31 {
32 if (con == null)
33 {
34 throw new ArgumentNullException("con");
35 }
36 if (constructorArgs == null)
37 {
38 throw new ArgumentNullException("constructorArgs");
39 }
40 if (namedProperties == null)
41 {
42 throw new ArgumentNullException("namedProperties");
43 }
44 if (propertyValues == null)
45 {
46 throw new ArgumentNullException("propertyValues");
47 }
48 if (namedFields == null)
49 {
50 throw new ArgumentNullException("namedFields");
51 }
52 if (fieldValues == null)
53 {
54 throw new ArgumentNullException("fieldValues");
55 }
56 if (namedProperties.Length != propertyValues.Length)
57 {
58 throw new ArgumentException(SR.Arg_ArrayLengthsDiffer,
"namedProperties, propertyValues");
59 }
60 if (namedFields.Length != fieldValues.Length)
61 {
62 throw new ArgumentException(SR.Arg_ArrayLengthsDiffer,
"namedFields, fieldValues");
63 }
64 if ((con.Attributes & MethodAttributes.Static) == MethodAttributes.Static || (con.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private)
65 {
67 }
68 if ((con.CallingConvention & CallingConventions.Standard) != CallingConventions.Standard)
69 {
71 }
75 Type[] parameterTypes = con.GetParameterTypes();
76 if (parameterTypes.Length != constructorArgs.Length)
77 {
79 }
80 for (
int i = 0;
i < parameterTypes.Length;
i++)
81 {
83 {
85 }
86 }
87 for (
int i = 0;
i < parameterTypes.Length;
i++)
88 {
89 object obj = constructorArgs[
i];
91 {
92 if (parameterTypes[i].IsValueType)
93 {
94 throw new ArgumentNullException($"{"constructorArgs"}[{i}]");
95 }
96 }
97 else
98 {
100 }
101 }
104 binaryWriter.
Write((ushort)1);
105 for (
int i = 0;
i < constructorArgs.Length;
i++)
106 {
107 EmitValue(binaryWriter, parameterTypes[i], constructorArgs[i]);
108 }
109 binaryWriter.
Write((ushort)(namedProperties.Length + namedFields.Length));
110 for (
int i = 0;
i < namedProperties.Length;
i++)
111 {
112 PropertyInfo propertyInfo = namedProperties[
i];
113 if (propertyInfo == null)
114 {
115 throw new ArgumentNullException("namedProperties[" + i + "]");
116 }
117 Type propertyType = propertyInfo.PropertyType;
118 object obj2 = propertyValues[
i];
119 if (obj2 == null && propertyType.IsValueType)
120 {
121 throw new ArgumentNullException("propertyValues[" + i + "]");
122 }
124 {
126 }
127 if (!propertyInfo.CanWrite)
128 {
130 }
131 if (propertyInfo.DeclaringType != con.DeclaringType && !(con.DeclaringType is TypeBuilderInstantiation) && !con.DeclaringType.IsSubclassOf(propertyInfo.DeclaringType) && !TypeBuilder.IsTypeEqual(propertyInfo.DeclaringType, con.DeclaringType) && (!(propertyInfo.DeclaringType is TypeBuilder) || !con.DeclaringType.IsSubclassOf(((TypeBuilder)propertyInfo.DeclaringType).BakedRuntimeType)))
132 {
134 }
135 if (obj2 != null)
136 {
138 }
139 binaryWriter.
Write((
byte)84);
140 EmitType(binaryWriter, propertyType);
142 EmitValue(binaryWriter, propertyType, obj2);
143 }
144 for (
int i = 0;
i < namedFields.Length;
i++)
145 {
146 FieldInfo fieldInfo = namedFields[
i];
147 if (fieldInfo == null)
148 {
149 throw new ArgumentNullException("namedFields[" + i + "]");
150 }
151 Type fieldType = fieldInfo.FieldType;
152 object obj3 = fieldValues[
i];
153 if (obj3 == null && fieldType.IsValueType)
154 {
155 throw new ArgumentNullException("fieldValues[" + i + "]");
156 }
158 {
160 }
161 if (fieldInfo.DeclaringType != con.DeclaringType && !(con.DeclaringType is TypeBuilderInstantiation) && !con.DeclaringType.IsSubclassOf(fieldInfo.DeclaringType) && !TypeBuilder.IsTypeEqual(fieldInfo.DeclaringType, con.DeclaringType) && (!(fieldInfo.DeclaringType is TypeBuilder) || !con.DeclaringType.IsSubclassOf(((TypeBuilder)namedFields[i].DeclaringType).BakedRuntimeType)))
162 {
164 }
165 if (obj3 != null)
166 {
168 }
169 binaryWriter.
Write((
byte)83);
172 EmitValue(binaryWriter, fieldType, obj3);
173 }
175 }
virtual Stream BaseStream
virtual void Write(bool value)
static void EmitType(BinaryWriter writer, Type type)
object[] m_constructorArgs
static void EmitString(BinaryWriter writer, string str)
static void EmitValue(BinaryWriter writer, Type type, object value)
static void VerifyTypeAndPassedObjectType(Type type, Type passedType, string paramName)
bool ValidateType(Type t)