Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created October 25, 2016 14:30
Show Gist options
  • Select an option

  • Save controlflow/5339934fbd1629437a933352c5f6ca63 to your computer and use it in GitHub Desktop.

Select an option

Save controlflow/5339934fbd1629437a933352c5f6ca63 to your computer and use it in GitHub Desktop.
public override bool Match(ITreeNode element, IMatchingContext context)
{
if (element == null)
return false;
if (element is ICSharpArgument arg)
element = arg.Value;
if (element is IExpressionInitializer exprInitializer)
element = exprInitializer.Value;
if (element is IAnonymousMemberDeclaration declaration)
{
if (!declaration.IsProjectionInitializer) return false;
element = declaration.Expression;
}
if (element is ILambdaParameterDeclaration lambda)
element = lambda.NameIdentifier;
if (element is IFieldDeclaration fieldDecl)
element = fieldDecl.NameIdentifier;
if (element is IEventDeclaration eventDecl)
element = eventDecl.NameIdentifier;
if (element is IQueryRangeVariableDeclaration rangeVar)
element = rangeVar.NameIdentifier;
if (element is ICatchVariableDeclaration catchVar)
element = catchVar.NameIdentifier;
...
}
public override bool Match(ITreeNode element, IMatchingContext context)
{
if (element == null)
return false;
if (element is ICSharpArgument)
element = ((ICSharpArgument)element).Value;
if (element is IExpressionInitializer)
element = ((IExpressionInitializer)element).Value;
if (element is IAnonymousMemberDeclaration)
{
var declaration = (IAnonymousMemberDeclaration)element;
if (!declaration.IsProjectionInitializer) return false;
element = declaration.Expression;
}
if (element is ILambdaParameterDeclaration)
element = ((ILambdaParameterDeclaration) element).NameIdentifier;
if (element is IFieldDeclaration)
element = ((IFieldDeclaration) element).NameIdentifier;
if (element is IEventDeclaration)
element = ((IEventDeclaration) element).NameIdentifier;
if (element is IQueryRangeVariableDeclaration)
element = ((IQueryRangeVariableDeclaration) element).NameIdentifier;
if (element is ICatchVariableDeclaration)
element = ((ICatchVariableDeclaration) element).NameIdentifier;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment