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


C# FieldInfo.Set方法代码示例

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


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

示例1: ReadFixedArrayField

 static void ReadFixedArrayField(BinaryReader binaryReader, object item, FieldInfo field)
 {
     var marhsalAsAttribute = field.Attribute<MarshalAsAttribute>();
     var elementType = field.FieldType.GetElementType();
     if (marhsalAsAttribute.Value == UnmanagedType.ByValArray)
     {
         var count = marhsalAsAttribute.SizeConst;
         var array = Array.CreateInstance(elementType, count);
         if (elementType == typeof(byte))
         {
             array = binaryReader.ReadBytes(count);
         }
         else
         {
             for (int i = 0; i < count; ++i)
             {
                 var element = ReadField(binaryReader, elementType);
                 ArrayExtensions.SetElement(array, i, element);
             }
         }
         field.Set(item, array);
     }
 }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:23,代码来源:Deserializer.cs

示例2: DefaultProcessTagBlockArray

        private static void DefaultProcessTagBlockArray(BinaryReader sourceReader, object item, FieldInfo field)
        {
            Type elementType = field.FieldType.GetElementType();
            int elementSize = SizeOf(elementType);

            var count = sourceReader.ReadInt32();
            var address = sourceReader.ReadInt32();

            sourceReader.BaseStream.Position = address;

            var array = Deserializer.DeserializeArray(sourceReader, elementType, elementSize, count);
            field.Set(item, array);
        }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:13,代码来源:Deserializer.cs

示例3: ProcessFixedStructArray

        private static void ProcessFixedStructArray(BinaryReader sourceReader, object item, FieldInfo field)
        {
            Type elementType = field.FieldType.GetElementType();
            int elementSize = SizeOf(elementType);

            var marhsalAsAttribute = field.Attribute<MarshalAsAttribute>();
            var count = marhsalAsAttribute.SizeConst;

            var array = Deserializer.DeserializeArray(sourceReader, elementType, elementSize, count);
            field.Set(item, array);
        }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:11,代码来源:Deserializer.cs

示例4: ReadSectionData

        public void ReadSectionData(BinaryReader sourceReader, Object item, FieldInfo field)
        {
            var originalDelegate = Deserializer.ProcessTagBlockArray.Clone();
            Deserializer.ProcessTagBlockArray = new Deserializer.ProcessTagBlockArrayDelegate(CustomProcessTagBlockArray);

            if (!geometryBlockInfo.IsInternal)
            {
                Stream resourceStream;
                if (Halo2.TryGettingResourceStream(geometryBlockInfo.blockOffset + 8, out resourceStream))
                {
                    resourceStream.Position = geometryBlockInfo.BlockAddress + 8;
                    var readerResource = new BinaryReader(resourceStream);
                    var returnValue = Deserializer.Deserialize(readerResource, typeof(RenderModelSectionDataBlock));

                    Deserializer.PreprocessField = null;
                    Deserializer.ProcessTagBlockArray = (Deserializer.ProcessTagBlockArrayDelegate)originalDelegate;
                    field.Set(item, new RenderModelSectionDataBlock[] { returnValue });
                }
                else
                {
                    Deserializer.PreprocessField = null;
                    Deserializer.ProcessTagBlockArray = (Deserializer.ProcessTagBlockArrayDelegate)originalDelegate;
                    field.Set(item, new RenderModelSectionDataBlock[0]);
                }
            }
            else
            {
                sourceReader.BaseStream.Position = geometryBlockInfo.BlockAddress + 8;
                var returnValue = Deserializer.Deserialize(sourceReader, typeof(RenderModelSectionDataBlock));

                Deserializer.PreprocessField = null;
                Deserializer.ProcessTagBlockArray = (Deserializer.ProcessTagBlockArrayDelegate)originalDelegate;
                field.Set(item, new RenderModelSectionDataBlock[] { returnValue });
            }
        }
开发者ID:jacksoncougar,项目名称:Moonfish-Editor,代码行数:35,代码来源:RenderModel.Code.cs


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