本文整理汇总了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);
}
}
示例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);
}
示例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);
}
示例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 });
}
}