public void Generate(ModuleDefinition module) { foreach (var member in _info.Members) { var key = member.MemberInfo.Name; var type = TypeFactory.CreateType(_model, _handler.ObjectType, key); type.Interfaces.Add(_handler.MemberHandlerInterface); try { if (member.MemberInfo.IsProperty) { _properties[key].CustomAttributes.Add(_handler.GetModelHandler(type)); } else { _fields[key].CustomAttributes.Add(_handler.GetModelHandler(type)); } } catch (Exception ex) { throw new ApplicationException(ex.Message + ":" + key); } GenerateConstructor(type); var mt = _handler.Import(member.MemberInfo.MemberType); GenerateSetValue(type, member, mt); GenerateGetValue(type, member, mt); module.Types.Add(type); } }
public ModelHandlerGenerator(Type type, TypeDefinition model, KnownTypesHandler handler) { this._model = model; this._handler = handler; _result = TypeFactory.CreateType(model, _handler.ModelHandlerBaseType); _result.Interfaces.Add(_handler.DbObjectHandlerInterface); _model.CustomAttributes.Add(_handler.GetModelHandler(_result)); _info = ObjectInfoFactory.Instance.GetInstance(type); CheckType(type); }