private void button2_Click(object sender, EventArgs e) { List <string> res = new List <string>(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (bool.Parse(row.Cells[0].Value.ToString())) { res.Add(row.Cells[1].Value as string); } } Dictionary <string, GFieldInfo[]> gfiss = new Dictionary <string, GFieldInfo[]>(); foreach (var t in Wizard.Schema.AllTables) { if (res.Contains(t.Name)) { var Fields = new List <GFieldInfo>(); foreach (var c in t.Columns.Values) { var c_i = new GFieldInfo(); c_i.Name = c.Name; c_i.Type = c.Type.ToString(); c_i._db_type = c.DbType; Fields.Add(c_i); } gfiss.Add(t.Name, Fields.ToArray()); } } List <GeneralProperty> ths = new List <GeneralProperty>(); foreach (KeyValuePair <string, GFieldInfo[]> gfis in gfiss) { GeneralProperty gp = new GeneralProperty(); gp.Fields = new List <GFieldInfo>(gfis.Value); gp.OwnerFields = new List <OwnerFieldInfo>(); gp.TableName = gfis.Key; ths.Add(gp); } Wizard.Tables = ths.ToArray(); Wizard.NextStep(); }
private CodeTypeReference _addField(GFieldInfo fieldinfo, CodeTypeDeclaration model) { CodeMemberField field = new CodeMemberField(); field.Attributes = MemberAttributes.Private; field.Name = "__" + fieldinfo.Name; CodeMemberProperty property = new CodeMemberProperty(); property.Attributes = MemberAttributes.Public; property.Name = fieldinfo.DisplayName; if (fieldinfo.Type.StartsWith("gen:")) { if (fieldinfo.Type.Substring(4).StartsWith("enum")) { field.Type = property.Type = _getEnum(fieldinfo.Type, "_" + fieldinfo.Name, model); } } else { field.Type = property.Type = new CodeTypeReference(Type.GetType(fieldinfo.Type)); } property.CustomAttributes.Add( new CodeAttributeDeclaration("DataField", new CodeAttributeArgument( new CodePrimitiveExpression(fieldinfo.Name) ), new CodeAttributeArgument( new CodeFieldReferenceExpression( new CodeTypeReferenceExpression("SerializeType"), fieldinfo.SerializeType.ToString() ) ) ) ); if (fieldinfo.IsIndexField) { property.CustomAttributes.Add( new CodeAttributeDeclaration("IndexField") ); } if (fieldinfo.DefaultValue != null) { property.CustomAttributes.Add( new CodeAttributeDeclaration("DefaultValue", new CodeAttributeArgument( new CodePrimitiveExpression(fieldinfo.DefaultValue) ) ) ); } property.HasGet = true; property.GetStatements.Add(new CodeMethodReturnStatement( new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), field.Name ) )); property.HasSet = true; property.SetStatements.Add(new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "SetValue", new CodePrimitiveExpression(fieldinfo.Name), new CodePropertySetValueReferenceExpression() )); model.Members.Add(field); model.Members.Add(property); return(property.Type); }