Пример #1
0
        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);
        }
Пример #2
0
 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);
     }
 }
Пример #3
0
 public override T GetAttribute <T>(bool inherit)
 {
     return(fi.Attribute <T>());
     //return ClassHelper.GetAttribute<T>(fi, inherit);
 }