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


C# FieldDefinition类代码示例

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


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

示例1: Rewrite

    public override List<IFieldDefinition> Rewrite(List<IFieldDefinition> fields) {
      if (fields != null) {
        var addedFields = new List<IFieldDefinition>();
        foreach (var field in fields) {
          if (field.IsStatic == false && field.ContainingType.IsEnum == false) {
            // private long fieldname$$storeCount; 
            var storeField = new FieldDefinition() {
              Name = this.host.NameTable.GetNameFor(MemberHelper.GetMemberSignature(field, NameFormattingOptions.None) + "$$storeCount"),
              Type = this.host.PlatformType.SystemInt64,
              InternFactory = base.host.InternFactory,
              ContainingTypeDefinition = field.ContainingTypeDefinition,
              Visibility = field.Visibility,
              IsStatic = false
            };

            var loadField = new FieldDefinition() {
              Name = this.host.NameTable.GetNameFor(MemberHelper.GetMemberSignature(field, NameFormattingOptions.None) + "$$loadCount"),
              Type = this.host.PlatformType.SystemInt64,
              InternFactory = base.host.InternFactory,
              ContainingTypeDefinition = field.ContainingTypeDefinition,
              Visibility = field.Visibility,
              IsStatic = false
            };

            addedFields.Add(storeField);
            addedFields.Add(loadField);
            Console.WriteLine("Added shadow field to : " + MemberHelper.GetMemberSignature(field, NameFormattingOptions.None));
          }
        }

        foreach (var field in addedFields) fields.Add(field);
      }
      return fields;
    }
开发者ID:modulexcite,项目名称:Microsoft.Cci.Metadata,代码行数:34,代码来源:ZombieFieldInstrumentor.cs

示例2: InjectField

	void InjectField(TypeDefinition type, FieldDefinition fieldDefinition)
	{
		var staticConstructor = type.GetStaticConstructor();
		var instructions = staticConstructor.Body.Instructions;

	    if (type.HasGenericParameters)
	    {
	        instructions.Insert(0, Instruction.Create(OpCodes.Call, buildLoggerGenericMethod));
	        instructions.Insert(1, Instruction.Create(OpCodes.Stsfld, fieldDefinition.GetGeneric()));
	    }
	    else
	    {
	        var logName = type.FullName;
	        if (type.IsCompilerGenerated() && type.IsNested)
	        {
	            logName = type.DeclaringType.FullName;
	        }

	        instructions.Insert(0, Instruction.Create(OpCodes.Ldstr, logName));
	        instructions.Insert(1, Instruction.Create(OpCodes.Call, buildLoggerMethod));
	        instructions.Insert(2, Instruction.Create(OpCodes.Stsfld, fieldDefinition));
	    }

	    type.Fields.Add(fieldDefinition);
	}
开发者ID:vlaci,项目名称:Anotar,代码行数:25,代码来源:TypeProcessor.cs

示例3: ProcessField

    void ProcessField(TypeNode node, FieldDefinition field)
    {
        var name = field.Name;
        if (!field.IsPublic || field.IsStatic || !char.IsUpper(name, 0))
        {
            return;
        }
        if (node.TypeDefinition.HasGenericParameters)
        {
            var message = string.Format("Skipped converting public field '{0}.{1}' to a property because generic types are not currently supported. You should make this a public property instead.", node.TypeDefinition.Name, field.Name);
            logger.LogWarning(message);
            return;
        }
        field.Name = string.Format("<{0}>k__BackingField", name);
        field.IsPublic = false;
        field.IsPrivate = true;
        var get = GetGet(field, name);
        node.TypeDefinition.Methods.Add(get);

        var set = GetSet(field, name);
        node.TypeDefinition.Methods.Add(set);

        var propertyDefinition = new PropertyDefinition(name, PropertyAttributes.None, field.FieldType)
                                     {
                                         GetMethod = get,
                                         SetMethod = set
                                     };
        foreach (var customAttribute in field.CustomAttributes)
        {
            propertyDefinition.CustomAttributes.Add(customAttribute);
        }
        node.TypeDefinition.Properties.Add(propertyDefinition);
        ForwardedFields.Add(field, propertyDefinition);
    }
开发者ID:marcuswhit,项目名称:NotifyPropertyWeaver,代码行数:34,代码来源:FieldToPropertyConverter.cs

示例4: CreateFields

 void CreateFields(TypeDefinition targetTypeDefinition)
 {
     TargetField = new FieldDefinition("target", FieldAttributes.Public, targetTypeDefinition);
     TypeDefinition.Fields.Add(TargetField);
     PropertyNameField = new FieldDefinition("propertyName", FieldAttributes.Public, ModuleWeaver.ModuleDefinition.TypeSystem.String);
     TypeDefinition.Fields.Add(PropertyNameField);
 }
开发者ID:dj-pgs,项目名称:PropertyChanged,代码行数:7,代码来源:DelegateHolderInjector.cs

示例5: Read

 public void Read(ClrModuleReader reader)
 {
     this.FieldDefinition = new FieldDefinition();
     this.FieldDefinition.Attributes = (FieldAttributes)reader.Binary.ReadUInt16();
     this.FieldDefinition.Name = reader.ReadString();
     this.Signature = reader.ReadFieldSignature();
 }
开发者ID:BGCX261,项目名称:zoompe-git,代码行数:7,代码来源:FieldEntry.cs

示例6: GetQuotedColumnName

 public static string GetQuotedColumnName(this IOrmLiteDialectProvider dialect,
     ModelDefinition modelDef, FieldDefinition fieldDef)
 {
     return dialect.GetQuotedTableName(modelDef.ModelName) +
         "." +
         dialect.GetQuotedColumnName(fieldDef.FieldName);
 }
开发者ID:JackFong,项目名称:ServiceStack.OrmLite,代码行数:7,代码来源:OrmLiteDialectProviderExtensions.cs

示例7: ProcessField

 void ProcessField(FieldDefinition field)
 {
     if (IsCompilerGenerated(field.CustomAttributes))
     {
         return;
     }
     if (field.IsPublic)
     {
         return;
     }
     var requiresPublicize = false;
     if (field.IsAssembly)
     {
         field.IsAssembly = false;
         requiresPublicize = true;
     }
     if (field.IsPrivate)
     {
         field.IsPrivate = false;
         requiresPublicize = true;
     }
     if (requiresPublicize)
     {
         field.IsPublic = true;
         AddEditorBrowsableAttribute(field.CustomAttributes);
     }
 }
开发者ID:mdabbagh88,项目名称:Publicize,代码行数:27,代码来源:TypeProcessor.cs

示例8: FromDbValue

        //Also support coercing 0 != int as Bool
        public override object FromDbValue(FieldDefinition fieldDef, object value)
        {
            if (value is bool)
                return value;

            return 0 != (long)this.ConvertNumber(typeof(long), value);
        }
开发者ID:gaoninggn,项目名称:ServiceStack.OrmLite,代码行数:8,代码来源:BoolConverter.cs

示例9: FileField_IsNotSearchable

        public void FileField_IsNotSearchable()
        {
            // VRN-1679 - file fields should not be searchable.
            var field = new FieldDefinition("Test", ColumnTypes.File, null, string.Empty);

            Assert.IsFalse(field.IsSearchable);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:7,代码来源:FieldDefinitionTests.cs

示例10: Execute

    public void Execute()
    {
        LogInfo("enter execute");
        var configurableTypes = ModuleDefinition.Types.Where(t => t.CustomAttributes
                            .Any(c => c.AttributeType.Name == typeof(ConfigurableAttribute).Name));

        foreach(var type in configurableTypes)
        {
            if (type.IsSealed && type.IsAbstract)
            {
                LogInfo(string.Format("Type {0} is static and cannot be configurable. Skipping type", type));
                continue;
            }

            var isConfiguredField = new FieldDefinition("<>__isConfigured",
                                                        Mono.Cecil.FieldAttributes.Private,
                                                        ModuleDefinition.TypeSystem.Boolean);
            type.Fields.Add(isConfiguredField);
            var ensureConfigurationMethod = GenerateEnsureConfigurationMethod(isConfiguredField, type);
            type.Methods.Add(ensureConfigurationMethod);

            foreach (var ctor in type.GetConstructors().Where(ctor => !ctor.IsStatic))
            {
                var baseCtorCall = ctor.Body.Instructions.Single(i => IsCallToCtor(i));
                var baseCtorCallIndex = ctor.Body.Instructions.IndexOf(baseCtorCall);

                ctor.Body.Instructions.Insert(baseCtorCallIndex + 1, Instruction.Create(OpCodes.Ldarg_0));
                ctor.Body.Instructions.Insert(baseCtorCallIndex + 2, Instruction.Create(OpCodes.Callvirt, ensureConfigurationMethod));
            }
        }
    }
开发者ID:jorgehmv,项目名称:FodySpring,代码行数:31,代码来源:ModuleWeaver.cs

示例11: QueryResultsTotalizerModel

        public QueryResultsTotalizerModel(IVisualStudioAdapter visualStudioAdapter)
        {
            this.visualStudioAdapter = visualStudioAdapter;

            CurrentWorkItems = new WorkItem[0];
            NumericFieldDefinitions = new FieldDefinition[0];
        }
开发者ID:cqse,项目名称:ScrumPowerTools,代码行数:7,代码来源:QueryResultsTotalizerModel.cs

示例12: InjectAsStreamReader

    void InjectAsStreamReader(TypeDefinition targetType, FieldDefinition fieldDefinition)
    {
        AsStreamReaderMethod = new MethodDefinition("AsStreamReader", staticMethodAttributes, StreamReaderTypeReference);
        var streamVariable = new VariableDefinition(StreamTypeReference);
        AsStreamReaderMethod.Body.Variables.Add(streamVariable);
        var pathParam = new ParameterDefinition(ModuleDefinition.TypeSystem.String);
        AsStreamReaderMethod.Parameters.Add(pathParam);
        AsStreamReaderMethod.Body.InitLocals = true;
        var inst = AsStreamReaderMethod.Body.Instructions;

        var skipReturn = Instruction.Create(OpCodes.Nop);

        inst.Add(Instruction.Create(OpCodes.Ldsfld, fieldDefinition));
        inst.Add(Instruction.Create(OpCodes.Ldarg, pathParam));
        inst.Add(Instruction.Create(OpCodes.Callvirt, GetManifestResourceStreamMethod));

        inst.Add(Instruction.Create(OpCodes.Stloc, streamVariable));
        inst.Add(Instruction.Create(OpCodes.Ldloc, streamVariable));
        inst.Add(Instruction.Create(OpCodes.Brtrue_S, skipReturn));

        inst.Add(Instruction.Create(OpCodes.Ldnull));
        inst.Add(Instruction.Create(OpCodes.Ret));
        inst.Add(skipReturn);

        inst.Add(Instruction.Create(OpCodes.Ldloc, streamVariable));
        inst.Add(Instruction.Create(OpCodes.Newobj, StreamReaderConstructorReference));
        inst.Add(Instruction.Create(OpCodes.Ret));
        targetType.Methods.Add(AsStreamReaderMethod);
    }
开发者ID:huoxudong125,项目名称:Resourcer,代码行数:29,代码来源:HelperClassInjector.cs

示例13: CreateArrayField

        public void CreateArrayField()
        {
            // set up temp assembly.
            var assembly = Utilities.CreateTempNetAssembly();
            var typeSystem = assembly.NetDirectory.MetadataHeader.TypeSystem;
            var tableStream = assembly.NetDirectory.MetadataHeader.GetStream<TableStream>();
            var fieldTable = tableStream.GetTable<FieldDefinition>();
            var importer = new ReferenceImporter(tableStream);

            // create field.
            var arraySignature = new ArrayTypeSignature(typeSystem.Int32);
            arraySignature.Dimensions.Add(new ArrayDimension(2, 1));
            arraySignature.Dimensions.Add(new ArrayDimension(2));
            arraySignature.Dimensions.Add(new ArrayDimension());

            var field = new FieldDefinition(FieldName, FieldAttributes.Public | FieldAttributes.Static,
                new FieldSignature(importer.ImportTypeSignature(arraySignature)));
            fieldTable.Add(field);

            // build and validate.
            assembly = Utilities.RebuildNetAssembly(assembly);
            fieldTable = assembly.NetDirectory.MetadataHeader.GetStream<TableStream>().GetTable<FieldDefinition>();
            field = fieldTable.First(x => x.Name == FieldName);

            Assert.IsInstanceOfType(field.Signature.FieldType, typeof(ArrayTypeSignature));
            Utilities.ValidateType(arraySignature, field.Signature.FieldType);
        }
开发者ID:JerreS,项目名称:AsmResolver,代码行数:27,代码来源:TypeSignatureTests.cs

示例14: CreateFields

 void CreateFields(TypeDefinition targetTypeDefinition)
 {
     Target = new FieldDefinition("target", FieldAttributes.Public, targetTypeDefinition);
     TypeDefinition.Fields.Add(Target);
     PropertyName = new FieldDefinition("propertyName", FieldAttributes.Public, msCoreReferenceFinder.StringTypeReference);
     TypeDefinition.Fields.Add(PropertyName);
 }
开发者ID:dsplaisted,项目名称:NotifyPropertyWeaver,代码行数:7,代码来源:DelegateHolderInjector.cs

示例15: CustomFields_IsSearchable

        public void CustomFields_IsSearchable()
        {
            var fieldName = new FieldDefinition("Full Name", ColumnTypes.String, null, null);
            var fieldDate = new FieldDefinition("Date field", ColumnTypes.DateTime, null, null);

            Assert.IsTrue(fieldName.IsSearchable);
            Assert.IsTrue(fieldDate.IsSearchable);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:8,代码来源:FieldDefinitionTests.cs


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