Guest User

Untitled

a guest
Apr 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. const TypeAttributes typeAttributes = TypeAttributes.Public |
  2. TypeAttributes.SequentialLayout |
  3. TypeAttributes.UnicodeClass;
  4. var typeBuilder = moduleBuilder.DefineType("MyType", typeAttributes, typeof(ValueType));
  5.  
  6. ConstructorInfo structLayoutAttributeConstructorInfo = typeof(StructLayoutAttribute).GetConstructor(new[] { typeof(LayoutKind) });
  7.  
  8. FieldInfo charSetFieldInfo = typeof(StructLayoutAttribute).GetField(nameof(StructLayoutAttribute.CharSet));
  9. CustomAttributeBuilder attr = new CustomAttributeBuilder(structLayoutAttributeConstructorInfo,
  10. new object[] { LayoutKind.Sequential },
  11. new FieldInfo[] { charSetFieldInfo },
  12. new object[] { CharSet.Unicode });
  13. typeBuilder.SetCustomAttribute(structLayoutAttributeBuilder);
  14.  
  15. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
Add Comment
Please, Sign In to add comment