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


C# TypeDeclaration.GetParent方法代码示例

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


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

示例1: CreateTypeSignature

 public static string CreateTypeSignature(TypeDeclaration type)
 {
     var @namespace = type.GetParent<NamespaceDeclaration>();
     var builder = new StringBuilder();
     builder.Append(@namespace.FullName.ToJavaNamespace());
     builder.Append("/");
     builder.Append(type.Name);
     return builder.ToString();
 }
开发者ID:hach-que,项目名称:cscjvm,代码行数:9,代码来源:JavaSignature.cs

示例2: VisitTypeDeclaration

        public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
        {
            if (!typeDeclaration.HasModifier(Modifiers.Public))
            {
                base.VisitTypeDeclaration(typeDeclaration);
                return;
            }

            var parent = typeDeclaration.GetParent<TypeDeclaration>();
            if (parent != null && typeDeclaration.HasModifier(Modifiers.Public))
            {
                this.Results.Issues.Add(new LintIssue(typeDeclaration)
                {
                    Index = LintIssueIndex.PublicNestedClassDefined,
                    Parameters = new[]
                    {
                        typeDeclaration.Name
                    }
                });
            }

            base.VisitTypeDeclaration(typeDeclaration);
        }
开发者ID:ow-pastuch,项目名称:cstools,代码行数:23,代码来源:EnsureNoNestedPublicClassesPolicy.cs

示例3: VisitTypeDeclaration

        public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
        {
            if (this.CurrentType != null)
            {
                this.NestedTypes = this.NestedTypes ?? new List<Tuple<TypeDeclaration, ITypeInfo>>();
                this.NestedTypes.Add(new Tuple<TypeDeclaration, ITypeInfo>(typeDeclaration, this.CurrentType));
                return;
            }

            ValidateNamespace(typeDeclaration);

            if (this.HasIgnore(typeDeclaration))
            {
                return;
            }

            var rr = this.Resolver.ResolveNode(typeDeclaration, null);
            var fullName = rr.Type.ReflectionName;
            var partialType = this.Types.FirstOrDefault(t => t.Key == fullName);
            var add = true;

            if (partialType == null)
            {
                ITypeInfo parentTypeInfo = null;
                var parentTypeDeclaration = typeDeclaration.GetParent<TypeDeclaration>();
                if (parentTypeDeclaration != null)
                {
                    var rr1 = this.Resolver.ResolveNode(parentTypeDeclaration, null);
                    var parentName = rr1.Type.ReflectionName;
                    parentTypeInfo = this.Types.FirstOrDefault(t => t.Key == parentName);
                }

                this.CurrentType = new TypeInfo()
                {
                    Key = rr.Type.ReflectionName,
                    TypeDeclaration = typeDeclaration,
                    ParentType = parentTypeInfo,
                    Name = typeDeclaration.Name,
                    ClassType = typeDeclaration.ClassType,
                    Namespace = this.Namespace,
                    Usings = new HashSet<string>(Usings),
                    IsEnum = typeDeclaration.ClassType == ClassType.Enum,
                    IsStatic = typeDeclaration.ClassType == ClassType.Enum || typeDeclaration.HasModifier(Modifiers.Static),
                    IsObjectLiteral = this.IsObjectLiteral(typeDeclaration),
                    Type = rr.Type
                };

                if (parentTypeInfo != null && Emitter.reservedStaticNames.Any(n => String.Equals(this.CurrentType.Name, n, StringComparison.InvariantCultureIgnoreCase)))
                {
                    throw new EmitterException(typeDeclaration, "Nested class cannot have such name: " + this.CurrentType.Name + ". Please rename it.");
                }
            }
            else
            {
                this.CurrentType = partialType;
                add = false;
            }

            if (typeDeclaration.ClassType != ClassType.Interface)
            {
                typeDeclaration.AcceptChildren(this);
            }
            else
            {
                typeDeclaration.AcceptChildren(this);
            }

            if (add)
            {
                this.Types.Add(this.CurrentType);
            }

            this.CurrentType = null;

            while (this.NestedTypes != null && this.NestedTypes.Count > 0)
            {
                var types = this.NestedTypes;
                this.NestedTypes = null;
                foreach (var nestedType in types)
                {
                    this.VisitTypeDeclaration(nestedType.Item1);
                }
            }
        }
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:84,代码来源:Inspector.Visitor.cs


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