private void DefineStructuralType(ModuleBuilder module, DynamicStructuralType typeInfo) { var typeAttributes = TypeAttributes.Class | GetTypeAccess(typeInfo.TypeAccess); if (typeInfo.IsAbstract) { typeAttributes |= TypeAttributes.Abstract; } if (typeInfo.IsSealed) { typeAttributes |= TypeAttributes.Sealed; } Type baseClass = null; if (typeInfo.BaseClass is Type) { baseClass = typeInfo.BaseClass as Type; } else if (typeInfo.BaseClass is DynamicStructuralType) { baseClass = _typeBuilders[((DynamicStructuralType)typeInfo.BaseClass).Name].Item1; } var typeBuilder = module.DefineType(typeInfo.Name, typeAttributes, baseClass); foreach (var a in typeInfo.Attributes) { typeBuilder.SetCustomAttribute(AnnotationAttributeBuilder.Create(a)); } // Define the Ctor var constructorBuilder = typeInfo.CtorAccess == MemberAccess.None ? null : typeBuilder.DefineDefaultConstructor(GetMethodAttributes(false, typeInfo.CtorAccess)); _typeBuilders.Add(typeInfo.Name, Tuple.Create(typeBuilder, constructorBuilder)); }
public DynamicField HasType(DynamicStructuralType propertyType) { FieldType = propertyType; return(this); }
public DynamicProperty HasCollectionType(Type collectionType, DynamicStructuralType referenceType) { CollectionType = collectionType; ReferenceType = referenceType; return(this); }
public DynamicProperty HasReferenceType(DynamicStructuralType referenceType) { ReferenceType = referenceType; return(this); }