public static void RegisterStruct(Type structType) { ExTraceGlobals.OehCallTracer.TraceDebug(0L, "OwaEventRegistry.RegisterStruct"); if (structType == null) { throw new ArgumentNullException("structType"); } object[] customAttributes = structType.GetCustomAttributes(typeof(OwaEventStructAttribute), false); if (customAttributes == null || customAttributes.Length == 0) { throw new OwaNotSupportedException("Struct type is missing the OwaEventStructAttribute attribute"); } OwaEventStructAttribute owaEventStructAttribute = (OwaEventStructAttribute)customAttributes[0]; owaEventStructAttribute.StructType = structType; ExTraceGlobals.OehDataTracer.TraceDebug <Type>(0L, "Struct type: '{0}'", structType); Type type = null; customAttributes = structType.GetCustomAttributes(typeof(OwaEventObjectIdAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { type = ((OwaEventObjectIdAttribute)customAttributes[0]).ObjectIdType; } FieldInfo[] fields = structType.GetFields(BindingFlags.Instance | BindingFlags.Public); int num = 0; uint num2 = 0U; foreach (FieldInfo fieldInfo in fields) { customAttributes = fieldInfo.GetCustomAttributes(typeof(OwaEventFieldAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { OwaEventFieldAttribute owaEventFieldAttribute = (OwaEventFieldAttribute)customAttributes[0]; owaEventFieldAttribute.FieldInfo = fieldInfo; owaEventFieldAttribute.FieldType = fieldInfo.FieldType; if (type != null && owaEventFieldAttribute.FieldType == typeof(ObjectId)) { owaEventFieldAttribute.FieldType = type; } if (!OwaEventRegistry.IsAllowedFieldType(owaEventFieldAttribute.FieldType)) { throw new OwaNotSupportedException("Field type is not supported."); } owaEventFieldAttribute.FieldMask = 1U << num; owaEventStructAttribute.AllFieldsMask |= owaEventFieldAttribute.FieldMask; if (!owaEventFieldAttribute.IsOptional) { num2 |= owaEventFieldAttribute.FieldMask; } else if (fieldInfo.FieldType == typeof(ExDateTime)) { owaEventFieldAttribute.DefaultValue = ExDateTime.MinValue; } if (num >= 32) { throw new OwaNotSupportedException("Struct declares more fields than allowed"); } owaEventStructAttribute.AddFieldInfo(owaEventFieldAttribute, num); num++; ExTraceGlobals.OehDataTracer.TraceDebug <string, Type>(0L, "Struct field found, name: '{0}', type: '{1}'", owaEventStructAttribute.Name, owaEventFieldAttribute.FieldType); } } if (num == 0) { throw new OwaNotSupportedException("Struct must have at least one field"); } owaEventStructAttribute.FieldCount = num; owaEventStructAttribute.RequiredMask = num2; OwaEventRegistry.structTable.Add(owaEventStructAttribute.Name, owaEventStructAttribute); OwaEventRegistry.structTypeTable.Add(owaEventStructAttribute.StructType, owaEventStructAttribute); }