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


C# EnumMemberDeclaration类代码示例

本文整理汇总了C#中EnumMemberDeclaration的典型用法代码示例。如果您正苦于以下问题:C# EnumMemberDeclaration类的具体用法?C# EnumMemberDeclaration怎么用?C# EnumMemberDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetActions

		public IEnumerable<CodeAction> GetActions(RefactoringContext context)
		{
			var expr = GetCreatePropertyOrFieldNode(context);
			if (expr == null)
				yield break;
			if (!(expr is MemberReferenceExpression))
				yield break;
			var propertyName = CreatePropertyAction.GetPropertyName(expr);
			if (propertyName == null)
				yield break;
			if (IsInvocationTarget(expr))
				yield break;
			var statement = expr.GetParent<Statement>();
			if (statement == null)
				yield break;
			if (!(context.Resolve(expr).IsError))
				yield break;
			var guessedType = CreateFieldAction.GuessType(context, expr);
			if (guessedType == null || guessedType.Kind != TypeKind.Enum)
				yield break;
			var state = context.GetResolverStateBefore(expr);
			if (state.CurrentMember == null || state.CurrentTypeDefinition == null)
				yield break;

			yield return new CodeAction(context.TranslateString("Create enum value"), script => {
				var decl = new EnumMemberDeclaration {
					Name = propertyName
				};
				script.InsertWithCursor(context.TranslateString("Create enum value"), guessedType.GetDefinition (), decl);
			});
			
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:32,代码来源:CreateEnumValue.cs

示例2: VisitEnumMemberDeclaration

 public override object VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data)
 {
     if(!enumMemberDeclaration.Initializer.IsNull)
     {
         UnlockWith(enumMemberDeclaration.Initializer);
     }
     return base.VisitEnumMemberDeclaration(enumMemberDeclaration, data);
 }
开发者ID:vlad2135,项目名称:strokes,代码行数:8,代码来源:EnumInitializerExplicitAchievement.cs

示例3: VisitEnumMemberDeclaration

        public override void VisitEnumMemberDeclaration(EnumMemberDeclaration ed)
        {
            ModelV2.Code.Enum e = (ModelV2.Code.Enum) GetDeclarationFor(ed);

            string[] keyValue = ed.GetText().Split('=');
            e.Values.Add(new KeyValuePair<string,string>(keyValue[0], (keyValue.Length == 2) ? keyValue[1] : ""));

            // call base
            base.VisitEnumMemberDeclaration(ed);
        }
开发者ID:goncalod,项目名称:csharp,代码行数:10,代码来源:NRefactoryVisitorV2.cs

示例4: VisitEnumMemberDeclaration

        public override void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration)
        {
            Expression initializer = enumMemberDeclaration.Initializer;
            if (enumMemberDeclaration.Initializer.IsNull)
            {
                initializer = new PrimitiveExpression(this.CurrentType.LastEnumValue);
            }

            this.CurrentType.StaticConfig.Fields.Add(new TypeConfigItem
            {
                Name = enumMemberDeclaration.Name,
                Entity = enumMemberDeclaration,
                Initializer = initializer
            });
        }
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:15,代码来源:Inspector.Visitor.cs

示例5: VisitEnumMemberDeclaration

        public override void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration)
        {
            Expression initializer = enumMemberDeclaration.Initializer;
            if (enumMemberDeclaration.Initializer.IsNull)
            {
                if (this.CurrentType.Type.GetDefinition().Attributes.Any(attr => attr.AttributeType.FullName == "System.FlagsAttribute"))
                {
                    if (this.CurrentType.LastEnumValue <= 0)
                    {
                        this.CurrentType.LastEnumValue = 1;
                    }
                    else
                    {
                        this.CurrentType.LastEnumValue *= 2;
                    }

                    initializer = new PrimitiveExpression(this.CurrentType.LastEnumValue);
                }
                else
                {
                    initializer = new PrimitiveExpression(++this.CurrentType.LastEnumValue);
                }
            }
            else
            {
                var rr = this.Resolver.ResolveNode(enumMemberDeclaration.Initializer, null) as ConstantResolveResult;
                if (rr != null)
                {
                    initializer = new PrimitiveExpression(rr.ConstantValue);
                    this.CurrentType.LastEnumValue = (int)rr.ConstantValue;
                }
            }

            this.CurrentType.StaticConfig.Fields.Add(new TypeConfigItem
            {
                Name = enumMemberDeclaration.Name,
                Entity = enumMemberDeclaration,
                Initializer = initializer
            });
        }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:40,代码来源:Inspector.Visitor.cs

示例6: VisitEnumMemberDeclaration

        public override void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration)
        {
            Expression initializer = enumMemberDeclaration.Initializer;
            if (enumMemberDeclaration.Initializer.IsNull)
            {
                initializer = new PrimitiveExpression(++this.CurrentType.LastEnumValue);
            }
            else
            {
                var rr = this.Resolver.ResolveNode(enumMemberDeclaration.Initializer, null) as ConstantResolveResult;
                if (rr != null)
                {
                    initializer = new PrimitiveExpression(rr.ConstantValue);
                    this.CurrentType.LastEnumValue = (int)rr.ConstantValue;
                }
            }

            this.CurrentType.StaticConfig.Fields.Add(new TypeConfigItem
            {
                Name = enumMemberDeclaration.Name,
                Entity = enumMemberDeclaration,
                Initializer = initializer
            });
        }
开发者ID:TerribleDev,项目名称:Bridge,代码行数:24,代码来源:Inspector.Visitor.cs

示例7: VisitEnumDecl

		public override void VisitEnumDecl(EnumDecl decl, VisitKind visitKind)
		{
			if (visitKind != VisitKind.Enter || !decl.IsCompleteDefinition || decl.QualifiedName == null)
				return;

			if (!decl.QualifiedName.StartsWith ("Urho")) {
				if (!decl.QualifiedName.ToLower ().Contains ("loopmode2d"))
			
				return;
			}
			
			//Console.WriteLine($"VisitingType: {decl.QualifiedName}");
			string typeName = RemapTypeName(decl.Name);

			PushType(new TypeDeclaration
			{
				Name = typeName,
				ClassType = ClassType.Enum,
				Modifiers = Modifiers.Public
			}, StringUtil.GetTypeComments(decl));

			foreach (var constantDecl in decl.Decls<EnumConstantDecl>()) {
				var valueName = RemapEnumName (typeName, constantDecl.Name);

				switch (valueName) {
				// LIST HERE ANY Values we want to skip
				case "foo":
				case null:
					continue;

				}
				var x = new EnumMemberDeclaration();
				var enumValue = new EnumMemberDeclaration { Name = valueName };
				if (constantDecl.InitExpr != null) {
					APSInt v;

					constantDecl.InitExpr.EvaluateAsInt (decl.AstContext, out v);
					var ul = v.GetLimitedValue ();
					PrimitiveExpression value;
					if ((ul & 0xffffffff) == ul)
						value = new PrimitiveExpression ((int)ul);
					else
						throw new NotImplementedException ($"Got a {ul} value which will not fit on an int, you must manually handle this case in the generatorg");
					enumValue.Initializer = value;
				}
				currentType.Members.Add(enumValue);
			}
		}
开发者ID:corefan,项目名称:urho,代码行数:48,代码来源:CxxBinder.cs

示例8: CreateType

		public TypeDeclaration CreateType(TypeDefinition typeDef)
		{
			TypeDefinition oldCurrentType = context.CurrentType;
			context.CurrentType = typeDef;
			TypeDeclaration astType = new TypeDeclaration();
			ConvertAttributes(astType, typeDef);
			astType.AddAnnotation(typeDef);
			astType.Modifiers = ConvertModifiers(typeDef);
			astType.Name = CleanName(typeDef.Name);
			
			if (typeDef.IsEnum) {  // NB: Enum is value type
				astType.ClassType = ClassType.Enum;
				astType.Modifiers &= ~Modifiers.Sealed;
			} else if (typeDef.IsValueType) {
				astType.ClassType = ClassType.Struct;
				astType.Modifiers &= ~Modifiers.Sealed;
			} else if (typeDef.IsInterface) {
				astType.ClassType = ClassType.Interface;
				astType.Modifiers &= ~Modifiers.Abstract;
			} else {
				astType.ClassType = ClassType.Class;
			}
			
			IEnumerable<GenericParameter> genericParameters = typeDef.GenericParameters;
			if (typeDef.DeclaringType != null && typeDef.DeclaringType.HasGenericParameters)
				genericParameters = genericParameters.Skip(typeDef.DeclaringType.GenericParameters.Count);
			astType.TypeParameters.AddRange(MakeTypeParameters(genericParameters));
			astType.Constraints.AddRange(MakeConstraints(genericParameters));
			
			// Nested types
			foreach(TypeDefinition nestedTypeDef in typeDef.NestedTypes) {
				if (MemberIsHidden(nestedTypeDef, context.Settings))
					continue;
				astType.AddChild(CreateType(nestedTypeDef), TypeDeclaration.MemberRole);
			}
			
			
			if (typeDef.IsEnum) {
				long expectedEnumMemberValue = 0;
				bool forcePrintingInitializers = IsFlagsEnum(typeDef);
				foreach (FieldDefinition field in typeDef.Fields) {
					if (field.IsRuntimeSpecialName) {
						// the value__ field
						if (field.FieldType != typeDef.Module.TypeSystem.Int32) {
							astType.AddChild(ConvertType(field.FieldType), TypeDeclaration.BaseTypeRole);
						}
					} else {
						EnumMemberDeclaration enumMember = new EnumMemberDeclaration();
						enumMember.Name = CleanName(field.Name);
						long memberValue = (long)CSharpPrimitiveCast.Cast(TypeCode.Int64, field.Constant, false);
						if (forcePrintingInitializers || memberValue != expectedEnumMemberValue) {
							enumMember.AddChild(new PrimitiveExpression(field.Constant), EnumMemberDeclaration.InitializerRole);
						}
						expectedEnumMemberValue = memberValue + 1;
						astType.AddChild(enumMember, TypeDeclaration.MemberRole);
					}
				}
			} else {
				// Base type
				if (typeDef.BaseType != null && !typeDef.IsValueType && typeDef.BaseType.FullName != "System.Object") {
					astType.AddChild(ConvertType(typeDef.BaseType), TypeDeclaration.BaseTypeRole);
				}
				foreach (var i in typeDef.Interfaces)
					astType.AddChild(ConvertType(i), TypeDeclaration.BaseTypeRole);
				
				
				AddTypeMembers(astType, typeDef);
			}

			context.CurrentType = oldCurrentType;
			return astType;
		}
开发者ID:eldersantos,项目名称:ILSpy,代码行数:72,代码来源:AstBuilder.cs

示例9: Visit

			public override void Visit (EnumMember em)
			{
				EnumMemberDeclaration newField = new EnumMemberDeclaration ();
				VariableInitializer variable = new VariableInitializer ();
				
				variable.AddChild (new Identifier (em.Name, Convert (em.Location)), AstNode.Roles.Identifier);
				
				if (em.Initializer != null) {
					var initializer = (AstNode)em.Initializer.Accept (this);
					if (initializer != null)
						variable.AddChild (initializer, AstNode.Roles.Initializer);
				}
				
				newField.AddChild (variable, AstNode.Roles.Initializer);
				typeStack.Peek ().AddChild (newField, TypeDeclaration.Roles.Member);
			}
开发者ID:tech-uday-mca,项目名称:monodevelop,代码行数:16,代码来源:CSharpParser.cs

示例10: VisitEnumMemberDeclaration

        public void VisitEnumMemberDeclaration(EnumMemberDeclaration node)
        {
            // Ensure all enum members have a value
            if (node.Initializer.IsNull) {
                node.Initializer = new PrimitiveExpression(nextEnumValue++);
            } else {
                var result = resolver.Resolve(node.Initializer) as ConstantResolveResult;
                if (result != null && result.ConstantValue is int) {
                    node.Initializer = new PrimitiveExpression((int)result.ConstantValue);
                    nextEnumValue = (int)result.ConstantValue + 1;
                } else {
                    NotSupported(node.Initializer);
                }
            }

            VisitChildren(node);
        }
开发者ID:evanw,项目名称:minisharp,代码行数:17,代码来源:Lower.cs

示例11: VisitEnumMemberDeclaration

		public virtual void VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration)
		{
			VisitChildren (enumMemberDeclaration);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs

示例12: VisitEnumMemberDeclaration

 public override void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration)
 {
     _currentEnumMembers.Add(new NameNode(enumMemberDeclaration.Name, enumMemberDeclaration));
     base.VisitEnumMemberDeclaration(enumMemberDeclaration);
 }
开发者ID:KvanTTT,项目名称:CSharp-Minifier,代码行数:5,代码来源:MinifyEnumsAstVisitor.cs

示例13: Visit

			public override void Visit (EnumMember em)
			{
				EnumMemberDeclaration newField = new EnumMemberDeclaration ();
				AddAttributeSection (newField, em);
				newField.AddChild (Identifier.Create (em.Name, Convert (em.Location)), AstNode.Roles.Identifier);
				
				if (em.Initializer != null) {
					newField.AddChild (new CSharpTokenNode (Convert (em.Initializer.Location), 1), EnumMemberDeclaration.Roles.Assign);
					newField.AddChild ((Expression)em.Initializer.Accept (this), EnumMemberDeclaration.InitializerRole);
				}
				
				typeStack.Peek ().AddChild (newField, TypeDeclaration.MemberRole);
			}
开发者ID:severinh,项目名称:monodevelop-vala-afrodite-update,代码行数:13,代码来源:CSharpParser.cs

示例14: VisitEnumMemberDeclaration

 public virtual void VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(enumMemberDeclaration);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs

示例15: CreateType

        public TypeDeclaration CreateType(TypeDefinition typeDef)
        {
            TypeDeclaration astType = new TypeDeclaration();
            astType.Modifiers = ConvertModifiers(typeDef);
            astType.Name = typeDef.Name;

            if (typeDef.IsEnum) {  // NB: Enum is value type
                astType.ClassType = ClassType.Enum;
                astType.Modifiers &= ~Modifiers.Sealed;
            } else if (typeDef.IsValueType) {
                astType.ClassType = ClassType.Struct;
                astType.Modifiers &= ~Modifiers.Sealed;
            } else if (typeDef.IsInterface) {
                astType.ClassType = ClassType.Interface;
                astType.Modifiers &= ~Modifiers.Abstract;
            } else {
                astType.ClassType = ClassType.Class;
            }

            // Nested types
            foreach(TypeDefinition nestedTypeDef in typeDef.NestedTypes) {
                astType.AddChild(CreateType(nestedTypeDef), TypeDeclaration.MemberRole);
            }

            if (typeDef.IsEnum) {
                foreach (FieldDefinition field in typeDef.Fields) {
                    if (field.IsRuntimeSpecialName) {
                        // the value__ field
                        astType.AddChild(ConvertType(field.FieldType), TypeDeclaration.BaseTypeRole);
                    } else {
                        EnumMemberDeclaration enumMember = new EnumMemberDeclaration();
                        enumMember.Name = field.Name;
                        astType.AddChild(enumMember, TypeDeclaration.MemberRole);
                    }
                }
            } else {
                // Base type
                if (typeDef.BaseType != null && !typeDef.IsValueType && typeDef.BaseType.FullName != Constants.Object) {
                    astType.AddChild(ConvertType(typeDef.BaseType), TypeDeclaration.BaseTypeRole);
                }
                foreach (var i in typeDef.Interfaces)
                    astType.AddChild(ConvertType(i), TypeDeclaration.BaseTypeRole);

                AddTypeMembers(astType, typeDef);
            }

            return astType;
        }
开发者ID:KleinR,项目名称:ILSpy,代码行数:48,代码来源:AstBuilder.cs


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