public TypeDefinition Generate() { _startIndex = _model.Properties.Count; foreach (var property in _composedOfType.Properties) { var name = "$" + _instanceName + "$" + property.Name; var dbn = _instanceName + property.Name; var pd = TypeFactory.CreateProperty(name, PropAttr, property.PropertyType, _handler); foreach (var attribute in property.CustomAttributes) { pd.CustomAttributes.Add(attribute); } if (pd.GetCustomAttribute(KnownTypesHandler.DbColumnAttribute) == null) { pd.CustomAttributes.Add(_handler.GetDbColumn(dbn)); } _model.Properties.Add(pd); _model.Methods.Add(pd.GetMethod); _model.Methods.Add(pd.SetMethod); var pi = new PropertyInformation { PropertyDefinition = pd, FieldType = FieldType.Normal }; var pp = new PropertyProcessor(pi, _model, _handler); pp.Process(); } GenerateClass(); return(_result); }
private void ProcessProperty(PropertyInformation pi) { var pp = new PropertyProcessor(pi, _model, _handler); pp.Process(); if (pi.IsComposedOf) { ProcessComposedOfAttribute(pi); } }
private void ProcessSpecialForeignKey(PropertyInformation property) { // process set var processor = PropertyProcessor.PreProcessPropertyMethod(property.PropertyDefinition.SetMethod); PropertyProcessor.ProcessPropertySetElse(processor); // remove field _model.Fields.Remove(property.FieldDefinition); // process get var name = property.PropertyDefinition.Name; name = name.Substring(0, name.Length - 2); var pi = FindProperty(name); processor = PropertyProcessor.PreProcessPropertyMethod(property.PropertyDefinition.GetMethod); processor.LoadArg(0); processor.LoadField(pi.FieldDefinition); processor.CallVirtual(_handler.BelongsToInterfaceGetForeignKey); processor.CastOrUnbox(property.PropertyDefinition.PropertyType, _handler); processor.Return(); processor.Append(); // add exclude property.PropertyDefinition.CustomAttributes.Add(_handler.GetExclude()); }