Ejemplo n.º 1
0
		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;
		}
Ejemplo n.º 2
0
        public override void PopulateSearchableIndex(IndexWriter writer)
        {
            foreach (Node n in Tree.RootNode.ChildNodes)
            {
                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);
            }
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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);
        }