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


C# FieldDeclaration类代码示例

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


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

示例1: AddRange

		/// <summary>
		/// Adds the elements of an array to the end of this FieldDeclarationCollection.
		/// </summary>
		/// <param name="items">
		/// The array whose elements are to be added to the end of this FieldDeclarationCollection.
		/// </param>
		public virtual void AddRange(FieldDeclaration[] items)
		{
			foreach (FieldDeclaration item in items)
			{
				this.List.Add(item);
			}
		}
开发者ID:uQr,项目名称:NHibernate.Mapping.Attributes,代码行数:13,代码来源:FieldDeclarationCollection.cs

示例2: ExtendDeclaration

        public override void ExtendDeclaration(IDeclarationModel declaration, CompilationModel model)
        {
            // this only applies to properties
            var propDecl = declaration as PropertyDeclaration;
            if (propDecl == null || propDecl.Container == null)
                return;

            var container = propDecl.Container;
            container.RemoveMember(propDecl);

            var field = new FieldDeclaration
            {
                Container = container,
                OriginatingNode = propDecl.OriginatingNode,
                OriginatingTree = propDecl.OriginatingTree,
                Definition = new FieldDefinition
                {
                    Name = propDecl.Name,
                    ContainingType = propDecl.Definition.ContainingType,
                    Kind = DefinitionKind.Member,
                    MemberKind = MemberDefinitionKind.Field,
                    Type = propDecl.Definition.Type
                }
            };

            field.Definition.Modifiers.Apply(propDecl.Definition.Modifiers);
            container.AddMember(field);
        }
开发者ID:FlyingDeveloper,项目名称:blade,代码行数:28,代码来源:ScriptFieldExtension.cs

示例3: VisitFieldDeclaration

        // Fields there is only on Classes or Structs
        public override void VisitFieldDeclaration(FieldDeclaration fd)
        {
            ClassesAndStructs cs = (ClassesAndStructs)GetDeclarationFor(fd);

            string name = fd.Variables.Single().Name;
            string returnType = fd.ReturnType.ToString();
            Visibility v = new Visibility(VisibilityMapper.Map(fd.Modifiers));

            if (al.CheckFlag(fd.Modifiers, Modifiers.Const))
            {
                Constant cf = new Constant(v, name, returnType, fd.Variables.Single().Initializer.ToString());
                cs.ConstantFields.Add(cf);
            }

            else
            {
                Field f = new Field(v, name,
                     al.CheckFlag(fd.Modifiers, Modifiers.Static),
                     al.CheckFlag(fd.Modifiers, Modifiers.Readonly),
                     returnType
                );

                cs.Fields.Add(f);
            }
            AddToNotDefaultReferencedTypes(cs, returnType);

            // call base to forward execution
            base.VisitFieldDeclaration(fd);
        }
开发者ID:goncalod,项目名称:csharp,代码行数:30,代码来源:NRefactoryVisitorV2.cs

示例4: Run

		public void Run (RefactoringContext context)
		{
			var property = context.GetNode<PropertyDeclaration> ();
			
			string backingStoreName = context.GetNameProposal (property.Name);
			
			// create field
			var backingStore = new FieldDeclaration ();
			backingStore.ReturnType = property.ReturnType.Clone ();
			
			var initializer = new VariableInitializer (backingStoreName);
			backingStore.Variables.Add (initializer);
			
			// create new property & implement the get/set bodies
			var newProperty = (PropertyDeclaration)property.Clone ();
			var id1 = new IdentifierExpression (backingStoreName);
			var id2 = new IdentifierExpression (backingStoreName);
			newProperty.Getter.Body = new BlockStatement () {
				new ReturnStatement (id1)
			};
			newProperty.Setter.Body = new BlockStatement () {
				new ExpressionStatement (new AssignmentExpression (id2, AssignmentOperatorType.Assign, new IdentifierExpression ("value")))
			};
			
			using (var script = context.StartScript ()) {
				script.Replace (property, newProperty);
				script.InsertBefore (property, backingStore);
				script.Link (initializer, id1, id2);
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:30,代码来源:CreateBackingStore.cs

示例5: GenerateNewScript

		void GenerateNewScript(Script script, FieldDeclaration fieldDeclaration, RefactoringContext context)
        {
            var firstOrNullObject = fieldDeclaration.Variables.FirstOrNullObject();
		    if(firstOrNullObject==null)
                return;
			var matchedNodes = ComputeMatchNodes(context, firstOrNullObject);

		    foreach (var matchNode in matchedNodes)
            {
                var parent = matchNode.Parent;
                if (matchNode is VariableInitializer)
                {
                    script.Remove(parent);
                }
                else
                if (matchNode is IdentifierExpression)
                {
                    if(parent is AssignmentExpression)
                    {
                        script.Remove(parent.Parent);
                    }
                    else
                    {
                        var clone = (IdentifierExpression)matchNode.Clone();
                        clone.Identifier = "TODO";
                        script.Replace(matchNode, clone);
                    }
                }
            }
        }
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:30,代码来源:RemoveFieldRefactoryActionRefactoringAction.cs

示例6: VisitFieldDeclaration

        public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
        {
            CLRType t = m_clrTypes.Value.Last.Value;
            string name = fieldDeclaration.Variables.Single().Name;
            string returnType =  fieldDeclaration.ReturnType.ToString();
            Visibility v = new Visibility(VisibilityMapper.Map(fieldDeclaration.Modifiers));

            if (CheckFlag(fieldDeclaration.Modifiers, Modifiers.Const))
            {
                ConstField cf = new ConstField(v, name, returnType, fieldDeclaration.Variables.Single().Initializer.ToString());
                t.ConstantFields.Add(cf);   // connect
            }

            else
            {
                Field f = new Field(
                     CheckFlag(fieldDeclaration.Modifiers, Modifiers.Static),
                     CheckFlag(fieldDeclaration.Modifiers, Modifiers.Readonly),
                     v,
                     CheckFlag(fieldDeclaration.Modifiers, Modifiers.Virtual),
                     name,
                     CheckFlag(fieldDeclaration.Modifiers, Modifiers.Abstract),
                     returnType
                );

                t.Fields.Add(f);    // connect
            }
            AddToNotDefaultReferencedTypes(returnType);

            // call base to forward execution
            base.VisitFieldDeclaration(fieldDeclaration);
        }
开发者ID:goncalod,项目名称:csharp,代码行数:32,代码来源:NRefactoryVisitor.cs

示例7: AddFieldForLocal

 internal FieldDeclaration AddFieldForLocal(SimpleName localName, Expression initialValue, ISourceLocation sourceLocation) {
   FieldDeclaration field = new FieldDeclaration(null, FieldDeclaration.Flags.Static, TypeMemberVisibility.Private, 
     TypeExpression.For(initialValue.Type), new NameDeclaration(localName.Name, localName.SourceLocation), null, sourceLocation);
   field.SetContainingTypeDeclaration(this, false);
   this.members.Add(field);
   this.localFieldFor.Add(localName.Name.UniqueKeyIgnoringCase, field.FieldDefinition);
   return field;
 }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:8,代码来源:TypeDeclarations.cs

示例8: VisitFieldDeclaration

 public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
 {
     if (fieldDeclaration.HasModifier(Modifiers.Static))
     {
         this.CheckDependency(fieldDeclaration.ReturnType);
         base.VisitFieldDeclaration(fieldDeclaration);
     }
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:8,代码来源:DependencyFinderVisitor.cs

示例9: Verify

 public void Verify()
 {
     FieldDeclaration field = new FieldDeclaration("_customer", new CodeDomTypeReference(typeof(int)));
     Assert.AreEqual("_customer", field.Name);
     field.Initialize = true;
     CodeMemberField codefield = field.ToCodeDom();
     Assert.AreEqual("_customer", codefield.Name);
     Assert.AreEqual("System.Int32", codefield.Type.BaseType);
 }
开发者ID:chrcar01,项目名称:HyperActive,代码行数:9,代码来源:FieldDeclarationTests.cs

示例10: AddStandardMembers

 internal void AddStandardMembers(Compilation compilation, List<Statement> bodyOfMainRoutine) {
   NameDeclaration labelOfFirstStatement = new NameDeclaration(compilation.NameTable.GetNameFor("<<first statement>>"), SourceDummy.SourceLocation);
   FieldDeclaration labelField = new FieldDeclaration(null, 0, TypeMemberVisibility.Private,
     TypeExpression.For(compilation.PlatformType.SystemInt32.ResolvedType), labelOfFirstStatement, null, SourceDummy.SourceLocation);
   this.members.Add(labelField);
   this.AddMainMethod(compilation, bodyOfMainRoutine, labelField);
   this.AddEntryPointMethod(compilation);
   this.AddConstructor(compilation);
 }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:9,代码来源:TypeDeclarations.cs

示例11: VisitFieldDeclaration

            public override object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
            {
                if ((fieldDeclaration.Modifiers & Modifiers.Const) == Modifiers.Const)
                {
                    UnlockWith(fieldDeclaration);
                }

                return base.VisitFieldDeclaration(fieldDeclaration, data);
            }
开发者ID:jonasswiatek,项目名称:strokes,代码行数:9,代码来源:ConstKeywordAchievement.cs

示例12: FieldReferenceExpression

        public FieldReferenceExpression(Expression target,FieldDeclaration field)
        {
            if (target==null)
                throw new ArgumentNullException("target");
            if (field==null)
                throw new ArgumentNullException("field");

            this.target = target;
            this.declaringField = field;
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:FieldReferenceExpression.cs

示例13: AddMainMethod

 private void AddMainMethod(Compilation compilation, List<Statement> bodyOfMainRoutine, FieldDeclaration labelField) {
   MethodDeclaration mainMethod = new MethodDeclaration(null, 0, TypeMemberVisibility.Public,
     TypeExpression.For(compilation.PlatformType.SystemVoid.ResolvedType), null, new NameDeclaration(compilation.NameTable.GetNameFor("Main"), SourceDummy.SourceLocation), null, 
     null, null, new BlockStatement(bodyOfMainRoutine, this.SourceLocation), this.SourceLocation);
   bodyOfMainRoutine.Add(new SwitchStatement(new SimpleName(labelField.Name, SourceDummy.SourceLocation, false), this.cases, SourceDummy.SourceLocation));
   bodyOfMainRoutine.Add(new LabeledStatement(new NameDeclaration(labelField.Name, SourceDummy.SourceLocation), new EmptyStatement(false, SourceDummy.SourceLocation), SourceDummy.SourceLocation));
   this.AddLabel(new SimpleName(labelField.Name, SourceDummy.SourceLocation, false));
   this.members.Add(mainMethod);
   this.mainMethod = mainMethod;
 }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:10,代码来源:TypeDeclarations.cs

示例14: Create

        public static OverloadsCollection Create(IEmitter emitter, FieldDeclaration fieldDeclaration)
        {
            string key = fieldDeclaration.GetHashCode().ToString();
            if (emitter.OverloadsCache.ContainsKey(key))
            {
                return emitter.OverloadsCache[key];
            }

            return new OverloadsCollection(emitter, fieldDeclaration);
        }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:10,代码来源:OverloadsCollection.cs

示例15: GetFieldDeclaration

        protected FieldDeclaration GetFieldDeclaration(String name, AstType propertyType)
        {
            var declaration = new FieldDeclaration();
            declaration.Name = name;
            declaration.Modifiers = Modifiers.Public;
            declaration.ReturnType = propertyType;

            IDELogger.Log("BaseRefactoringDialog::GetFieldDeclaration -- {0}", declaration.Name);

            return declaration;
        }
开发者ID:Monobjc,项目名称:monobjc-monodevelop,代码行数:11,代码来源:BaseRefactoringDialog.cs


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