public UniqueTableGenerator(string xmlDir, string table) { generateFor = CaFieldInfo.ReadInfo(xmlDir, table, out guid); xmlDirectory = xmlDir; tableName = table; IValueGenerator intGenerator = new IntGenerator(); generators.Add("integer", intGenerator); generators.Add("longinteger", intGenerator); generators.Add("autonumber", intGenerator); generators.Add("decimal", intGenerator); IValueGenerator floatGenerator = new FloatGenerator(); generators.Add("single", floatGenerator); generators.Add("double", floatGenerator); IValueGenerator textGenerator = new TextGenerator(); generators.Add("text", textGenerator); generators.Add("memo", textGenerator); IValueGenerator boolGenerator = new BoolGenerator(); generators.Add("yesno", boolGenerator); }
public static List <CaFieldInfo> ReadInfo(string xmlDirectory, string tableName, out string guid) { guid = "unknown"; List <CaFieldInfo> result = new List <CaFieldInfo>(); try { string filename = Path.Combine(xmlDirectory, string.Format("TWaD_{0}.xml", tableName)); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); foreach (XmlNode node in xmlDoc.ChildNodes) { if (node.Name.Equals("root")) { foreach (XmlNode fieldNode in node.ChildNodes) { if (fieldNode.Name.Equals("edit_uuid")) { guid = fieldNode.InnerText; } if (!fieldNode.Name.Equals("field")) { continue; } string name = null, type = null; string refTable = null, refField = null; foreach (XmlNode itemNode in fieldNode.ChildNodes) { if (itemNode.Name.Equals("name")) { name = itemNode.InnerText; } else if (itemNode.Name.Equals("field_type")) { type = itemNode.InnerText; } else if (itemNode.Name.Equals("column_source_table")) { refTable = itemNode.InnerText; } else if (itemNode.Name.Equals("column_source_column")) { refField = itemNode.InnerText; } } CaFieldInfo info = new CaFieldInfo(name, type); if (refTable != null && refField != null) { info.Reference = new FieldReference(refTable, refField); } result.Add(info); } } } } catch { } return(result); }
public static CaFieldInfo FindInList(List <CaFieldInfo> list, string name) { CaFieldInfo result = null; foreach (CaFieldInfo info in list) { if (info.Name.Equals(name)) { result = info; break; } } return(result); }