public Dictionary<string, ErrorDocumentation> Compile (HelpSource hs) { string[] files = Directory.GetFiles (FilesPath, Match); var ret = new Dictionary<string, ErrorDocumentation> (); foreach (string s in files) { ErrorDocumentation d; int errorNum = 0; try { errorNum = int.Parse (Path.GetFileName (s).Substring (ErrorNumSubstringStart, ErrorNumSubstringLength)); } catch { Console.WriteLine ("Ignoring file {0}", s); } string errorName = String.Format (FriendlyFormatString, errorNum); if (!ret.TryGetValue (errorName, out d)) ret[errorName] = d = new ErrorDocumentation (errorName); if (d.Details == null) { string xmlFile = Path.ChangeExtension (s, "xml"); if (File.Exists (xmlFile)) { XmlSerializer cfgRdr = new XmlSerializer (typeof (ErrorDetails)); d.Details = (ErrorDetails)cfgRdr.Deserialize (new XmlTextReader (xmlFile)); } } // Encoding is same as used in MCS, so we will be able to do all those files using (StreamReader reader = new StreamReader (s, Encoding.GetEncoding (28591))) { d.Examples.Add (reader.ReadToEnd ()); } } return ret; }
public override void PopulateSearchableIndex(IndexWriter writer) { foreach (Node n in Tree.RootNode.Nodes) { XmlSerializer reader = new XmlSerializer(typeof(ErrorDocumentation)); ErrorDocumentation d = (ErrorDocumentation)reader.Deserialize(GetHelpStream(n.Element.Substring(6))); SearchableDocument doc = new SearchableDocument(); doc.title = d.ErrorName; doc.url = n.Element; doc.text = d.Details != null?d.Details.ToString() : string.Empty; doc.examples = d.Examples.Cast <string> ().Aggregate((e1, e2) => e1 + Environment.NewLine + e2); doc.hottext = d.ErrorName; writer.AddDocument(doc.LuceneDoc); } }
public override void CloseTree(HelpSource hs, Tree tree) { var entries = config.Compile(hs); MemoryStream ms = new MemoryStream(); XmlSerializer writer = new XmlSerializer(typeof(ErrorDocumentation)); foreach (var de in entries) { ErrorDocumentation d = de.Value; string s = de.Key; tree.RootNode.GetOrCreateNode(s, "error:" + s); writer.Serialize(ms, d); ms.Position = 0; hs.Storage.Store(s, ms); ms.SetLength(0); } tree.RootNode.Sort(); }
public Dictionary <string, ErrorDocumentation> Compile(HelpSource hs) { string[] files = Directory.GetFiles(FilesPath, Match); var ret = new Dictionary <string, ErrorDocumentation> (); foreach (string s in files) { ErrorDocumentation d; int errorNum = 0; try { errorNum = int.Parse(Path.GetFileName(s).Substring(ErrorNumSubstringStart, ErrorNumSubstringLength)); } catch { Console.WriteLine("Ignoring file {0}", s); } string errorName = String.Format(FriendlyFormatString, errorNum); if (!ret.TryGetValue(errorName, out d)) { ret[errorName] = d = new ErrorDocumentation(errorName); } if (d.Details == null) { string xmlFile = Path.ChangeExtension(s, "xml"); if (File.Exists(xmlFile)) { XmlSerializer cfgRdr = new XmlSerializer(typeof(ErrorDetails)); d.Details = (ErrorDetails)cfgRdr.Deserialize(new XmlTextReader(xmlFile)); } } // Encoding is same as used in MCS, so we will be able to do all those files using (StreamReader reader = new StreamReader(s, Encoding.GetEncoding(28591))) { d.Examples.Add(reader.ReadToEnd()); } } return(ret); }