static private int readArrayLength(string FileName) { XpoReader SourceFile = new XpoReader(FileName); string ArraySizeProperty = SourceFile.GetPropertyValue("ArraySize"); if (ArraySizeProperty != String.Empty) { return(Int32.Parse(ArraySizeProperty)); } return(1); }
void scanFile(string filename) { progressCallback(filename); if (File.Exists(filename)) { XpoReader SourceFile = new XpoReader(filename); string fileText = SourceFile.Text(); string processedText = fileText; string skipText = processedText.ToLower(); foreach (Rule rule in rules) { if (rule.skip(skipText)) { continue; } processedText = rule.Run(processedText); } if (fileText != processedText) { ResultItem item = new ResultItem(); item.filename = filename; item.before = fileText; item.after = processedText; resultCallback(item); if (commit) { System.Text.Encoding outEncoding; outEncoding = SourceFile.fileEncoding; SourceFile = null; File.SetAttributes(filename, FileAttributes.Archive); FileStream destinationStream = new FileStream(filename, FileMode.Create); using (StreamWriter destinationFile = new StreamWriter(destinationStream, outEncoding)) { destinationFile.Write(processedText); } } } } }
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); } } } } }