public Writer(RelationSchemaLoaderResult rslr, String Title, String CopyrightText) { this.Schema = rslr.Schema; this.Title = Title; this.CopyrightText = CopyrightText; TypeInfoDict = new Dictionary <String, TypeInfo>(StringComparer.OrdinalIgnoreCase); String Root = ""; if (rslr.Positions.Count > 0) { Func <String, String, String> GetCommonHead = (a, b) => { var lc = new List <Char>(); var k = 0; while (true) { if (k >= a.Length || k >= b.Length) { break; } if (a[k] != b[k]) { break; } lc.Add(a[k]); k += 1; } return(new String(lc.ToArray())); }; Root = rslr.Positions.Select(p => FileNameHandling.GetDirectoryPathWithTailingSeparator(FileNameHandling.GetFileDirectory(p.Value.Text.Path))).Aggregate((a, b) => GetCommonHead(a, b)); if (Root != FileNameHandling.GetDirectoryPathWithTailingSeparator(Root)) { Root = FileNameHandling.GetFileDirectory(Root); } } var Map = Schema.GetMap().ToDictionary(p => p.Key, p => p.Value); foreach (var t in Schema.Types) { if (t.OnQueryList) { continue; } var Name = t.Name(); var Path = "Default.tree"; if (rslr.Positions.ContainsKey(t)) { Path = FileNameHandling.GetRelativePath(rslr.Positions[t].Text.Path, Root); } var PathWithoutExt = FileNameHandling.GetPath(FileNameHandling.GetFileDirectory(Path), FileNameHandling.GetMainFileName(Path)); var DocFilePath = PathWithoutExt.Replace(@"\", @"_").Replace(@"/", @"_").Replace(@".", "_").Replace(@":", @"_").Replace(@"#", @"_") + @".html"; var tli = new TypeInfo { Def = Map[Name], FriendlyPath = PathWithoutExt.Replace(@"\", @"/"), DocFilePath = DocFilePath, DocPath = String.Format("{0}#{1}", DocFilePath, Name) }; TypeInfoDict.Add(Name, tli); } }
public static List <FileResult> CompileToXhtml(this RelationSchemaLoaderResult rslr, String Title, String CopyrightText) { var w = new Writer(rslr, Title, CopyrightText); var Files = w.GetFiles(); return(Files); }