• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CSharp.Field类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: DoResolveLValue

        public override Expression DoResolveLValue(ResolveContext ec, Expression right_side)
        {
            Expression ret = base.DoResolveLValue (ec, right_side);
            if (ret == null)
                return null;

            Field f = new Field (container, new TypeExpression (ret.Type, Location),
                         Modifiers.PUBLIC | Modifiers.STATIC,
                         new MemberName (name, Location), null);
            container.AddField (f);
            if (f.Define ())
                Evaluator.QueueField (f);

            return ret;
        }
开发者ID:speier,项目名称:shake,代码行数:15,代码来源:eval.cs


示例2: Create

		public static AnonymousTypeClass Create (TypeContainer parent, IList<AnonymousTypeParameter> parameters, Location loc)
		{
			string name = ClassNamePrefix + parent.Module.CounterAnonymousTypes++;

			ParametersCompiled all_parameters;
			TypeParameters tparams = null;
			SimpleName[] t_args;

			if (parameters.Count == 0) {
				all_parameters = ParametersCompiled.EmptyReadOnlyParameters;
				t_args = null;
			} else {
				t_args = new SimpleName[parameters.Count];
				tparams = new TypeParameters ();
				Parameter[] ctor_params = new Parameter[parameters.Count];
				for (int i = 0; i < parameters.Count; ++i) {
					AnonymousTypeParameter p = parameters[i];
					for (int ii = 0; ii < i; ++ii) {
						if (parameters[ii].Name == p.Name) {
							parent.Compiler.Report.Error (833, parameters[ii].Location,
								"`{0}': An anonymous type cannot have multiple properties with the same name",
									p.Name);

							p = new AnonymousTypeParameter (null, "$" + i.ToString (), p.Location);
							parameters[i] = p;
							break;
						}
					}

					t_args[i] = new SimpleName ("<" + p.Name + ">__T", p.Location);
					tparams.Add (new TypeParameter (i, new MemberName (t_args[i].Name, p.Location), null, null, Variance.None));
					ctor_params[i] = new Parameter (t_args[i], p.Name, Parameter.Modifier.NONE, null, p.Location);
				}

				all_parameters = new ParametersCompiled (ctor_params);
			}

			//
			// Create generic anonymous type host with generic arguments
			// named upon properties names
			//
			AnonymousTypeClass a_type = new AnonymousTypeClass (parent.Module, new MemberName (name, tparams, loc), parameters, loc);

			Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
				null, all_parameters, loc);
			c.Block = new ToplevelBlock (parent.Module.Compiler, c.ParameterInfo, loc);

			// 
			// Create fields and constructor body with field initialization
			//
			bool error = false;
			for (int i = 0; i < parameters.Count; ++i) {
				AnonymousTypeParameter p = parameters [i];

				Field f = new Field (a_type, t_args [i], Modifiers.PRIVATE | Modifiers.READONLY | Modifiers.DEBUGGER_HIDDEN,
					new MemberName ("<" + p.Name + ">", p.Location), null);

				if (!a_type.AddField (f)) {
					error = true;
					continue;
				}

				c.Block.AddStatement (new StatementExpression (
					new SimpleAssign (new MemberAccess (new This (p.Location), f.Name),
						c.Block.GetParameterReference (i, p.Location))));

				ToplevelBlock get_block = new ToplevelBlock (parent.Module.Compiler, p.Location);
				get_block.AddStatement (new Return (
					new MemberAccess (new This (p.Location), f.Name), p.Location));

				Property prop = new Property (a_type, t_args [i], Modifiers.PUBLIC,
					new MemberName (p.Name, p.Location), null);
				prop.Get = new Property.GetMethod (prop, 0, null, p.Location);
				prop.Get.Block = get_block;
				a_type.AddMember (prop);
			}

			if (error)
				return null;

			a_type.AddConstructor (c);
			return a_type;
		}
开发者ID:rabink,项目名称:mono,代码行数:83,代码来源:anonymous.cs


示例3: HoistedVariable

		protected HoistedVariable (AnonymousMethodStorey storey, Field field)
		{
			this.storey = storey;
			this.field = field;
		}
开发者ID:rabink,项目名称:mono,代码行数:5,代码来源:anonymous.cs


示例4: HoistedEvaluatorVariable

		public HoistedEvaluatorVariable (Field field)
			: base (null, field)
		{
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:eval.cs


示例5: Emit

		public override void Emit (EmitContext ec)
		{
			//
			// Use same anonymous method implementation for scenarios where same
			// code is used from multiple blocks, e.g. field initializers
			//
			if (method == null) {
				//
				// Delay an anonymous method definition to avoid emitting unused code
				// for unreachable blocks or expression trees
				//
				method = DoCreateMethodHost (ec);
				method.Define ();
			}

			bool is_static = (method.ModFlags & Modifiers.STATIC) != 0;
			if (is_static && am_cache == null) {
				//
				// Creates a field cache to store delegate instance if it's not generic
				//
				if (!method.MemberName.IsGeneric) {
					var parent = method.Parent.PartialContainer;
					int id = parent.AnonymousMethodsCounter++;
					var cache_type = storey != null && storey.Mutator != null ? storey.Mutator.Mutate (type) : type;

					am_cache = new Field (parent, new TypeExpression (cache_type, loc),
						Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED,
						new MemberName (CompilerGeneratedContainer.MakeName (null, "f", "am$cache", id), loc), null);
					am_cache.Define ();
					parent.AddField (am_cache);
				} else {
					// TODO: Implement caching of generated generic static methods
					//
					// Idea:
					//
					// Some extra class is needed to capture variable generic type
					// arguments. Maybe we could re-use anonymous types, with a unique
					// anonymous method id, but they are quite heavy.
					//
					// Consider : "() => typeof(T);"
					//
					// We need something like
					// static class Wrap<Tn, Tm, DelegateType> {
					//		public static DelegateType cache;
					// }
					//
					// We then specialize local variable to capture all generic parameters
					// and delegate type, e.g. "Wrap<Ta, Tb, DelegateTypeInst> cache;"
					//
				}
			}

			Label l_initialized = ec.DefineLabel ();

			if (am_cache != null) {
				ec.Emit (OpCodes.Ldsfld, am_cache.Spec);
				ec.Emit (OpCodes.Brtrue_S, l_initialized);
			}

			//
			// Load method delegate implementation
			//

			if (is_static) {
				ec.EmitNull ();
			} else if (storey != null) {
				Expression e = storey.GetStoreyInstanceExpression (ec).Resolve (new ResolveContext (ec.MemberContext));
				if (e != null) {
					e.Emit (ec);
				}
			} else {
				ec.EmitThis ();

				//
				// Special case for value type storey where this is not lifted but
				// droped off to parent class
				//
				for (var b = Block.Parent; b != null; b = b.Parent) {
					if (b.ParametersBlock.StateMachine != null) {
						ec.Emit (OpCodes.Ldfld, b.ParametersBlock.StateMachine.HoistedThis.Field.Spec);
						break;
					}
				}
			}

			var delegate_method = method.Spec;
			if (storey != null && storey.MemberName.IsGeneric) {
				TypeSpec t = storey.Instance.Type;

				//
				// Mutate anonymous method instance type if we are in nested
				// hoisted generic anonymous method storey
				//
				if (ec.IsAnonymousStoreyMutateRequired) {
					t = storey.Mutator.Mutate (t);
				}

				ec.Emit (OpCodes.Ldftn, TypeBuilder.GetMethod (t.GetMetaInfo (), (MethodInfo) delegate_method.GetMetaInfo ()));
			} else {
				if (delegate_method.IsGeneric)
//.........这里部分代码省略.........
开发者ID:rabink,项目名称:mono,代码行数:101,代码来源:anonymous.cs


示例6: Visit

			public override void Visit(Field f)
			{
				var location = LocationsBag.GetMemberLocation(f);
				
				var newField = new FieldDeclaration();
				AddAttributeSection(newField, f);
				AddModifiers(newField, location);
				newField.AddChild(ConvertToType(f.TypeExpression), Roles.Type);
				
				var variable = new VariableInitializer();
				variable.AddChild(Identifier.Create(f.MemberName.Name, Convert(f.MemberName.Location)), Roles.Identifier);
				int locationIdx = 0;
				if (f.Initializer != null) {
					if (location != null)
						variable.AddChild(new CSharpTokenNode(Convert(location [locationIdx++]), Roles.Assign), Roles.Assign);
					variable.AddChild((Expression)f.Initializer.Accept(this), Roles.Expression);
				}
				newField.AddChild(variable, Roles.Variable);
				if (f.Declarators != null) {
					foreach (var decl in f.Declarators) {
						var declLoc = LocationsBag.GetLocations(decl);
						if (declLoc != null)
							newField.AddChild(new CSharpTokenNode(Convert(declLoc [0]), Roles.Comma), Roles.Comma);
						
						variable = new VariableInitializer();
						variable.AddChild(Identifier.Create(decl.Name.Value, Convert(decl.Name.Location)), Roles.Identifier);
						if (decl.Initializer != null) {
							if (declLoc != null)
								variable.AddChild(new CSharpTokenNode(Convert(declLoc [1]), Roles.Assign), Roles.Assign);
							variable.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression);
						}
						newField.AddChild(variable, Roles.Variable);
					}
				}
				if (location != null && location.Count > locationIdx)
					newField.AddChild(new CSharpTokenNode(Convert(location [locationIdx++]), Roles.Semicolon), Roles.Semicolon);

				typeStack.Peek().AddChild(newField, Roles.TypeMemberRole);
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:39,代码来源:CSharpParser.cs


示例7: Define

		public override bool Define()
		{
			var mod_flags_src = ModFlags;

			if (!base.Define ())
				return false;

			if (declarators != null) {
				if ((mod_flags_src & Modifiers.DEFAULT_ACCESS_MODIFER) != 0)
					mod_flags_src &= ~(Modifiers.AccessibilityMask | Modifiers.DEFAULT_ACCESS_MODIFER);

				var t = new TypeExpression (MemberType, TypeExpression.Location);
				foreach (var d in declarators) {
					var ef = new EventField (Parent, t, mod_flags_src, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);

					if (d.Initializer != null)
						ef.initializer = d.Initializer;

					ef.Define ();
					Parent.PartialContainer.Members.Add (ef);
				}
			}

			if (!HasBackingField) {
				SetIsUsed ();
				return true;
			}

			if (Add.IsInterfaceImplementation)
				SetIsUsed ();

			backing_field = new Field (Parent,
				new TypeExpression (MemberType, Location),
				Modifiers.BACKING_FIELD | Modifiers.COMPILER_GENERATED | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
				MemberName, null);

			Parent.PartialContainer.Members.Add (backing_field);
			backing_field.Initializer = Initializer;
			backing_field.ModFlags &= ~Modifiers.COMPILER_GENERATED;

			// Call define because we passed fields definition
			backing_field.Define ();

			// Set backing field for event fields
			spec.BackingField = backing_field.Spec;

			return true;
		}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:48,代码来源:property.cs


示例8: AddCompilerGeneratedField

		protected Field AddCompilerGeneratedField (string name, FullNamedExpression type)
		{
			const Modifiers mod = Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED;
			Field f = new Field (this, type, mod, new MemberName (name, Location), null);
			AddField (f);
			return f;
		}
开发者ID:pgoron,项目名称:monodevelop,代码行数:7,代码来源:anonymous.cs


示例9: AssemblyAttributesPlaceholder

		public AssemblyAttributesPlaceholder (ModuleContainer parent, string outputName)
			: base (parent, new MemberName (GetGeneratedName (outputName)), Modifiers.STATIC)
		{
			assembly = new Field (this, new TypeExpression (TypeManager.object_type, Location), Modifiers.PUBLIC | Modifiers.STATIC,
				new MemberName (AssemblyFieldName), null);

			AddField (assembly);
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:8,代码来源:assembly.cs


示例10: Visit

		public virtual void Visit (Field f)
		{
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:3,代码来源:visit.cs


示例11: Create

		public static AnonymousTypeClass Create (CompilerContext ctx, TypeContainer parent, IList<AnonymousTypeParameter> parameters, Location loc)
		{
			string name = ClassNamePrefix + types_counter++;

			SimpleName [] t_args = new SimpleName [parameters.Count];
			TypeParameterName [] t_params = new TypeParameterName [parameters.Count];
			Parameter [] ctor_params = new Parameter [parameters.Count];
			for (int i = 0; i < parameters.Count; ++i) {
				AnonymousTypeParameter p = (AnonymousTypeParameter) parameters [i];

				t_args [i] = new SimpleName ("<" + p.Name + ">__T", p.Location);
				t_params [i] = new TypeParameterName (t_args [i].Name, null, p.Location);
				ctor_params [i] = new Parameter (t_args [i], p.Name, 0, null, p.Location);
			}

			//
			// Create generic anonymous type host with generic arguments
			// named upon properties names
			//
			AnonymousTypeClass a_type = new AnonymousTypeClass (parent.NamespaceEntry.SlaveDeclSpace,
				new MemberName (name, new TypeArguments (t_params), loc), parameters, loc);

			if (parameters.Count > 0)
				a_type.SetParameterInfo (null);

			Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
				null, new AnonymousParameters (ctx, ctor_params), null, loc);
			c.Block = new ToplevelBlock (ctx, c.ParameterInfo, loc);

			// 
			// Create fields and contructor body with field initialization
			//
			bool error = false;
			for (int i = 0; i < parameters.Count; ++i) {
				AnonymousTypeParameter p = (AnonymousTypeParameter) parameters [i];

				Field f = new Field (a_type, t_args [i], Modifiers.PRIVATE | Modifiers.READONLY,
					new MemberName ("<" + p.Name + ">", p.Location), null);

				if (!a_type.AddField (f)) {
					error = true;
					continue;
				}

				c.Block.AddStatement (new StatementExpression (
					new SimpleAssign (new MemberAccess (new This (p.Location), f.Name),
						c.Block.GetParameterReference (p.Name, p.Location))));

				ToplevelBlock get_block = new ToplevelBlock (ctx, p.Location);
				get_block.AddStatement (new Return (
					new MemberAccess (new This (p.Location), f.Name), p.Location));

				Property prop = new Property (a_type, t_args [i], Modifiers.PUBLIC,
					new MemberName (p.Name, p.Location), null);
				prop.Get = new Property.GetMethod (prop, 0, null, p.Location);
				prop.Get.Block = get_block;
				a_type.AddProperty (prop);
			}

			if (error)
				return null;

			a_type.AddConstructor (c);
			return a_type;
		}
开发者ID:pgoron,项目名称:monodevelop,代码行数:65,代码来源:anonymous.cs


示例12: ResolveStringSwitchMap

		void ResolveStringSwitchMap (ResolveContext ec)
		{
			FullNamedExpression string_dictionary_type;
			if (TypeManager.generic_ienumerable_type != null) {
				MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
					new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc), "Generic", loc);

				string_dictionary_type = new MemberAccess (system_collections_generic, "Dictionary",
					new TypeArguments (
						new TypeExpression (TypeManager.string_type, loc),
						new TypeExpression (TypeManager.int32_type, loc)), loc);
			} else {
				MemberAccess system_collections_generic = new MemberAccess (
					new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Collections", loc);

				string_dictionary_type = new MemberAccess (system_collections_generic, "Hashtable", loc);
			}

			var ctype = ec.CurrentMemberDefinition.Parent.PartialContainer;
			Field field = new Field (ctype, string_dictionary_type,
				Modifiers.STATIC | Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED,
				new MemberName (CompilerGeneratedClass.MakeName (null, "f", "switch$map", unique_counter++), loc), null);
			if (!field.Define ())
				return;
			ctype.AddField (field);

			var init = new List<Expression> ();
			int counter = 0;
			Elements.Clear ();
			string value = null;
			foreach (SwitchSection section in Sections) {
				int last_count = init.Count;
				foreach (SwitchLabel sl in section.Labels) {
					if (sl.Label == null || sl.Converted == SwitchLabel.NullStringCase)
						continue;

					value = (string) sl.Converted;
					var init_args = new List<Expression> (2);
					init_args.Add (new StringLiteral (value, sl.Location));
					init_args.Add (new IntConstant (counter, loc));
					init.Add (new CollectionElementInitializer (init_args, loc));
				}

				//
				// Don't add empty sections
				//
				if (last_count == init.Count)
					continue;

				Elements.Add (counter, section.Labels [0]);
				++counter;
			}

			Arguments args = new Arguments (1);
			args.Add (new Argument (new IntConstant (init.Count, loc)));
			Expression initializer = new NewInitialize (string_dictionary_type, args,
				new CollectionOrObjectInitializers (init, loc), loc);

			switch_cache_field = new FieldExpr (field, loc);
			string_dictionary = new SimpleAssign (switch_cache_field, initializer.Resolve (ec));
		}
开发者ID:alisci01,项目名称:mono,代码行数:61,代码来源:statement.cs


示例13: CreateEvaluatorVariable

		void CreateEvaluatorVariable (BlockContext bc, LocalVariable li)
		{
			var container = bc.CurrentMemberDefinition.Parent;

			Field f = new Field (container, new TypeExpression (li.Type, li.Location), Modifiers.PUBLIC | Modifiers.STATIC,
				new MemberName (li.Name, li.Location), null);

			container.AddField (f);
			f.Define ();
			Evaluator.QueueField (f);

			li.HoistedVariant = new HoistedEvaluatorVariable (f);
			li.SetIsUsed ();
		}
开发者ID:alisci01,项目名称:mono,代码行数:14,代码来源:statement.cs


示例14: Define

		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			try {
				Type[] required_modifier = null;
				if ((ModFlags & Modifiers.VOLATILE) != 0) {
					if (TypeManager.isvolatile_type == null)
						TypeManager.isvolatile_type = TypeManager.CoreLookupType (Compiler,
							"System.Runtime.CompilerServices", "IsVolatile", MemberKind.Class, true);

					if (TypeManager.isvolatile_type != null)
						required_modifier = new Type[] { TypeManager.isvolatile_type.GetMetaInfo () };
				}

				FieldBuilder = Parent.TypeBuilder.DefineField (
					Name, member_type.GetMetaInfo (), required_modifier, null, ModifiersExtensions.FieldAttr (ModFlags));

				spec = new FieldSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags);

				// Don't cache inaccessible fields
				if ((ModFlags & Modifiers.BACKING_FIELD) == 0) {
					Parent.MemberCache.AddMember (spec);
				}

				if (initializer != null) {
					((TypeContainer) Parent).RegisterFieldForInitialization (this,
						new FieldInitializer (spec, initializer, this));
				}
			} catch (ArgumentException) {
				Report.RuntimeMissingSupport (Location, "`void' or `void*' field type");
				return false;
			}

			if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				int index = Parent.PartialContainer.Fields.IndexOf (this);
				foreach (var d in declarators) {
					var f = new Field (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
					if (d.Initializer != null)
						f.initializer = d.Initializer;

					Parent.PartialContainer.Fields.Insert (++index, f);
				}
			}

			return true;
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:49,代码来源:field.cs


示例15: DynamicFieldExpr

 public DynamicFieldExpr(Field field, Location loc)
     : base(loc)
 {
     this.field = field;
 }
开发者ID:speier,项目名称:shake,代码行数:5,代码来源:iterators.cs


示例16: CreateAutomaticProperty

		void CreateAutomaticProperty ()
		{
			// Create backing field
			backing_field = new BackingField (this);
			if (!backing_field.Define ())
				return;

			Parent.PartialContainer.Members.Add (backing_field);

			FieldExpr fe = new FieldExpr (backing_field, Location);
			if ((backing_field.ModFlags & Modifiers.STATIC) == 0)
				fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);

			//
			// Create get block but we careful with location to
			// emit only single sequence point per accessor. This allow
			// to set a breakpoint on it even with no user code
			//
			Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
			Return r = new Return (fe, Get.Location);
			Get.Block.AddStatement (r);

			// Create set block
			Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location.Null);
			Assign a = new SimpleAssign (fe, new SimpleName ("value", Location.Null), Location.Null);
			Set.Block.AddStatement (new StatementExpression (a, Set.Location));
		}
开发者ID:nberardi,项目名称:mono,代码行数:27,代码来源:property.cs


示例17: Visit

			public override void Visit (Field f)
			{
				var field = new DomField ();
				field.Name = ConvertQuoted (f.MemberName.Name);
				field.Documentation = RetrieveDocumentation (f.Location.Row);
				field.Location = Convert (f.MemberName.Location);
				field.Modifiers = ConvertModifiers (f.ModFlags);
				field.ReturnType = ConvertReturnType (f.TypeName);
				AddAttributes (field, f.OptAttributes, f);
				field.DeclaringType = typeStack.Peek ();
				typeStack.Peek ().Add (field);
				
				if (f.Declarators != null) {
					foreach (var decl in f.Declarators) {
						field = new DomField ();
						field.Name = ConvertQuoted (decl.Name.Value);
						field.Location = Convert (decl.Name.Location);
						field.Modifiers = ConvertModifiers (f.ModFlags);
						field.ReturnType = ConvertReturnType (f.TypeName);
						AddAttributes (field, f.OptAttributes, f);
						field.DeclaringType = typeStack.Peek ();
						typeStack.Peek ().Add (field);
					}
				}
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:25,代码来源:McsParser.cs


示例18: HoistedLocalVariable

		//
		// For compiler generated local variables
		//
		public HoistedLocalVariable (AnonymousMethodStorey storey, Field field)
			: base (storey, field)
		{
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:7,代码来源:anonymous.cs


示例19: CreateSiteField

        static Field CreateSiteField(FullNamedExpression type)
        {
            TypeContainer site_container = CreateSiteContainer ();
            Field f = new Field (site_container, type, Modifiers.PUBLIC | Modifiers.STATIC,
                new MemberName ("Site" +  field_counter++), null);
            f.Define ();

            site_container.AddField (f);
            return f;
        }
开发者ID:speier,项目名称:shake,代码行数:10,代码来源:dynamic.cs


示例20: Define

		public override bool Define()
		{
			if (!base.Define ())
				return false;

			if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				int index = Parent.PartialContainer.Events.IndexOf (this);
				foreach (var d in declarators) {
					var ef = new EventField (Parent, t, ModFlags, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);

					if (d.Initializer != null)
						ef.initializer = d.Initializer;

					Parent.PartialContainer.Events.Insert (++index, ef);
				}
			}

			if (!HasBackingField) {
				SetIsUsed ();
				return true;
			}

			if (Add.IsInterfaceImplementation)
				SetIsUsed ();

			backing_field = new Field (Parent,
				new TypeExpression (MemberType, Location),
				Modifiers.BACKING_FIELD | Modifiers.COMPILER_GENERATED | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
				MemberName, null);

			Parent.PartialContainer.AddField (backing_field);
			backing_field.Initializer = Initializer;
			backing_field.ModFlags &= ~Modifiers.COMPILER_GENERATED;

			// Call define because we passed fields definition
			backing_field.Define ();

			// Set backing field for event fields
			spec.BackingField = backing_field.Spec;

			return true;
		}
开发者ID:afaerber,项目名称:mono,代码行数:43,代码来源:property.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.FieldBase类代码示例发布时间:2022-05-26
下一篇:
C# CSharp.ExpressionStatement类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap