static public void readFile(string filename, Hashtable collection) { if (File.Exists(filename)) { using (StreamReader reader = new StreamReader(filename)) { string line = reader.ReadLine(); while (line != null) { FieldDictionaryBase d = new FieldDictionaryBase(); string[] values = line.Split(';'); d.TableName = values[0]; d.FieldName = values[1]; d.TypeName = values[2]; d.ArraySize = Int32.Parse(values[3]); // d.Type = values[4]; if (!collection.ContainsKey(d.Key)) { collection.Add(d.Key, d); } line = reader.ReadLine(); } } } }
private void init(string path) { types = new Hashtable(); enums = new Hashtable(); fields = new Hashtable(); TypeDictionaryBase.readFile("..\\..\\Dictionary\\types.txt", types); EnumDictionaryBase.readFile("..\\..\\Dictionary\\enums.txt", enums); TypeDictionaryBase.readFile("Dictionary\\types.txt", types); EnumDictionaryBase.readFile("Dictionary\\enums.txt", enums); FieldDictionaryBase.readFile("Dictionary\\fields.txt", fields); TypeDictionaryBase.readFolder(path + "\\Data Dictionary\\Extended Data Types", types); EnumDictionaryBase.readFolder(path + "\\Data Dictionary\\Base Enums", enums); FieldDictionaryBase.readFolder(path + "\\Data Dictionary\\Tables", fields); }
public static void readFolder(string path, Hashtable collection) { if (Directory.Exists(path)) { string[] files = System.IO.Directory.GetFiles(path, "*.xpo"); foreach (string file in files) { string name = file.Substring(path.Length + 1, file.Length - path.Length - 5); XpoReader SourceFile = new XpoReader(file); string xpoText = SourceFile.Text(); MatchCollection matches = Regex.Matches(xpoText, @"FIELD[ ][#]([\w]+)[\s\S]*?PROPERTIES([\s\S]*?)ENDPROPERTIES", RegexOptions.Compiled); foreach (Match match in matches) { string fieldName = match.Groups[1].Value.Trim(); string properties = match.Groups[2].Value.Trim(); string typename = SourceFile.GetPropertyValue("ARRAY \r\n", properties); if (typename == String.Empty) { typename = SourceFile.GetPropertyValue("EnumType", properties); } FieldDictionaryBase d = new FieldDictionaryBase(); d.TableName = name; d.FieldName = fieldName; d.TypeName = typename; if (typename == string.Empty) { d.ArraySize = 1; } else { d.ArraySize = XpoRefactor.Dictionary.typeArraySize(typename); } if (!collection.ContainsKey(d.Key)) { collection.Add(d.Key, d); } } } } }