public string AddDCType(DCType dCType) { string empty = string.Empty; string str; if (!this.IsContains(dCType, this._DCTypes) && !this.IsContains(dCType, this._PreparedTypes)) { this._PreparedTypes.Add(dCType); List <DCField> fields = dCType.GetFields(); str = dCType.Name; if (dCType.ParentId != 0) { DCType dCType1 = new DCType(dCType.ParentId, dCType.IsSubentity); dCType.ParentName = this.AddDCType(dCType1); } this._DCTypes.Add(dCType); this._PreparedTypes.Remove(dCType); foreach (DCField dcField in fields) { if (!dcField.IsSimpleType) { if (dcField.DCType.IsSubentity) { this.AddDCChildren(dcField.DCType); } if (!this.IsContains(dcField.DCType, this._DCTypes)) { this.AddDCType(dcField.DCType); } } else if (dcField.IsEnum && !this.IsContains(dcField.DCType, this._DCTypes)) { dcField.DCType.GetFields(); this._DCTypes.Add(dcField.DCType); } } } else { str = this.GetDCName(dCType); } return(str); }
private void AddKnownTypeAttribute( DCType dCType, TypeBuilder typeBuilder, DCBuilderType dCBuilderType) { if (!dCType.IsSubentity || !(dCType.ParentName != "Subentity")) { return; } CustomAttributeBuilder customBuilder = new CustomAttributeBuilder(typeof(KnownTypeAttribute).GetConstructor(new Type[1] { typeof(Type) }), new object[1] { (object)typeBuilder.UnderlyingSystemType }); dCBuilderType.TypeBuilder.SetCustomAttribute(customBuilder); }
private void AddEnumeration(DCType dCType) { Type type1 = this.baseAssembly.GetType(this.nameSpacePrefix + "Enumeration`2"); EnumBuilder enumBuilder = this.DefineEnum(this.nameSpacePrefix + dCType.Name); bool isEmptyEnum = true; List <DCField> fields = dCType.GetFields(); Type type2 = typeof(string); foreach (DCField field in fields) { type2 = this.dCTypeStore.GetDCBuilderType(field.EnumFieldTypeName).Type.GetGenericArguments()[0]; int result; this.DefineLiteral(enumBuilder, field.Name, int.TryParse(field.DefaultValue, out result) ? result : field.Name.GetHashCode(), field.DefaultValue, field); isEmptyEnum = false; } Type type3 = enumBuilder.CreateType(); Type type4 = type1.MakeGenericType(type3, type2); this.dCTypeStore.Add(dCType.Name, type4, (TypeBuilder)null, true, isEmptyEnum); }
private bool IsContains(DCType dCType, List <DCType> types) { bool flag = false; if (dCType.ID != 0) { foreach (DCType type in types) { if (type.ID == dCType.ID) { flag = true; break; } } } else { flag = true; } return(flag); }
private void AddEnumeration(DCType dCType) { CDORequestor.CurrentRequestor.GetFields(dCType.ID); }
public virtual void AddDC(DCType dCType) { this.dCTypeStore.Add(dCType.Name, typeof(string), (TypeBuilder)null); }
public override void AddDC(DCType dCType) { bool isPrivate = this is ClientGenerator; if (dCType.IsEnum) { return; } DCBuilderType dcBuilderType1 = this.dCTypeStore.GetDCBuilderType(dCType.ParentName); DCBuilderType dcBuilderType2 = this.dCTypeStore.GetDCBuilderType(dCType.Name); DCBuilderType dcBuilderType3 = this.dCTypeStore.GetDCBuilderType(dCType.Name + "_Environment"); DCBuilderType dcBuilderType4 = this.dCTypeStore.GetDCBuilderType(dCType.Name + "_Info"); if (isPrivate) { this.BeginOverrideMethods(dcBuilderType2.TypeBuilder); } foreach (DCField field in dCType.GetFields()) { DCBuilderType dcBuilderType5 = this.dCTypeStore.GetDCBuilderType(field.TypeName); Type type = dcBuilderType5.Type; if (field.IsList) { type = dcBuilderType5.Type.MakeArrayType(); } FieldInfo fieldInfo = dcBuilderType1.Type.GetField((isPrivate ? "_" : "") + field.Name, (BindingFlags)(4 | (!isPrivate || this._IsSilverlight ? 16 : 32))); if (!field.IsSimpleType) { if (fieldInfo != (FieldInfo)null) { try { Type fieldType = fieldInfo.FieldType; } catch (TypeLoadException ex) { fieldInfo = (FieldInfo)null; } } } if (field.IsActual(fieldInfo == (FieldInfo)null ? string.Empty : (fieldInfo.FieldType.IsArray ? fieldInfo.FieldType.GetElementType().Name : fieldInfo.FieldType.Name))) { FieldBuilder fieldBuilder = this.DefineField(dcBuilderType2.TypeBuilder, field.Name, type, isPrivate); if (isPrivate) { this.AddFieldOverrideMethods(dcBuilderType2.TypeBuilder, fieldBuilder); } this.DefineField(dcBuilderType3.TypeBuilder, field.Name, this.GetEnvironmentType(dcBuilderType5), field, isPrivate); this.DefineField(dcBuilderType4.TypeBuilder, field.Name, this.GetInfoType(dcBuilderType5), isPrivate); if (isPrivate) { this.DefineProperty(dcBuilderType2.TypeBuilder, field.Name, type); this.DefineProperty(dcBuilderType3.TypeBuilder, field.Name, this.GetEnvironmentType(dcBuilderType5), field); this.DefineProperty(dcBuilderType4.TypeBuilder, field.Name, this.GetInfoType(dcBuilderType5)); } } } if (isPrivate) { this.EndOverrideMethods(dcBuilderType1.Type); } this.DefineTypeConstructor(dcBuilderType2.TypeBuilder, dcBuilderType1.Type); dcBuilderType2.TypeBuilder.CreateType(); dcBuilderType3.TypeBuilder.CreateType(); dcBuilderType4.TypeBuilder.CreateType(); }