static void Main(string[] args) { Console.WriteLine("Hello World!"); using (DbContext db = new DbContext()) { //Test.ShowQuery(db.Countries); //Test.ShowQuery(db.Cities); //Test.ShowQuery(db.Mains); //Test.ShowQuery(db.Details); //Test.ShowQuery(db.DetailChilds); Console.WriteLine("========================================="); //Test.ShowQuery<Country>(db.Countries.Where(x=>x.Name.ToLower() == "usa" || x.Id<2)); DocExample.GoDynamic(); } Console.ReadLine(); }
/// <summary> /// Loads all content from a folder hierarchy (overlaying anything already existing) /// </summary> /// <param name="project"></param> /// <param name="path"></param> public static void LoadFolder(DocProject project, string path) { // get all files within folder hierarchy string pathSchema = path + @"\schemas"; IEnumerable <string> en = System.IO.Directory.EnumerateFiles(pathSchema, "*.cs", System.IO.SearchOption.AllDirectories); List <string> list = new List <string>(); foreach (string s in en) { list.Add(s); } string[] files = list.ToArray(); Dictionary <string, string> options = new Dictionary <string, string> { { "CompilerVersion", "v4.0" } }; Microsoft.CSharp.CSharpCodeProvider prov = new Microsoft.CSharp.CSharpCodeProvider(options); System.CodeDom.Compiler.CompilerParameters parms = new System.CodeDom.Compiler.CompilerParameters(); parms.GenerateInMemory = true; parms.GenerateExecutable = false; parms.ReferencedAssemblies.Add("System.dll"); parms.ReferencedAssemblies.Add("System.Core.dll"); parms.ReferencedAssemblies.Add("System.ComponentModel.dll"); parms.ReferencedAssemblies.Add("System.ComponentModel.DataAnnotations.dll"); parms.ReferencedAssemblies.Add("System.Data.dll"); parms.ReferencedAssemblies.Add("System.Runtime.Serialization.dll"); parms.ReferencedAssemblies.Add("System.Xml.dll"); System.CodeDom.Compiler.CompilerResults results = prov.CompileAssemblyFromFile(parms, files); System.Reflection.Assembly assem = results.CompiledAssembly; LoadAssembly(project, assem); // EXPRESS rules (eventually in C#, though .exp file snippets for now) en = System.IO.Directory.EnumerateFiles(pathSchema, "*.exp", System.IO.SearchOption.AllDirectories); foreach (string file in en) { string name = Path.GetFileNameWithoutExtension(file); string expr = null; using (StreamReader readExpr = new StreamReader(file, Encoding.UTF8)) { if (name.Contains('-')) { // where rule expr = readExpr.ReadToEnd(); } else { // function: skip first and last lines readExpr.ReadLine(); StringBuilder sbExpr = new StringBuilder(); while (!readExpr.EndOfStream) { string line = readExpr.ReadLine(); if (!readExpr.EndOfStream) { sbExpr.AppendLine(line); } } expr = sbExpr.ToString(); } } if (name.Contains('-')) { // where rule string[] parts = name.Split('-'); if (parts.Length == 2) { DocWhereRule docWhere = new DocWhereRule(); docWhere.Name = parts[1]; docWhere.Expression = expr; DocDefinition docDef = project.GetDefinition(parts[0]); if (docDef is DocEntity) { DocEntity docEnt = (DocEntity)docDef; docEnt.WhereRules.Add(docWhere); } else if (docDef is DocDefined) { DocDefined docEnt = (DocDefined)docDef; docEnt.WhereRules.Add(docWhere); } else if (docDef == null) { //... global rule... } } } else { // function string schema = Path.GetDirectoryName(file); schema = Path.GetDirectoryName(schema); schema = Path.GetFileName(schema); DocSchema docSchema = project.GetSchema(schema); if (docSchema != null) { DocFunction docFunction = new DocFunction(); docSchema.Functions.Add(docFunction); docFunction.Name = name; docFunction.Expression = expr; } } } // now, hook up html documentation en = System.IO.Directory.EnumerateFiles(pathSchema, "*.htm", System.IO.SearchOption.AllDirectories); foreach (string file in en) { string name = Path.GetFileNameWithoutExtension(file); DocObject docObj = null; if (name == "schema") { string schema = Path.GetDirectoryName(file); schema = Path.GetFileName(schema); docObj = project.GetSchema(schema); } else if (name.Contains('-')) { // where rule string[] parts = name.Split('-'); if (parts.Length == 2) { DocDefinition docDef = project.GetDefinition(parts[0]); if (docDef is DocEntity) { DocEntity docEnt = (DocEntity)docDef; foreach (DocWhereRule docWhereRule in docEnt.WhereRules) { if (docWhereRule.Name.Equals(parts[1])) { docObj = docWhereRule; break; } } } else if (docDef is DocDefined) { DocDefined docEnt = (DocDefined)docDef; foreach (DocWhereRule docWhereRule in docEnt.WhereRules) { if (docWhereRule.Name.Equals(parts[1])) { docObj = docWhereRule; break; } } } } } else { docObj = project.GetDefinition(name); if (docObj == null) { docObj = project.GetFunction(name); } } if (docObj != null) { using (StreamReader readHtml = new StreamReader(file, Encoding.UTF8)) { docObj.Documentation = readHtml.ReadToEnd(); } } } // load schema diagrams en = System.IO.Directory.EnumerateFiles(pathSchema, "*.svg", System.IO.SearchOption.AllDirectories); foreach (string file in en) { string schema = Path.GetDirectoryName(file); schema = Path.GetFileName(schema); DocSchema docSchema = project.GetSchema(schema); if (docSchema != null) { using (IfcDoc.Schema.SVG.SchemaSVG schemaSVG = new IfcDoc.Schema.SVG.SchemaSVG(file, docSchema, project, DiagramFormat.UML)) { schemaSVG.Load(); } } } // psets, qsets //... // exchanges en = System.IO.Directory.EnumerateFiles(path, "*.mvdxml", System.IO.SearchOption.AllDirectories); foreach (string file in en) { IfcDoc.Schema.MVD.SchemaMVD.Load(project, file); } // examples string pathExamples = path + @"\examples"; if (Directory.Exists(pathExamples)) { en = System.IO.Directory.EnumerateFiles(pathExamples, "*.htm", SearchOption.TopDirectoryOnly); foreach (string file in en) { DocExample docExample = new DocExample(); docExample.Name = Path.GetFileNameWithoutExtension(file); project.Examples.Add(docExample); using (StreamReader reader = new StreamReader(file)) { docExample.Documentation = reader.ReadToEnd(); } string dirpath = file.Substring(0, file.Length - 4); if (Directory.Exists(dirpath)) { IEnumerable <string> suben = System.IO.Directory.EnumerateFiles(dirpath, "*.ifc", SearchOption.TopDirectoryOnly); foreach (string ex in suben) { DocExample docEx = new DocExample(); docEx.Name = Path.GetFileNameWithoutExtension(ex); docExample.Examples.Add(docEx); // read the content of the file using (FileStream fs = new FileStream(ex, FileMode.Open, FileAccess.Read)) { docEx.File = new byte[fs.Length]; fs.Read(docEx.File, 0, docEx.File.Length); } // read documentation string exdoc = ex.Substring(0, ex.Length - 4) + ".htm"; if (File.Exists(exdoc)) { using (StreamReader reader = new StreamReader(exdoc)) { docEx.Documentation = reader.ReadToEnd(); } } } } } } // localization en = System.IO.Directory.EnumerateFiles(path, "*.txt", System.IO.SearchOption.AllDirectories); foreach (string file in en) { using (FormatCSV format = new FormatCSV(file)) { try { format.Instance = project; format.Load(); } catch { } } } }
/// <summary> /// /// </summary> /// <param name="path">Path of parent</param> /// <param name="docExample"></param> private static void ExportExample(string path, string webpath, Type typeProject, DocExample docExample, StreamWriter writerIndex) { string pathExample = path + @"\" + DocumentationISO.MakeLinkName(docExample); string pathExampleWeb = webpath + "/" + DocumentationISO.MakeLinkName(docExample); // load SPF from internal content if (docExample.File != null) { try { using (MemoryStream streamSource = new MemoryStream(docExample.File)) { StepSerializer serSource = new StepSerializer(typeProject); object project = serSource.ReadObject(streamSource); // write original IFC file as-is (including comments) -- or could be normalized using StepSerializer using (FileStream streamIFC = new FileStream(pathExample + ".ifc", FileMode.Create)) { streamIFC.Write(docExample.File, 0, docExample.File.Length); } #if false using (FileStream streamXML = new FileStream(pathExample + ".ifcxml", FileMode.Create)) { BuildingSmart.Serialization.Xml.XmlSerializer streamTarget = new BuildingSmart.Serialization.Xml.XmlSerializer(typeProject); streamTarget.WriteObject(streamXML, project); } using (FileStream streamJSN = new FileStream(pathExample + ".json", FileMode.Create)) { BuildingSmart.Serialization.Json.JsonSerializer streamTarget = new BuildingSmart.Serialization.Json.JsonSerializer(typeProject); streamTarget.WriteObject(streamJSN, project); } using (FileStream streamTTL = new FileStream(pathExample + ".ttl", FileMode.Create)) { BuildingSmart.Serialization.Turtle.TurtleSerializer streamTarget = new BuildingSmart.Serialization.Turtle.TurtleSerializer(typeProject); streamTarget.WriteObject(streamTTL, project); } #endif } } catch (Exception xx) { System.Diagnostics.Debug.WriteLine(xx.Message); return; } writerIndex.WriteLine("<tr><td><a href=\"./" + webpath + ".htm\">" + docExample.Name + "</a></td>"); WriteExampleIndexFormat(writerIndex, pathExampleWeb, "ifc"); WriteExampleIndexFormat(writerIndex, pathExampleWeb, "ifcxml"); WriteExampleIndexFormat(writerIndex, pathExampleWeb, "json"); WriteExampleIndexFormat(writerIndex, pathExampleWeb, "ttl"); // github link writerIndex.WriteLine("<td><a href=\"https://github.com/BuildingSMART/IfcDoc/blob/master/IfcKit/" + pathExampleWeb + ".ifc\"><img src=\"github.png\" width=\"32\" height=\"32\" /></a></td>"); writerIndex.WriteLine("</tr>"); } else { // write header row writerIndex.WriteLine("<tr><th colspan=\"6\"><a href=\"./" + pathExampleWeb + ".htm\">" + docExample.Name + "</a></th></tr>"); } if (!String.IsNullOrEmpty(docExample.Documentation)) { string filehtml = pathExample + ".htm"; using (StreamWriter writerHtml = new StreamWriter(filehtml, false, Encoding.UTF8)) { writerHtml.Write(docExample.Documentation); } } if (docExample.Examples.Count > 0) { System.IO.Directory.CreateDirectory(pathExample); // recurse foreach (DocExample docSub in docExample.Examples) { ExportExample(pathExample, pathExampleWeb, typeProject, docSub, writerIndex); } } }
private static void BuildExampleList(List<DocExample> listExample, DocExample docExample, DocObject docObject, Dictionary<DocObject, bool> included) { // check for view reference if (included != null) { bool viewref = false; foreach (DocModelView docView in docExample.Views) { if (included.ContainsKey(docView)) { viewref = true; break; } } if (!viewref) return; } if (docExample.ApplicableType != null) { string[] types = docExample.ApplicableType.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string type in types) { string[] parts = type.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length >= 1) { if (parts[0].Equals(docObject.Name)) { listExample.Add(docExample); } } } } // templates if (docExample.ApplicableTemplates != null && docObject is DocTemplateDefinition) { if (docExample.ApplicableTemplates.Contains((DocTemplateDefinition)docObject)) { listExample.Add(docExample); } } // recurse foreach (DocExample docSub in docExample.Examples) { BuildExampleList(listExample, docSub, docObject, included); } }
private static void GenerateExample( DocExample docExample, List<DocXsdFormat> listFormats, string path, List<int> indexpath, Dictionary<DocObject, bool> included, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema, Dictionary<string, Type> typemap, List<ContentRef> listFigures, List<ContentRef> listTables, FormatHTM htmTOC, FormatHTM htmSectionTOC ) { if (included == null || included.ContainsKey(docExample)) { indexpath[indexpath.Count - 1]++; StringBuilder indexpathname = new StringBuilder(); indexpathname.Append("E"); foreach(int x in indexpath) { indexpathname.Append("."); indexpathname.Append(x); } string indexpathstring = indexpathname.ToString(); string pathExample = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".htm"; using (FormatHTM htmExample = new FormatHTM(pathExample, mapEntity, mapSchema, included)) { htmExample.WriteHeader(docExample.Name, 2); htmExample.WriteScript(-5, indexpath[0], 0, 0); htmExample.WriteLine("<h3 class=\"std\">" + indexpathstring + " " + docExample.Name + "</h3>"); // table of files if (docExample.File != null) { htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>Format</th><th>ASCII</th><th>HTML</th></tr>"); if (Properties.Settings.Default.ExampleSPF) { htmExample.Write("<tr><td>IFC-SPF</td><td><a href=\"" + MakeLinkName(docExample) + ".ifc\">File</a></td><td><a href=\"" + MakeLinkName(docExample) + ".ifc.htm\">Markup</a></td></tr>"); } if (Properties.Settings.Default.ExampleXML) { htmExample.Write("<tr><td>IFC-XML</td><td><a href=\"" + MakeLinkName(docExample) + ".ifcxml\">File</a></td><td><a href=\"" + MakeLinkName(docExample) + ".ifcxml.htm\">Markup</a></td></tr>"); } htmExample.Write("</table>"); htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>View</th></tr>"); foreach (DocModelView docView in docExample.Views) { if (included != null && included.ContainsKey(docView)) { string hyperlink = "../../schema/views/" + MakeLinkName(docView) + "/index.htm"; htmExample.Write("<tr><td><a href=\"" + hyperlink + "\">" + docView.Name + "</td></tr>"); } } htmExample.Write("</table>"); if (docExample.ApplicableType != null) { string[] ApplicableTypesArray = docExample.ApplicableType.Split(','); htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>Entity</th></tr>"); for (int i = 0; i < ApplicableTypesArray.Length; i++) { string hyperlink = "../../schema/" + mapSchema[ApplicableTypesArray.GetValue(i).ToString()].ToString().ToLower() + "/lexical/" + ApplicableTypesArray.GetValue(i).ToString().ToLower() + ".htm"; htmExample.Write("<tr><td><a href=" + hyperlink + ">" + ApplicableTypesArray.GetValue(i) + "</td></tr>"); } htmExample.Write("</table>"); } } docExample.Documentation = UpdateNumbering(docExample.Documentation, listFigures, listTables, docExample); htmExample.WriteDocumentationForISO(docExample.Documentation, docExample, false); htmExample.WriteLinkTo(docExample); htmExample.WriteFooter(Properties.Settings.Default.Footer); } if (docExample.File != null && !Properties.Settings.Default.SkipDiagrams) { string pathIFC = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc"; using (System.IO.FileStream filestream = new System.IO.FileStream(pathIFC, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) { filestream.Write(docExample.File, 0, docExample.File.Length); } using (FormatSPF spfExample = new FormatSPF(new System.IO.MemoryStream(docExample.File, false), typemap, null)) { string pathListing = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc.htm"; if (Properties.Settings.Default.ExampleSPF) { using (FormatHTM htmListing = new FormatHTM(pathListing, mapEntity, mapSchema, included)) { htmListing.WriteHeader(docExample.Name, 2); htmListing.WriteLine("<tt class=\"spf\">"); string htm = null; try { htm = spfExample.LoadMarkup(); } catch { } htmListing.Write(htm); htmListing.Write("</tt>"); htmListing.WriteFooter(String.Empty); } } else if(Properties.Settings.Default.ExampleXML) { // must load file in any case in order to generate xml try { spfExample.Load(); } catch { } } if (Properties.Settings.Default.ExampleXML) { // find the IfcProject SEntity rootproject = null; foreach (SEntity ent in spfExample.Instances.Values) { if (ent.GetType().Name.Equals("IfcProject")) { rootproject = ent; break; } } string pathXML = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml"; using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXML, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats)) { xmlExample.Instance = rootproject; xmlExample.Save(); } string pathXMH = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml.htm"; using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXMH, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats)) { xmlExample.Instance = rootproject; xmlExample.Markup = true; xmlExample.Save(); } } } } using (FormatHTM htmLink = new FormatHTM(path + "/link/" + MakeLinkName(docExample) + ".htm", mapEntity, mapSchema, included)) { string linkurl = "../annex/annex-e/" + MakeLinkName(docExample) + ".htm"; htmLink.WriteLinkPage(linkurl); } string urlExample = "annex-e/" + MakeLinkName(docExample) + ".htm"; htmTOC.WriteTOC(2, "<a class=\"listing-link\" href=\"annex/" + urlExample + "\" >" + indexpathstring + " " + docExample.Name + "</a>"); string linkid = ""; if(indexpath.Count == 1) { linkid = indexpath[0].ToString(); } string htmllink = "<a class=\"listing-link\" id=\"" + linkid + "\" href=\"" + urlExample + "\" target=\"info\">" + docExample.Name + "</a>"; htmSectionTOC.WriteLine("<tr class=\"std\"><td class=\"menu\">" + indexpathstring + " " + htmllink + "</td></tr>"); if (docExample.Examples.Count > 0) { indexpath.Add(0); foreach(DocExample docSub in docExample.Examples) { GenerateExample(docSub, listFormats, path, indexpath, included, mapEntity, mapSchema, typemap, listFigures, listTables, htmTOC, htmSectionTOC); } indexpath.RemoveAt(indexpath.Count - 1); } } }
private void toolStripMenuItemInsertExample_Click(object sender, EventArgs e) { DocExample docExample = new DocExample(); if (this.treeView.SelectedNode.Tag is DocExample) { DocExample docParent = (DocExample)this.treeView.SelectedNode.Tag; docParent.Examples.Add(docExample); TreeNode tn = LoadNode(this.treeView.SelectedNode, docExample, docExample.Name, true); this.treeView.SelectedNode = tn; } else { // top-level this.m_project.Examples.Add(docExample); TreeNode tn = LoadNode(this.treeView.Nodes[12], docExample, docExample.Name, true); this.treeView.SelectedNode = tn; } this.toolStripMenuItemEditRename_Click(sender, e); this.m_modified = true; }
private static void GenerateExample( DocPublication docPublication, DocExample docExample, List<DocXsdFormat> listFormats, string path, List<int> indexpath, Dictionary<DocObject, bool> included, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema, Dictionary<string, Type> typemap, List<ContentRef> listFigures, List<ContentRef> listTables, FormatHTM htmTOC, FormatHTM htmSectionTOC, Dictionary<DocFormatSchemaEnum, IFormatData> mapFormats, Dictionary<long, SEntity> outerinstancemap, // instance data of parent example, if inherited SEntity outerinstanceroot ) { if (included == null || included.ContainsKey(docExample)) { indexpath[indexpath.Count - 1]++; StringBuilder indexpathname = new StringBuilder(); indexpathname.Append("E"); foreach(int x in indexpath) { indexpathname.Append("."); indexpathname.Append(x); } string indexpathstring = indexpathname.ToString(); string pathExample = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".htm"; using (FormatHTM htmExample = new FormatHTM(pathExample, mapEntity, mapSchema, included)) { htmExample.WriteHeader(docExample.Name, 2, docPublication.Header); htmExample.WriteScript(-5, indexpath[0], 0, 0); htmExample.WriteLine("<h3 class=\"std\">" + indexpathstring + " " + docExample.Name + "</h3>"); // table of files if (docExample.File != null) { htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>Format</th><th>ASCII</th><th>HTML</th></tr>"); foreach(DocFormat docFormat in docPublication.Formats) { if (docFormat.FormatOptions == DocFormatOptionEnum.Examples) { string ext = docFormat.ExtensionInstances; htmExample.WriteLine("<tr><td>" + docFormat.FormatType.ToString() + "</td><td><a href=\"" + MakeLinkName(docExample) + "." + ext + "\">File</a></td><td><a href=\"" + MakeLinkName(docExample) + "." + ext + ".htm\">Markup</a></td></tr>"); } } htmExample.Write("</table>"); htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>View</th></tr>"); foreach (DocModelView docView in docExample.Views) { if (included != null && included.ContainsKey(docView)) { string hyperlink = "../../schema/views/" + MakeLinkName(docView) + "/index.htm"; htmExample.Write("<tr><td><a href=\"" + hyperlink + "\">" + docView.Name + "</td></tr>"); } } htmExample.Write("</table>"); if (docExample.ApplicableType != null) { string[] ApplicableTypesArray = docExample.ApplicableType.Split(','); htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>Entity</th></tr>"); for (int i = 0; i < ApplicableTypesArray.Length; i++) { string hyperlink = "../../schema/" + mapSchema[ApplicableTypesArray.GetValue(i).ToString()].ToString().ToLower() + "/lexical/" + ApplicableTypesArray.GetValue(i).ToString().ToLower() + ".htm"; htmExample.Write("<tr><td><a href=" + hyperlink + ">" + ApplicableTypesArray.GetValue(i) + "</td></tr>"); } htmExample.Write("</table>"); } } docExample.Documentation = UpdateNumbering(docExample.Documentation, listFigures, listTables, docExample); htmExample.WriteDocumentationMarkup(docExample.Documentation, docExample, docPublication); if (docExample.File == null && outerinstancemap != null) { // if specific to exchange, capture inline if (docExample.Views.Count > 0) { // hack for now based on example name matching exchange name -- make explicit later foreach (DocExchangeDefinition docExchange in docExample.Views[0].Exchanges) { if (docExample.Name.Equals(docExchange.Name)) { // matches -- generate FormatSQL fmt = new FormatSQL(); string content = fmt.FormatData(docPublication, docExchange, mapEntity, outerinstancemap, outerinstanceroot, false); htmExample.Write(content); break; } } } } htmExample.WriteLinkTo(docExample); htmExample.WriteFooter(docPublication.Footer); } if (docExample.File != null && !Properties.Settings.Default.SkipDiagrams) { string pathIFC = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc"; using (System.IO.FileStream filestream = new System.IO.FileStream(pathIFC, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) { filestream.Write(docExample.File, 0, docExample.File.Length); } using (FormatSPF spfExample = new FormatSPF(new System.IO.MemoryStream(docExample.File, false), typemap, null)) { string pathListing = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc.htm"; if (docPublication.GetFormatOption(DocFormatSchemaEnum.STEP) == DocFormatOptionEnum.Examples)//Properties.Settings.Default.ExampleSPF) { using (FormatHTM htmListing = new FormatHTM(pathListing, mapEntity, mapSchema, included)) { htmListing.WriteHeader(docExample.Name, 2, docPublication.Header); htmListing.WriteLine("<tt class=\"spf\">"); string htm = null; try { htm = spfExample.LoadMarkup(); outerinstancemap = spfExample.Instances; } catch { } htmListing.Write(htm); htmListing.Write("</tt>"); htmListing.WriteFooter(String.Empty); } } #if false else if(Properties.Settings.Default.ExampleXML) { // must load file in any case in order to generate xml try { spfExample.Load(); } catch { } } #endif // find the IfcProject SEntity rootproject = null; foreach (SEntity ent in spfExample.Instances.Values) { if (ent.GetType().Name.Equals("IfcProject")) { rootproject = ent; break; } } foreach (DocFormat docFormat in docPublication.Formats) { // generate example in other formats... if (docFormat.FormatOptions == DocFormatOptionEnum.Examples) { switch(docFormat.FormatType) { case DocFormatSchemaEnum.STEP: break; // do nothing #if false case DocFormatSchemaEnum.XML: // TODO: use generic formatter { // use xml namespace of first view string xmlns = "http://www.buildingsmart-tech.org/ifcXML/IFC4/final"; if (docExample.Views.Count > 0 && !String.IsNullOrEmpty(docExample.Views[0].XsdUri)) { xmlns = docExample.Views[0].XsdUri; } string pathXML = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml"; using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXML, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats, xmlns, docPublication.Code)) { xmlExample.Instance = rootproject; xmlExample.Save(); } string pathXMH = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml.htm"; using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXMH, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats, xmlns, docPublication.Code)) { xmlExample.Instance = rootproject; xmlExample.Markup = true; xmlExample.Save(); } } break; #endif // now use generic formatters case DocFormatSchemaEnum.TTL: { string ns = "http://ifcowl.openbimstandards.org/IFC4_ADD1#"; string pathTTL = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ttl"; Console.Out.WriteLine("------------------------------------------------"); Console.Out.WriteLine("converting file: " + MakeLinkName(docExample) + ".ttl"); Console.Out.WriteLine("------------------------------------------------"); using (FormatTTL_Stream TTLExample = new FormatTTL_Stream(new System.IO.FileStream(pathTTL, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), ns)) { TTLExample.Instances = spfExample.Instances; TTLExample.Save(); } //TODO: redo the HTM part later on //string pathTTLHTM = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ttl.htm"; //using (FormatTTL_Stream TTLExample = new FormatTTL_Stream(new System.IO.FileStream(pathTTLHTM, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), ns)) //{ // TTLExample.Instances = spfExample.Instances; // TTLExample.Markup = true; // TTLExample.Save(); //} } break; #if false case DocFormatTypeEnum.SQL: // todo: support others... // use formatter { FormatSQL fmt = new FormatSQL(); string content = fmt.FormatData(docPublication, null, mapEntity, spfExample.Instances); string pathRAW = path + @"\annex\annex-e\" + MakeLinkName(docExample) + "." + docFormat.ExtensionInstances; using (System.IO.StreamWriter writer = new System.IO.StreamWriter(pathRAW, false)) { writer.Write(content); } string pathHTM = pathRAW + ".htm"; using (FormatHTM fmtHTM = new FormatHTM(pathHTM, mapEntity, mapSchema, included)) { fmtHTM.WriteHeader(docExample.Name, 2, docPublication.Header); fmtHTM.Write(content); fmtHTM.WriteFooter(""); } } break; #endif default: // pluggable formatters { IFormatData formatext = null; if(mapFormats.TryGetValue(docFormat.FormatType, out formatext)) { string content = formatext.FormatData(docPublication, null, mapEntity, spfExample.Instances, rootproject, false); string pathRAW = path + @"\annex\annex-e\" + MakeLinkName(docExample) + "." + docFormat.ExtensionInstances; using (System.IO.StreamWriter writer = new System.IO.StreamWriter(pathRAW, false)) { writer.Write(content); } string conmark = formatext.FormatData(docPublication, null, mapEntity, spfExample.Instances, rootproject, true); string pathHTM = pathRAW + ".htm"; using (FormatHTM fmtHTM = new FormatHTM(pathHTM, mapEntity, mapSchema, included)) { fmtHTM.WriteHeader(docExample.Name, 2, docPublication.Header); fmtHTM.Write(conmark); fmtHTM.WriteFooter(""); } } } break; } } } } } using (FormatHTM htmLink = new FormatHTM(path + "/link/" + MakeLinkName(docExample) + ".htm", mapEntity, mapSchema, included)) { string linkurl = "../annex/annex-e/" + MakeLinkName(docExample) + ".htm"; htmLink.WriteLinkPage(linkurl, docPublication); } string urlExample = "annex-e/" + MakeLinkName(docExample) + ".htm"; htmTOC.WriteTOC(2, "<a class=\"listing-link\" href=\"annex/" + urlExample + "\" >" + indexpathstring + " " + docExample.Name + "</a>"); string linkid = ""; if(indexpath.Count == 1) { linkid = indexpath[0].ToString(); } string htmllink = "<a class=\"listing-link\" id=\"" + linkid + "\" href=\"" + urlExample + "\" target=\"info\">" + docExample.Name + "</a>"; htmSectionTOC.WriteLine("<tr class=\"std\"><td class=\"menu\">" + indexpathstring + " " + htmllink + "</td></tr>"); if (docExample.Examples.Count > 0) { indexpath.Add(0); foreach(DocExample docSub in docExample.Examples) { GenerateExample(docPublication, docSub, listFormats, path, indexpath, included, mapEntity, mapSchema, typemap, listFigures, listTables, htmTOC, htmSectionTOC, mapFormats, outerinstancemap, outerinstanceroot); } indexpath.RemoveAt(indexpath.Count - 1); } } }
private static void Dereference(DocExample docExample, DocModelView docModelView) { if (docExample.Views.Contains(docModelView)) { docExample.Views.Remove(docModelView); } if (docExample.Examples != null) { foreach (DocExample docSub in docExample.Examples) { Dereference(docSub, docModelView); } } }
private static void Dereference(DocExample docExample, DocTemplateDefinition docTemplate) { if (docExample.ApplicableTemplates != null && docExample.ApplicableTemplates.Contains(docTemplate)) { docExample.ApplicableTemplates.Remove(docTemplate); } if (docExample.Examples != null) { foreach (DocExample docSub in docExample.Examples) { Dereference(docSub, docTemplate); } } }
private void LoadTreeExample(TreeNode tnParent, DocExample docExample) { TreeNode tnChange = LoadNode(tnParent, docExample, docExample.Name, true); if (docExample.Examples != null) { foreach (DocExample docSub in docExample.Examples) { LoadTreeExample(tnChange, docSub); } } }
/// <summary> /// Loads all content from a folder hierarchy (overlaying anything already existing) /// </summary> /// <param name="project"></param> /// <param name="path"></param> public static void Load(DocProject project, string path) { // get all files within folder hierarchy string pathSchema = path + @"\schemas"; IEnumerable <string> en = System.IO.Directory.EnumerateFiles(pathSchema, "*.cs", System.IO.SearchOption.AllDirectories); List <string> list = new List <string>(); foreach (string s in en) { list.Add(s); } string[] files = list.ToArray(); Dictionary <string, string> options = new Dictionary <string, string> { { "CompilerVersion", "v4.0" } }; Microsoft.CSharp.CSharpCodeProvider prov = new Microsoft.CSharp.CSharpCodeProvider(options); System.CodeDom.Compiler.CompilerParameters parms = new System.CodeDom.Compiler.CompilerParameters(); parms.GenerateInMemory = true; parms.GenerateExecutable = false; parms.ReferencedAssemblies.Add("System.dll"); parms.ReferencedAssemblies.Add("System.Core.dll"); parms.ReferencedAssemblies.Add("System.ComponentModel.dll"); parms.ReferencedAssemblies.Add("System.ComponentModel.DataAnnotations.dll"); parms.ReferencedAssemblies.Add("System.Data.dll"); parms.ReferencedAssemblies.Add("System.Runtime.Serialization.dll"); parms.ReferencedAssemblies.Add("System.Xml.dll"); System.CodeDom.Compiler.CompilerResults results = prov.CompileAssemblyFromFile(parms, files); System.Reflection.Assembly assem = results.CompiledAssembly; // look through classes of assembly foreach (Type t in assem.GetTypes()) { string[] namespaceparts = t.Namespace.Split('.'); string schema = namespaceparts[namespaceparts.Length - 1]; DocSection docSection = null; if (t.Namespace.EndsWith("Resource")) { docSection = project.Sections[7]; } else if (t.Namespace.EndsWith("Domain")) { docSection = project.Sections[6]; } else if (t.Namespace.Contains("Shared")) { docSection = project.Sections[5]; } else { docSection = project.Sections[4]; // kernel, extensions } // find schema DocSchema docSchema = null; foreach (DocSchema docEachSchema in docSection.Schemas) { if (docEachSchema.Name.Equals(schema)) { docSchema = docEachSchema; break; } } if (docSchema == null) { docSchema = new DocSchema(); docSchema.Name = schema; docSection.Schemas.Add(docSchema); docSection.SortSchemas(); } DocDefinition docDef = null; if (t.IsEnum) { DocEnumeration docEnum = new DocEnumeration(); docSchema.Types.Add(docEnum); docDef = docEnum; System.Reflection.FieldInfo[] fields = t.GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); foreach (System.Reflection.FieldInfo field in fields) { DocConstant docConst = new DocConstant(); docEnum.Constants.Add(docConst); docConst.Name = field.Name; DescriptionAttribute[] attrs = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attrs.Length == 1) { docConst.Documentation = attrs[0].Description; } } } else if (t.IsValueType) { DocDefined docDefined = new DocDefined(); docSchema.Types.Add(docDefined); docDef = docDefined; PropertyInfo[] fields = t.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); docDefined.DefinedType = fields[0].PropertyType.Name; } else if (t.IsInterface) { DocSelect docSelect = new DocSelect(); docSchema.Types.Add(docSelect); docDef = docSelect; } else if (t.IsClass) { DocEntity docEntity = new DocEntity(); docSchema.Entities.Add(docEntity); docDef = docEntity; if (t.BaseType != typeof(object)) { docEntity.BaseDefinition = t.BaseType.Name; } if (!t.IsAbstract) { docEntity.EntityFlags = 0x20; } Dictionary <int, DocAttribute> attrsDirect = new Dictionary <int, DocAttribute>(); List <DocAttribute> attrsInverse = new List <DocAttribute>(); PropertyInfo[] fields = t.GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | BindingFlags.DeclaredOnly); foreach (PropertyInfo field in fields) { DocAttribute docAttr = new DocAttribute(); docAttr.Name = field.Name.Substring(1); Type typeField = field.PropertyType; if (typeField.IsGenericType) { Type typeGeneric = typeField.GetGenericTypeDefinition(); typeField = typeField.GetGenericArguments()[0]; if (typeGeneric == typeof(Nullable <>)) { docAttr.IsOptional = true; } else if (typeGeneric == typeof(ISet <>)) { docAttr.AggregationType = (int)DocAggregationEnum.SET; } else if (typeGeneric == typeof(IList <>)) { docAttr.AggregationType = (int)DocAggregationEnum.LIST; } } docAttr.DefinedType = typeField.Name; MinLengthAttribute mla = (MinLengthAttribute)field.GetCustomAttribute(typeof(MinLengthAttribute)); if (mla != null) { docAttr.AggregationLower = mla.Length.ToString(); } MaxLengthAttribute mxa = (MaxLengthAttribute)field.GetCustomAttribute(typeof(MaxLengthAttribute)); if (mxa != null) { docAttr.AggregationUpper = mxa.Length.ToString(); } PropertyInfo propinfo = t.GetProperty(docAttr.Name); if (propinfo != null) { DescriptionAttribute da = (DescriptionAttribute)propinfo.GetCustomAttribute(typeof(DescriptionAttribute)); if (da != null) { docAttr.Documentation = da.Description; } } DataMemberAttribute dma = (DataMemberAttribute)field.GetCustomAttribute(typeof(DataMemberAttribute)); if (dma != null) { attrsDirect.Add(dma.Order, docAttr); RequiredAttribute rqa = (RequiredAttribute)field.GetCustomAttribute(typeof(RequiredAttribute)); if (rqa == null) { docAttr.IsOptional = true; } CustomValidationAttribute cva = (CustomValidationAttribute)field.GetCustomAttribute(typeof(CustomValidationAttribute)); if (cva != null) { docAttr.IsUnique = true; } } else { InversePropertyAttribute ipa = (InversePropertyAttribute)field.GetCustomAttribute(typeof(InversePropertyAttribute)); if (ipa != null) { docAttr.Inverse = ipa.Property; attrsInverse.Add(docAttr); } } // xml XmlIgnoreAttribute xia = (XmlIgnoreAttribute)field.GetCustomAttribute(typeof(XmlIgnoreAttribute)); if (xia != null) { docAttr.XsdFormat = DocXsdFormatEnum.Hidden; } else { XmlElementAttribute xea = (XmlElementAttribute)field.GetCustomAttribute(typeof(XmlElementAttribute)); if (xea != null) { if (!String.IsNullOrEmpty(xea.ElementName)) { docAttr.XsdFormat = DocXsdFormatEnum.Element; } else { docAttr.XsdFormat = DocXsdFormatEnum.Attribute; } } } } foreach (DocAttribute docAttr in attrsDirect.Values) { docEntity.Attributes.Add(docAttr); } foreach (DocAttribute docAttr in attrsInverse) { docEntity.Attributes.Add(docAttr); } // get derived attributes based on properties PropertyInfo[] props = t.GetProperties(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); foreach (PropertyInfo prop in props) { // if no backing field, then derived FieldInfo field = t.GetField("_" + prop.Name, BindingFlags.NonPublic | BindingFlags.Instance); if (field == null) { DocAttribute docDerived = new DocAttribute(); docDerived.Name = prop.Name; docEntity.Attributes.Add(docDerived); } } } if (docDef != null) { docDef.Name = t.Name; docDef.Uuid = t.GUID; } docSchema.SortTypes(); docSchema.SortEntities(); } // pass 2: hook up selects foreach (Type t in assem.GetTypes()) { Type[] typeInterfaces = t.GetInterfaces(); if (typeInterfaces.Length > 0) { foreach (Type typeI in typeInterfaces) { DocSelect docSelect = project.GetDefinition(typeI.Name) as DocSelect; if (docSelect != null) { DocSelectItem docItem = new DocSelectItem(); docItem.Name = t.Name; docSelect.Selects.Add(docItem); } } } } // EXPRESS rules (eventually in C#, though .exp file snippets for now) en = System.IO.Directory.EnumerateFiles(pathSchema, "*.exp", System.IO.SearchOption.AllDirectories); foreach (string file in en) { string name = Path.GetFileNameWithoutExtension(file); string expr = null; using (StreamReader readExpr = new StreamReader(file, Encoding.UTF8)) { expr = readExpr.ReadToEnd(); } if (name.Contains('-')) { // where rule string[] parts = name.Split('-'); if (parts.Length == 2) { DocWhereRule docWhere = new DocWhereRule(); docWhere.Name = parts[1]; docWhere.Expression = expr; DocDefinition docDef = project.GetDefinition(parts[0]); if (docDef is DocEntity) { DocEntity docEnt = (DocEntity)docDef; docEnt.WhereRules.Add(docWhere); } else if (docDef is DocDefined) { DocDefined docEnt = (DocDefined)docDef; docEnt.WhereRules.Add(docWhere); } else if (docDef == null) { //... global rule... } } } else { // function string schema = Path.GetDirectoryName(file); schema = Path.GetDirectoryName(schema); schema = Path.GetFileName(schema); DocSchema docSchema = project.GetSchema(schema); if (docSchema != null) { DocFunction docFunction = new DocFunction(); docSchema.Functions.Add(docFunction); docFunction.Name = name; docFunction.Expression = expr; } } } // now, hook up html documentation en = System.IO.Directory.EnumerateFiles(pathSchema, "*.htm", System.IO.SearchOption.AllDirectories); foreach (string file in en) { string name = Path.GetFileNameWithoutExtension(file); DocObject docObj = null; if (name == "schema") { string schema = Path.GetDirectoryName(file); schema = Path.GetFileName(schema); docObj = project.GetSchema(schema); } else if (name.Contains('-')) { // where rule string[] parts = name.Split('-'); if (parts.Length == 2) { DocDefinition docDef = project.GetDefinition(parts[0]); if (docDef is DocEntity) { DocEntity docEnt = (DocEntity)docDef; foreach (DocWhereRule docWhereRule in docEnt.WhereRules) { if (docWhereRule.Name.Equals(parts[1])) { docObj = docWhereRule; break; } } } else if (docDef is DocDefined) { DocDefined docEnt = (DocDefined)docDef; foreach (DocWhereRule docWhereRule in docEnt.WhereRules) { if (docWhereRule.Name.Equals(parts[1])) { docObj = docWhereRule; break; } } } } } else { docObj = project.GetDefinition(name); if (docObj == null) { docObj = project.GetFunction(name); } } if (docObj != null) { using (StreamReader readHtml = new StreamReader(file, Encoding.UTF8)) { docObj.Documentation = readHtml.ReadToEnd(); } } } // load schema diagrams en = System.IO.Directory.EnumerateFiles(pathSchema, "*.svg", System.IO.SearchOption.AllDirectories); foreach (string file in en) { string schema = Path.GetDirectoryName(file); schema = Path.GetFileName(schema); DocSchema docSchema = project.GetSchema(schema); if (docSchema != null) { using (IfcDoc.Schema.SVG.SchemaSVG schemaSVG = new IfcDoc.Schema.SVG.SchemaSVG(file, docSchema, project)) { schemaSVG.Load(); } } } // psets, qsets //... // exchanges en = System.IO.Directory.EnumerateFiles(path, "*.mvdxml", System.IO.SearchOption.AllDirectories); foreach (string file in en) { IfcDoc.Schema.MVD.SchemaMVD.Load(project, file); } // examples string pathExamples = path + @"\examples"; if (Directory.Exists(pathExamples)) { en = System.IO.Directory.EnumerateFiles(pathExamples, "*.htm", SearchOption.TopDirectoryOnly); foreach (string file in en) { DocExample docExample = new DocExample(); docExample.Name = Path.GetFileNameWithoutExtension(file); project.Examples.Add(docExample); using (StreamReader reader = new StreamReader(file)) { docExample.Documentation = reader.ReadToEnd(); } string dirpath = file.Substring(0, file.Length - 4); if (Directory.Exists(dirpath)) { IEnumerable <string> suben = System.IO.Directory.EnumerateFiles(dirpath, "*.ifc", SearchOption.TopDirectoryOnly); foreach (string ex in suben) { DocExample docEx = new DocExample(); docEx.Name = Path.GetFileNameWithoutExtension(ex); docExample.Examples.Add(docEx); // read the content of the file using (FileStream fs = new FileStream(ex, FileMode.Open, FileAccess.Read)) { docEx.File = new byte[fs.Length]; fs.Read(docEx.File, 0, docEx.File.Length); } // read documentation string exdoc = ex.Substring(0, ex.Length - 4) + ".htm"; if (File.Exists(exdoc)) { using (StreamReader reader = new StreamReader(exdoc)) { docEx.Documentation = reader.ReadToEnd(); } } } } } } // localization en = System.IO.Directory.EnumerateFiles(path, "*.txt", System.IO.SearchOption.AllDirectories); foreach (string file in en) { using (FormatCSV format = new FormatCSV(file)) { try { format.Instance = project; format.Load(); } catch { } } } }
private static void GenerateExample( DocProject docProject, DocPublication docPublication, DocExample docExample, List<DocXsdFormat> listFormats, string path, List<int> indexpath, Dictionary<DocObject, bool> included, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema, Dictionary<string, Type> typemap, List<ContentRef> listFigures, List<ContentRef> listTables, FormatHTM htmTOC, FormatHTM htmSectionTOC, Dictionary<DocFormatSchemaEnum, IFormatData> mapFormats, Dictionary<long, SEntity> outerinstancemap, // instance data of parent example, if inherited SEntity outerinstanceroot ) { if (included == null || included.ContainsKey(docExample)) { indexpath[indexpath.Count - 1]++; StringBuilder indexpathname = new StringBuilder(); indexpathname.Append("E"); foreach(int x in indexpath) { indexpathname.Append("."); indexpathname.Append(x); } string indexpathstring = indexpathname.ToString(); string pathExample = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".htm"; using (FormatHTM htmExample = new FormatHTM(pathExample, mapEntity, mapSchema, included)) { htmExample.WriteHeader(docExample.Name, 2, docPublication.Header); htmExample.WriteScript(-5, indexpath[0], 0, 0); htmExample.WriteLine("<h3 class=\"std\">" + indexpathstring + " " + docExample.Name + "</h3>"); // table of files if (docExample.File != null) { htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>Format</th><th>ASCII</th><th>HTML</th><th>Size</th></tr>"); if (docExample.File != null && !Properties.Settings.Default.SkipDiagrams) { string pathIFC = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc"; using (System.IO.FileStream filestream = new System.IO.FileStream(pathIFC, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) { filestream.Write(docExample.File, 0, docExample.File.Length); } using (FormatSPF spfExample = new FormatSPF(new System.IO.MemoryStream(docExample.File, false), typemap, null)) { string pathListing = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc.htm"; if (docPublication.GetFormatOption(DocFormatSchemaEnum.STEP) == DocFormatOptionEnum.Examples)//Properties.Settings.Default.ExampleSPF) { using (FormatHTM htmListing = new FormatHTM(pathListing, mapEntity, mapSchema, included)) { htmListing.WriteHeader(docExample.Name, 2, docPublication.Header); htmListing.WriteLine("<tt class=\"spf\">"); string htm = null; try { htm = spfExample.LoadMarkup(); outerinstancemap = spfExample.Instances; } catch { } htmListing.Write(htm); htmListing.Write("</tt>"); htmListing.WriteFooter(String.Empty); } } // find the IfcProject SEntity rootproject = null; foreach (SEntity ent in spfExample.Instances.Values) { if (ent.GetType().Name.Equals("IfcProject")) { rootproject = ent; break; } } foreach (DocFormat docFormat in docPublication.Formats) { // generate example in other formats... if (docFormat.FormatOptions == DocFormatOptionEnum.Examples) { long filesize = docExample.File.LongLength; if (docFormat.FormatType != DocFormatSchemaEnum.STEP) { IFormatData formatext = null; if (mapFormats.TryGetValue(docFormat.FormatType, out formatext)) { string content = formatext.FormatData(docProject, docPublication, null, mapEntity, spfExample.Instances, rootproject, false); string pathRAW = path + @"\annex\annex-e\" + MakeLinkName(docExample) + "." + docFormat.ExtensionInstances; using (System.IO.StreamWriter writer = new System.IO.StreamWriter(pathRAW, false)) { writer.Write(content); } string conmark = formatext.FormatData(docProject, docPublication, null, mapEntity, spfExample.Instances, rootproject, true); string pathHTM = pathRAW + ".htm"; using (FormatHTM fmtHTM = new FormatHTM(pathHTM, mapEntity, mapSchema, included)) { fmtHTM.WriteHeader(docExample.Name, 2, docPublication.Header); fmtHTM.Write(conmark); fmtHTM.WriteFooter(""); } filesize = content.Length; } } string sizetext = filesize.ToString(); string ext = docFormat.ExtensionInstances; htmExample.WriteLine("<tr><td>" + docFormat.FormatType.ToString() + "</td><td><a href=\"" + MakeLinkName(docExample) + "." + ext + "\">File</a></td><td><a href=\"" + MakeLinkName(docExample) + "." + ext + ".htm\">Markup</a></td><td style=\"text-align:right\">" + sizetext + "</td></tr>"); } } } } htmExample.Write("</table>"); htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>View</th></tr>"); foreach (DocModelView docView in docExample.Views) { if (included != null && included.ContainsKey(docView)) { string hyperlink = "../../schema/views/" + MakeLinkName(docView) + "/index.htm"; htmExample.Write("<tr><td><a href=\"" + hyperlink + "\">" + docView.Name + "</td></tr>"); } } htmExample.Write("</table>"); if (docExample.ApplicableType != null) { string[] ApplicableTypesArray = docExample.ApplicableType.Split(','); htmExample.Write("<table class=\"gridtable\">"); htmExample.Write("<tr><th>Entity</th></tr>"); for (int i = 0; i < ApplicableTypesArray.Length; i++) { string hyperlink = "../../schema/" + mapSchema[ApplicableTypesArray.GetValue(i).ToString()].ToString().ToLower() + "/lexical/" + ApplicableTypesArray.GetValue(i).ToString().ToLower() + ".htm"; htmExample.Write("<tr><td><a href=" + hyperlink + ">" + ApplicableTypesArray.GetValue(i) + "</td></tr>"); } htmExample.Write("</table>"); } } docExample.Documentation = UpdateNumbering(docExample.Documentation, listFigures, listTables, docExample); htmExample.WriteDocumentationMarkup(docExample.Documentation, docExample, docPublication); if (docExample.File == null && outerinstancemap != null) { // if specific to exchange, capture inline if (docExample.Views.Count > 0) { // hack for now based on example name matching exchange name -- make explicit later foreach (DocExchangeDefinition docExchange in docExample.Views[0].Exchanges) { if (docExample.Name.Equals(docExchange.Name)) { // matches -- generate FormatSQL fmt = new FormatSQL(); string content = fmt.FormatData(docProject, docPublication, docExchange, mapEntity, outerinstancemap, outerinstanceroot, false); htmExample.Write(content); break; } } } } htmExample.WriteLinkTo(docExample); htmExample.WriteFooter(docPublication.Footer); } using (FormatHTM htmLink = new FormatHTM(path + "/link/" + MakeLinkName(docExample) + ".htm", mapEntity, mapSchema, included)) { string linkurl = "../annex/annex-e/" + MakeLinkName(docExample) + ".htm"; htmLink.WriteLinkPage(linkurl, docPublication); } string urlExample = "annex-e/" + MakeLinkName(docExample) + ".htm"; htmTOC.WriteTOC(2, "<a class=\"listing-link\" href=\"annex/" + urlExample + "\" >" + indexpathstring + " " + docExample.Name + "</a>"); string linkid = ""; if(indexpath.Count == 1) { linkid = indexpath[0].ToString(); } string htmllink = "<a class=\"listing-link\" id=\"" + linkid + "\" href=\"" + urlExample + "\" target=\"info\">" + docExample.Name + "</a>"; htmSectionTOC.WriteLine("<tr class=\"std\"><td class=\"menu\">" + indexpathstring + " " + htmllink + "</td></tr>"); if (docExample.Examples.Count > 0) { indexpath.Add(0); foreach(DocExample docSub in docExample.Examples) { GenerateExample(docProject, docPublication, docSub, listFormats, path, indexpath, included, mapEntity, mapSchema, typemap, listFigures, listTables, htmTOC, htmSectionTOC, mapFormats, outerinstancemap, outerinstanceroot); } indexpath.RemoveAt(indexpath.Count - 1); } } }