当前位置: 首页>>代码示例>>C#>>正文


C# InvocationExpression.GetParent方法代码示例

本文整理汇总了C#中InvocationExpression.GetParent方法的典型用法代码示例。如果您正苦于以下问题:C# InvocationExpression.GetParent方法的具体用法?C# InvocationExpression.GetParent怎么用?C# InvocationExpression.GetParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InvocationExpression的用法示例。


在下文中一共展示了InvocationExpression.GetParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsConditionallyRemoved

        public static bool IsConditionallyRemoved(InvocationExpression invocationExpression, IEntity entity)
 		{
            if (entity == null)
            {
                return false;
            }
 			var result = new List<string>();
 			foreach (var a in entity.Attributes)
 			{
 				var type = a.AttributeType.GetDefinition();
 				if (type != null && type.FullName.Equals("System.Diagnostics.ConditionalAttribute", StringComparison.Ordinal))
                {
 					if (a.PositionalArguments.Count > 0)
                    {
 						var symbol = a.PositionalArguments[0].ConstantValue as string;
                        if (symbol != null)
                        {
                            result.Add(symbol);
                        }
 					}
 				}
 			}

            if (result.Count > 0)
            {
                var syntaxTree = invocationExpression.GetParent<SyntaxTree>();
                if (syntaxTree != null)
                {
                    return !result.Intersect(syntaxTree.ConditionalSymbols).Any();    
                }
            }

 			return false;
 		}
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:34,代码来源:InvocationBlock.cs

示例2: VisitInvocationExpression

        public override void VisitInvocationExpression(InvocationExpression invocationExpression)
        {
            var match = this.m_Pattern.Match(invocationExpression);
            if (match.Success)
            {
                var method = (invocationExpression.Target as MemberReferenceExpression).MemberName;
                if (method == "Write" || method == "WriteLine")
                {
                    // FIXME: Couldn't get a pattern matcher to work on the MethodDeclaration.
                    var declMethod = invocationExpression.GetParent<MethodDeclaration>();
                    if (declMethod == null)
                    {
                        base.VisitInvocationExpression(invocationExpression);
                        return;
                    }
                    var allowed = (
                        declMethod.Name == "Main" &&
                        declMethod.Modifiers == (Modifiers.Public | Modifiers.Static) &&
                        declMethod.ReturnType.ToString() == "void" &&
                        declMethod.Parameters.Count == 1 &&
                        declMethod.Parameters.ToList()[0].Type.ToString() == "string[]");
                    if (!allowed)
                    {
                        this.Results.Issues.Add(new LintIssue(invocationExpression)
                        {
                            Index = LintIssueIndex.ConsoleWriteUsedOutsideOfProgramMain,
                            Parameters = new[]
                            {
                                declMethod.GetParent<TypeDeclaration>().Name + "." + declMethod.Name
                            }
                        });
                    }
                }
            }

            base.VisitInvocationExpression(invocationExpression);
        }
开发者ID:ow-pastuch,项目名称:cstools,代码行数:37,代码来源:ConsoleWriteUsedOutsideOfProgramMainPolicy.cs


注:本文中的InvocationExpression.GetParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。