System.Xml.XmlWriter.WriteEndElement()

Here are the examples of the csharp api System.Xml.XmlWriter.WriteEndElement() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

832 Examples 7

19 Source : PSHelpGenerator.cs
with Apache License 2.0
from aws

private void WriteRelatedLinks(XmlWriter writer, string serviceAbbreviation, string cmdletName)
        {
            var webrefLink 
                = string.Format("{0}/index.html?page={1}.html&tocid={1}",
                                WebApiReferenceBaseUrl,
                                cmdletName);

            writer.WriteStartElement("relatedLinks");

            // first link must always be to the online version so get-help -online works
            WriteRelatedHelpNavigationLink(writer, "Online version:", webrefLink);

            WriteRelatedHelpNavigationLink(writer,
                                            "Common credential and region parameters: ",
                                            string.Format("{0}/items/pstoolsref-commonparams.html", WebApiReferenceBaseUrl));

            // finish with any service api reference/user guide links
            XmlDoreplacedent doreplacedent;
            if (LinksCache.TryGetValue(serviceAbbreviation, out doreplacedent))
            {
                ConstructLinks(writer, doreplacedent, "*");
                ConstructLinks(writer, doreplacedent, cmdletName);
            }

            writer.WriteEndElement();
        }

19 Source : PSHelpGenerator.cs
with Apache License 2.0
from aws

private void WriteExamples(XmlWriter writer, string cmdletName)
        {
            XmlDoreplacedent doreplacedent;
            if (!ExamplesCache.TryGetValue(cmdletName, out doreplacedent))
            {
                Console.WriteLine("NO EXAMPLES - {0}", cmdletName);
                return;
            }

            var set = doreplacedent.SelectSingleNode("examples");
            if (set == null || !set.HasChildNodes)
            {
                Console.WriteLine("NO EXAMPLES - {0} (file present but empty)", cmdletName);
                return;
            }

            writer.WriteStartElement("examples");
            {
                int exampleIndex = 1;
                var examples = set.SelectNodes("example");
                foreach (XmlNode example in examples)
                {
                    writer.WriteStartElement("example");
                    {
                        writer.WriteElementString("replacedle", string.Format(examplereplacedleFormat, exampleIndex));
                        {
                            // code tag CANNOT HAVE PARA TAGS
                            var code = example.SelectSingleNode("code");
                            if (code == null)
                            {
                                Logger.LogError("Unable to find examples <code> tag for cmdlet " + cmdletName);
                            }
                            
                            writer.WriteRawElementString("code", code.InnerXml);

                            // remarks tag MUST HAVE PARA TAGS
                            var description = example.SelectSingleNode("description");
                            if (description == null)
                            {
                                Logger.LogError("Unable to find examples <description> tag for cmdlet " + cmdletName);
                            }
                            var correctedText = DoreplacedentationUtils.ProcessLines(description.InnerXml, s => string.Format("<para>{0}</para>", s));
                            // we use br/ tags to format the description for webhelp, for native help we can replace
                            // with simple newlines
                            correctedText = correctedText.Replace("<br />", "\n"); // xml handler shows us <br/> as <br />
                            // <url>link</url> elements are stripped to leave the inner link text for the user to copy/paste
                            // (web help converts these to <a href="link" />)
                            correctedText = correctedText.Replace("<url>", "");
                            correctedText = correctedText.Replace("</url>", "");
                            var remarks = string.Format(remarksFormat, correctedText);
                            writer.WriteUnescapedElementString("remarks", remarks);
                        }
                    }
                    writer.WriteEndElement();
                    exampleIndex++;
                }
            }
            writer.WriteEndElement();
        }

19 Source : SerializableDictionary.cs
with Apache License 2.0
from aws

public void WriteXml(XmlWriter writer)
        {
            XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));
            XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));

            foreach (TKey key in this.Keys)
            {
                writer.WriteStartElement("item");

                writer.WriteStartElement("key");
                keySerializer.Serialize(writer, key);
                writer.WriteEndElement();

                writer.WriteStartElement("value");
                TValue value = this[key];
                valueSerializer.Serialize(writer, value);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }
        }

19 Source : PSHelpGenerator.cs
with Apache License 2.0
from aws

private static void WriteRelatedHelpNavigationLink(XmlWriter writer, string linkText, string linkUri)
        {
            writer.WriteStartElement("navigationLink");
            {
                writer.WriteElementString("linkText", linkText);
                writer.WriteElementString("uri", string.IsNullOrEmpty(linkUri) ? string.Empty : linkUri);
            }
            writer.WriteEndElement();
        }

19 Source : XmlReportWriter.cs
with Apache License 2.0
from aws

public static void SerializeReport(string folderPath, IEnumerable<ConfigModel> models)
        {
            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            var overrides = XmlOverridesMerger.GetOverridesDescription(folderPath, out var errorMessage);

            var filename = Path.Combine(folderPath, "report.xml");
            try
            {
                var writerSettings = new XmlWriterSettings
                {
                    Encoding = new UTF8Encoding(false),
                    Indent = true,
                    IndentChars = "    "
                };

                //We only include services with errors, new operations or operations requiring a configuration update
                var configModelsToOutput = models.Where(configModel =>
                        configModel.replacedysisErrors.Any() ||
                        overrides.ContainsKey(configModel.C2jFilename) ||
                        configModel.ServiceOperationsList.Where(op => op.IsAutoConfiguring || op.replacedysisErrors.Any()).Any())
                    .ToArray();

                var doc = new XDoreplacedent();

                using (var writer = doc.CreateWriter())
                {
                    writer.WriteStartElement("Overrides");
                    writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
                    writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
                    writer.WriteAttributeString("xsi", "noNamespaceSchemaLocation", null, "https://raw.githubusercontent.com/aws/aws-tools-for-powershell/master/XmlSchemas/ConfigurationOverrides/overrides.xsd");

                    if (errorMessage != null)
                    {
                        writer.WriteComment($"ERROR - {errorMessage}");
                    }

                    foreach (var configModel in configModelsToOutput)
                    {
                        var xmlAttributeOverrides = new XmlAttributeOverrides();
                        xmlAttributeOverrides.Add(typeof(ConfigModel), new XmlAttributes() { XmlRoot = new XmlRootAttribute("Service") });
                        var serializer = new XmlSerializer(typeof(ConfigModel), xmlAttributeOverrides);
                        serializer.Serialize(writer, configModel);
                    }

                    writer.WriteEndElement(); //Overrides
                }

                foreach (var configModel in doc.Root.Elements().Zip(configModelsToOutput, (element, model) => (element, model)))
                {
                    List<XComment> serviceComments = new List<XComment>();

                    XmlOverridesMerger.OverrideDescription modelOverrides;
                    if (overrides.TryGetValue(configModel.model.C2jFilename, out modelOverrides) && modelOverrides.FileVersion != configModel.model.FileVersion)
                    {
                        replacedysisError.WrongFileVersionNumber(configModel.model);
                        modelOverrides = null;
                    }

                    serviceComments.Add(new XComment($"The current full configuration for this service is available at https://raw.githubusercontent.com/aws/aws-tools-for-powershell/master/generator/AWSPSGeneratorLib/Config/ServiceConfig/{configModel.model.C2jFilename}.xml."));

                    foreach (var error in configModel.model.replacedysisErrors)
                    {
                        serviceComments.Add(new XComment($"ERROR - {error.Message}"));
                    }

                    foreach (var serviceElement in configModel.element.Elements().ToArray())
                    {
                        switch (serviceElement.Name.LocalName)
                        {
                            case nameof(ConfigModel.C2jFilename):
                            case nameof(ConfigModel.ServiceOperations):
                            case nameof(ConfigModel.FileVersion):
                                //Preserve these elements
                                break;
                            case nameof(ConfigModel.SkipCmdletGeneration):
                            case nameof(ConfigModel.replacedemblyName):
                            case nameof(ConfigModel.ServiceNounPrefix):
                            case nameof(ConfigModel.ServiceName):
                            case nameof(ConfigModel.ServiceClientInterface):
                            case nameof(ConfigModel.ServiceClient):
                            case nameof(ConfigModel.ServiceModuleGuid):
                                //Remove unless present in the override file
                                if (!(modelOverrides?.ElementNames.Contains(serviceElement.Name.LocalName) ?? false))
                                {
                                    serviceElement.Remove();
                                }
                                break;
                            default:
                                //Change into comments unless present in the override file
                                if (!(modelOverrides?.ElementNames.Contains(serviceElement.Name.LocalName) ?? false))
                                {
                                    serviceComments.Add(new XComment(serviceElement.ToString()));
                                    serviceElement.Remove();
                                }
                                break;
                        }
                    }

                    var serviceOperationsElement = configModel.element.Element("ServiceOperations");

                    serviceOperationsElement.AddBeforeSelf(serviceComments);

                    var operations = serviceOperationsElement.Elements()
                        .Join(configModel.model.ServiceOperationsList, element => element.Attribute("MethodName").Value, operation => operation.MethodName, (element, operation) => (element, operation))
                        .ToArray();

                    foreach (var operation in operations)
                    {
                        var isConfigurationOverridden = modelOverrides?.MethodNames.Contains(operation.operation.MethodName) ?? false;

                        //We only include in the report new operations (IsAutoConfiguring=true) and operations requiring configuration updated. We also retain in the report
                        //any operation that was manually configured.
                        if (operation.operation.IsAutoConfiguring ||
                            operation.operation.replacedysisErrors.Any() ||
                            isConfigurationOverridden)
                        {
                            var firstOperationChildElement = operation.element.Elements().FirstOrDefault();

                            if (operation.operation.IsAutoConfiguring)
                            {
                                operation.element.AddFirst(new XComment($"INFO - This is a new cmdlet."));
                            }
                            if (isConfigurationOverridden)
                            {
                                operation.element.AddFirst(new XComment($"INFO - The configuration of this cmdlet is being changed through overrides."));
                            }
                            foreach (var error in operation.operation.replacedysisErrors)
                            {
                                operation.element.AddFirst(new XComment($"ERROR - {error.Message}"));
                            }

                            try
                            {
                                //Excluded operations have replacedyzer == null
                                if (operation.operation.replacedyzer != null)
                                {
                                    if (operation.operation.replacedyzer.replacedyzedParameters.Any())
                                    {
                                        var parametersComments = operation.operation.replacedyzer.replacedyzedParameters.Select(PropertyChangedEventArgs => GetParameterCommentForReport(PropertyChangedEventArgs, operation.operation.replacedyzer));
                                        operation.element.Add(new XComment($"INFO - Parameters:\n            {string.Join(";\n            ", parametersComments)}."));
                                    }

                                    var returnTypeComment = GetReturnTypeComment(operation.operation.replacedyzer);
                                    if (returnTypeComment != null)
                                    {
                                        operation.element.Add(new XComment($"INFO - {returnTypeComment}"));
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                operation.element.AddFirst(new XComment($"ERROR - Exception while generating operation report: {e.ToString()}"));
                            }
                        }
                        else
                        {
                            operation.element.Remove();
                        }
                    }
                }

                doc.Save(filename);
            }
            catch (Exception e)
            {
                throw new IOException("Unable to serialize report to " + filename, e);
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                throw new Exception(errorMessage);
            }
        }

19 Source : FormatGenerator.cs
with Apache License 2.0
from aws

protected override void GenerateHelper()
        {
            var configurationsFolder = Path.Combine(Options.RootPath, FormatGeneratorConfigurationsFoldername);
            ConfigCollection = ConfigModelCollection.LoadAllConfigs(configurationsFolder, Options.Verbose);

            LoadCustomFormatDoreplacedents(configurationsFolder);

            var types = new List<Type>();
            foreach (var replacedembly in Targetreplacedemblies)
            {
                var replacedemblyTypes = GetTypes(replacedembly);
                types.AddRange(replacedemblyTypes);

                var includeTypes = GetTypes(replacedembly, ConfigCollection.TypesToInclude.ToArray());
                types.AddRange(includeTypes);
            }

            var cmdletType = typeof(Cmdlet);
            types.RemoveAll(t =>
            {
                var isPrivate = !t.IsPublic || t.IsNestedPrivate;
                var shouldExclude = ConfigCollection.TypeExclusionSet.Contains(t.FullName);
                var isCmdlet = t.IsSubclreplacedOf(cmdletType);

                var exclude = (isPrivate || shouldExclude || isCmdlet);
                if (exclude)
                    Logger.Log("Excluding type {0} from formats file", t.FullName);

                return exclude;
            });

            if (!Directory.Exists(OutputFolder))
                Directory.CreateDirectory(OutputFolder);

            var outputFile = Path.Combine(OutputFolder, Name + ".Format.ps1xml");
            if (File.Exists(outputFile))
                File.Delete(outputFile);

            using (var stream = File.OpenWrite(outputFile))
            {
                var writerSettings = new XmlWriterSettings
                {
                    Encoding = Encoding.UTF8,
                    Indent = true
                };
                using (var writer = XmlWriter.Create(stream, writerSettings))
                {
                    writer.WriteStartDoreplacedent();
                    writer.WriteStartElement("Configuration");
                    writer.WriteStartElement("ViewDefinitions");

                    foreach (var type in types)
                    {
                        var config = GetConfig(type);

                        Logger.Log();
                        Logger.Log(new string('>', 20));
                        Logger.Log("Generating config: {0}", config);

                        GenerateView(config, writer, type);

                        Logger.Log(new string('<', 20));
                        Logger.Log();
                    }

                    foreach (var cfd in ConfigCollection.CustomFormatDoreplacedents)
                    {
                        var viewDefinitions = cfd.SelectSingleNode("descendant::ViewDefinitions");
                        if (viewDefinitions == null)
                            continue;

                        foreach (var viewNode in viewDefinitions.ChildNodes)
                        {
                            var viewNodeXml = viewNode as XmlNode;
                            using (var reader = XmlReader.Create(new StringReader(viewNodeXml.OuterXml)))
                            {
                                writer.WriteNode(reader, false);
                            }
                        }
                    }

                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndDoreplacedent();
                }
            }
        }

19 Source : IndexXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(XmlWriter writer)
        {
            writer.WriteStartDoreplacedent();
            writer.WriteStartElement("index");

            foreach (Entry current in this.doreplacedentMap)
            {
                writer.WriteStartElement("item");
                writer.WriteAttributeString("name", current.Name);
                writer.WriteAttributeString("safename", Exporter.CreateSafeName(current.Name));
                writer.WriteAttributeString("key", current.Key.ToString());
                writer.WriteAttributeString("subkey", current.SubKey);

                foreach (Entry child in current.Children)
                {
                    this.Render(child, writer);
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement(); // index
            writer.WriteEndDoreplacedent();
        }

19 Source : CollectionXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            writer.WriteStartDoreplacedent();
            writer.WriteRaw("<!DOCTYPE HelpCollection SYSTEM \"MS-Help://Hx/Resources/HelpCollection.DTD\">");

            writer.WriteStartElement("HelpCollection");
            writer.WriteAttributeString("DTDVersion", "1.0");
            writer.WriteAttributeString("FileVersion", "1.0");
            writer.WriteAttributeString("replacedle", "Specified by the user");

            writer.WriteStartElement("CompilerOptions");
            writer.WriteAttributeString("CompileResult", "Hxs");
            if (!string.IsNullOrEmpty(this.outputFileName))
            {
                writer.WriteAttributeString("OutputFile", this.outputFileName);
            }
            writer.WriteAttributeString("StopWordFile", "stopwords.txt");

            // pointer to the include file .HxF (requried)
            writer.WriteStartElement("IncludeFile");
            writer.WriteAttributeString("File", string.Format("{0}.HxF", CollectionXmlRenderer.doreplacedentation));
            writer.WriteEndElement(); // IncludeFile

            writer.WriteEndElement(); // CompilerOptions

            //// pointer to the attribute definition file .HxA (requried)
            //writer.WriteStartElement("AttributeDef");	// zero or more times
            //writer.WriteAttributeString("File", string.Empty);	// required
            //writer.WriteAttributeString("Owner", string.Empty);
            //writer.WriteEndElement();

            //// pointer to the virtual topic defintion file .HxV (requried)
            //writer.WriteStartElement("VTopicDef");	// zero or more times
            //writer.WriteAttributeString("File", string.Empty);
            //writer.WriteEndElement();

            // pointer to the TOC file .HxT (requried)
            writer.WriteStartElement("TOCDef");     // zero or more times
            writer.WriteAttributeString("File", string.Format("{0}.HxT", CollectionXmlRenderer.doreplacedentation));
            writer.WriteEndElement();

            string[] indexes = {
                                   "_A.HxK",
                                   "_B.HxK",
                                   "_F.HxK",
                                   "_K.HxK",
                                   "_NamedUrl.HxK",
                                   "_S.HxK"
                               };
            foreach (string index in indexes)
            {
                // pointer to the keyword-index file .HxK (requried)
                writer.WriteStartElement("KeywordIndexDef"); // zero or more times
                writer.WriteAttributeString("File", string.Format("{0}{1}", CollectionXmlRenderer.doreplacedentation, index));
                writer.WriteEndElement();
            }

            //// pointer to the sample definition .HxE (requried)
            //writer.WriteStartElement("SampleDef"); // zero or more times
            //writer.WriteAttributeString("File", "sampledef.HxE");
            //writer.WriteEndElement();

            // apparently these are required, but I dont really know why? http://helpware.net/mshelp2/h2tutorial.htm
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultTOC\" ProgId=\"HxDs.HxHierarchy\" InitData=\"" + CollectionXmlRenderer.doreplacedentation + "\" />");
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultFullTextSearch\" ProgId=\"HxDs.HxFullTextSearch\" InitData=\"FTS\" />");
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultreplacedociativeIndex\" ProgId=\"HxDs.HxIndex\" InitData=\"A\" />");
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultDynamicLinkIndex\" ProgId=\"HxDs.HxIndex\" InitData=\"B\" />");
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultContextWindowIndex\" ProgId=\"HxDs.HxIndex\" InitData=\"F\" />");
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultKeywordIndex\" ProgId=\"HxDs.HxIndex\" InitData=\"K\" />");
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultNamedUrlIndex\" ProgId=\"HxDs.HxIndex\" InitData=\"NamedUrl\" />");
            writer.WriteRaw("<ItemMoniker Name=\"!DefaultSearchWindowIndex\" ProgId=\"HxDs.HxIndex\" InitData=\"S\" />");

            //writer.WriteStartElement("ToolData"); // zero or more times
            //writer.WriteAttributeString("Name", string.Empty); // requried
            //writer.WriteAttributeString("Value", string.Empty); // required
            //writer.WriteEndElement();

            writer.WriteEndElement(); // HelpCollection
        }

19 Source : IncludeFileXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            writer.WriteStartDoreplacedent();
            writer.WriteRaw("<!DOCTYPE HelpFileList SYSTEM \"ms-help://hx/resources/HelpFileList.DTD\">");

            writer.WriteStartElement("HelpFileList");
            writer.WriteAttributeString("DTDVersion", "1.0");

            foreach (string file in this.BuildFileList())
            {
                writer.WriteStartElement("File");
                writer.WriteAttributeString("Url", file);
                writer.WriteEndElement();
            }

            writer.WriteEndElement(); // HelpFileList
        }

19 Source : AssemblyXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("replacedembly");
            writer.WriteAttributeString("id", replacedociatedEntry.Key.ToString());

            writer.WriteStartElement("name");
            writer.WriteString($"{_member.Name} replacedembly");
            writer.WriteEndElement();

            foreach (Entry current in replacedociatedEntry.Children)
            {
                writer.WriteStartElement("parent");
                writer.WriteAttributeString("name", current.Name);
                writer.WriteAttributeString("key", current.Key.ToString());
                writer.WriteAttributeString("type", "namespace");
                if (IncludeCRefPath)
                    writer.WriteAttributeString("cref", string.Format("N:{0}", current.Name));
                writer.WriteEndElement(); // parent
            }

            writer.WriteEndElement(); // replacedembly
        }

19 Source : DocumentMapXmlRenderer.cs
with MIT License
from barry-jones

private void Render(Entry entry, System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("item");
            writer.WriteAttributeString("name", entry.Name);
            if (_includeSafeName)
                writer.WriteAttributeString("safename", Exporter.CreateSafeName(entry.Name));
            writer.WriteAttributeString("key", entry.Key.ToString());
            writer.WriteAttributeString("subkey", entry.SubKey);
            WriteCref(entry, writer);

            foreach (Entry child in entry.Children)
            {
                Render(child, writer);
            }

            writer.WriteEndElement();
        }

19 Source : EventXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath crefPath = new CRefPath(_member);
            XmlCodeComment comment = _xmlComments.GetComment(crefPath);

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", replacedociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            writer.WriteAttributeString("cref", crefPath.ToString());
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(_member.Name));
            writer.WriteString(_member.Name);
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = replacedociatedEntry.FindNamespace(_member.Type.Namespace);
            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.Type.Namespace}");
            writer.WriteString(_member.Type.Namespace);
            writer.WriteEndElement();
            writer.WriteStartElement("replacedembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.replacedembly.FileName));
            writer.WriteString(_member.replacedembly.Name);
            writer.WriteEndElement();

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement summary = comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    Serialize(summary, writer);
                }
            }

            RenderPermissionBlock(_member, writer, comment);
            RenderSyntaxBlocks(_member, writer);

            // find and output the remarks
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the examples
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            writer.WriteEndElement();
        }

19 Source : FieldXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath crefPath = new CRefPath(_member);
            XmlCodeComment comment = _xmlComments.GetComment(crefPath);

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", replacedociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            writer.WriteAttributeString("cref", crefPath.ToString());
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(_member.Name));
            writer.WriteString(_member.Name);
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = this.replacedociatedEntry.FindNamespace(_member.Type.Namespace);
            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.Type.Namespace}");
            writer.WriteString(_member.Type.Namespace);
            writer.WriteEndElement();
            writer.WriteStartElement("replacedembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.replacedembly.FileName));
            writer.WriteString(_member.replacedembly.Name);
            writer.WriteEndElement();

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement summary = comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    Serialize(summary, writer);
                }
            }

            this.RenderPermissionBlock(_member, writer, comment);
            this.RenderSyntaxBlocks(_member, writer);

            // find and output the value
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ValueXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the examples
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            writer.WriteEndElement();
        }

19 Source : ListXmlElementRenderer.cs
with MIT License
from barry-jones

private void RenderTable(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("table");

            // create the table header
            ListHeaderXmlCodeElement header = (ListHeaderXmlCodeElement)_element.Elements.Find(
                e => e.Element == XmlCodeElements.ListHeader);
            writer.WriteStartElement("header");
            if (header != null)
            {
                XmlContainerCodeElement description = (XmlContainerCodeElement)_element.Elements.Find(
                    e => e.Element == XmlCodeElements.Description);
                XmlContainerCodeElement term = (XmlContainerCodeElement)_element.Elements.Find(
                    e => e.Element == XmlCodeElements.Term);

                writer.WriteStartElement("cell");
                if (term != null)
                {
                    foreach (XmlCodeElement child in term.Elements)
                    { // miss out the lisreplacedem and just focus on children
                        this.Serialize(child, writer);
                    }
                }
                else
                {
                    writer.WriteElementString("text", "Term");
                }
                writer.WriteEndElement(); // column

                writer.WriteStartElement("cell");
                if (description != null)
                {
                    foreach (XmlCodeElement child in description.Elements)
                    { // miss out the lisreplacedem and just focus on children
                        Serialize(child, writer);
                    }
                }
                else
                {
                    writer.WriteElementString("text", "Description");
                }
                writer.WriteEndElement(); // column
            }
            else
            {
                writer.WriteStartElement("cell");
                writer.WriteElementString("text", "Term");
                writer.WriteEndElement(); // column
                writer.WriteStartElement("cell");
                writer.WriteElementString("text", "Description");
                writer.WriteEndElement(); // column
            }
            writer.WriteEndElement(); // header

            // rows
            List<XmlCodeElement> items = _element.Elements.FindAll(e => e.Element == XmlCodeElements.Lisreplacedem);
            foreach (LisreplacedemXmlCodeElement currenreplacedem in items)
            {
                if (currenreplacedem.Elements.Count == 2)
                {
                    writer.WriteStartElement("row");
                    XmlContainerCodeElement description = (XmlContainerCodeElement)currenreplacedem.Elements.Find(
                    e => e.Element == XmlCodeElements.Description);
                    XmlContainerCodeElement term = (XmlContainerCodeElement)currenreplacedem.Elements.Find(
                        e => e.Element == XmlCodeElements.Term);

                    writer.WriteStartElement("cell");
                    if (term != null)
                    {
                        foreach (XmlCodeElement child in term.Elements)
                        { // miss out the lisreplacedem and just focus on children
                            Serialize(child, writer);
                        }
                    }
                    writer.WriteEndElement();
                    writer.WriteStartElement("cell");
                    if (description != null)
                    {
                        foreach (XmlCodeElement child in description.Elements)
                        { // miss out the lisreplacedem and just focus on children
                            Serialize(child, writer);
                        }
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement(); // row
                }
            }

            writer.WriteEndElement(); // table
        }

19 Source : ListXmlElementRenderer.cs
with MIT License
from barry-jones

private void RenderList(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("list");
            // listtype can be bullet or number
            writer.WriteAttributeString("type", _element.ListType.ToString().ToLower());

            List<XmlCodeElement> elements = _element.Elements.FindAll(e => e.Element == XmlCodeElements.Lisreplacedem);
            foreach (LisreplacedemXmlCodeElement item in elements)
            {
                writer.WriteStartElement("item");
                foreach (XmlCodeElement child in item.Elements)
                { // miss out the lisreplacedem and just focus on children
                    this.Serialize(child, writer);
                }
                writer.WriteEndElement(); // item
            }

            writer.WriteEndElement(); // list
        }

19 Source : MethodXmlRenderer.cs
with MIT License
from barry-jones

private void RenderParameters(System.Xml.XmlWriter writer, XmlCodeComment comment)
        {
            if (_member.Parameters.Count > 0)
            {
                writer.WriteStartElement("parameters");
                for (int i = 0; i < _member.Parameters.Count; i++)
                {
                    if (_member.Parameters[i].Sequence == 0)
                        continue;

                    TypeRef parameterType = _member.ResolveParameter(_member.Parameters[i].Sequence);
                    TypeDef foundEntry = _member.replacedembly.FindType(parameterType.Namespace, parameterType.Name);

                    writer.WriteStartElement("parameter");
                    writer.WriteAttributeString("name", _member.Parameters[i].Name);
                    writer.WriteStartElement("type");
                    if (foundEntry != null)
                    {
                        writer.WriteAttributeString("key", foundEntry.GetGloballyUniqueId().ToString());
                        writer.WriteAttributeString("cref", CRefPath.Create(foundEntry).ToString());
                    }
                    writer.WriteString(parameterType.GetDisplayName(false));
                    writer.WriteEndElement(); // type

                    if (comment != XmlCodeComment.Empty)
                    {
                        XmlCodeElement paramEntry = comment.Elements.Find(currentBlock =>
                            currentBlock is ParamXmlCodeElement
                            && ((ParamXmlCodeElement)currentBlock).Name == _member.Parameters[i].Name);
                        if (paramEntry != null)
                        {
                            writer.WriteStartElement("description");
                            ParamXmlCodeElement paraElement = (ParamXmlCodeElement)paramEntry;
                            for (int j = 0; j < paraElement.Elements.Count; j++)
                            {
                                Serialize(paraElement.Elements[j], writer);
                            }
                            writer.WriteEndElement();
                        }
                    }

                    writer.WriteEndElement(); // parameter
                }
                writer.WriteEndElement();
            }
        }

19 Source : NamespaceXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("namespace");
            writer.WriteAttributeString("id", replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", replacedociatedEntry.SubKey);
            WriteCref(replacedociatedEntry, writer);

            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(_member.Key));
            writer.WriteString($"{_member.Key} Namespace");
            writer.WriteEndElement();

            foreach (Entry current in replacedociatedEntry.Children)
            {
                writer.WriteStartElement("parent");
                writer.WriteAttributeString("name", current.Name);
                writer.WriteAttributeString("key", current.Key.ToString());
                writer.WriteAttributeString("type", ReflectionHelper.GetType((TypeDef)current.Item));
                writer.WriteAttributeString("visibility", ReflectionHelper.GetVisibility(current.Item));
                WriteCref(current, writer);

                // write the summary text for the current member
                XmlCodeComment comment = _xmlComments.GetComment(new CRefPath((TypeDef)current.Item));
                if (comment != null && comment.Elements != null)
                {
                    SummaryXmlCodeElement summary = comment.Elements.Find(
                        p => p is SummaryXmlCodeElement
                        ) as SummaryXmlCodeElement;
                    if (summary != null)
                    {
                        Serialize(summary, writer);
                    }
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }

19 Source : PropertyXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath crefPath = new CRefPath(_member);
            XmlCodeComment comment = _xmlComments.GetComment(crefPath);
            string displayName = new DisplayNameSignitureConvertor(_member, false, true).Convert();

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", replacedociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            WriteCref(replacedociatedEntry, writer);
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", displayName);
            writer.WriteString(displayName);
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = replacedociatedEntry.FindNamespace(_member.OwningType.Namespace);
            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.OwningType.Namespace}");
            writer.WriteString(_member.OwningType.Namespace);
            writer.WriteEndElement();
            writer.WriteStartElement("replacedembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.replacedembly.FileName));
            writer.WriteString(_member.replacedembly.Name);
            writer.WriteEndElement();

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement summary = comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    Serialize(summary, writer);
                }
            }

            RenderExceptionBlock(_member, writer, comment);
            RenderPermissionBlock(_member, writer, comment);
            RenderSyntaxBlocks(_member, writer);

            MethodDef internalMethod = _member.Getter == null ? _member.Setter : _member.Getter;
            if (_member.IsIndexer() && internalMethod.Parameters.Count > 0)
            {
                writer.WriteStartElement("parameters");
                for (int i = 0; i < internalMethod.Parameters.Count; i++)
                {
                    if (internalMethod.Parameters[i].Sequence == 0)
                        continue;

                    TypeRef parameterType = internalMethod.ResolveParameter(internalMethod.Parameters[i].Sequence);
                    TypeDef foundEntry = _member.replacedembly.FindType(parameterType.Namespace, parameterType.Name);

                    writer.WriteStartElement("parameter");
                    writer.WriteAttributeString("name", internalMethod.Parameters[i].Name);
                    writer.WriteStartElement("type");
                    if (foundEntry != null)
                    {
                        writer.WriteAttributeString("key", foundEntry.GetGloballyUniqueId().ToString());
                        writer.WriteAttributeString("cref", CRefPath.Create(foundEntry).ToString());
                    }
                    writer.WriteString(parameterType.GetDisplayName(false));
                    writer.WriteEndElement(); // type

                    if (comment != XmlCodeComment.Empty)
                    {
                        XmlCodeElement paramEntry = comment.Elements.Find(currentBlock =>
                            currentBlock is ParamXmlCodeElement
                            && ((ParamXmlCodeElement)currentBlock).Name == internalMethod.Parameters[i].Name);
                        if (paramEntry != null)
                        {
                            writer.WriteStartElement("description");
                            ParamXmlCodeElement paraElement = (ParamXmlCodeElement)paramEntry;
                            for (int j = 0; j < paraElement.Elements.Count; j++)
                            {
                                Serialize(paraElement.Elements[j], writer);
                            }
                            writer.WriteEndElement();
                        }
                    }

                    writer.WriteEndElement(); // parameter
                }
                writer.WriteEndElement();
            }

            // find and output the value
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ValueXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the remarks
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the examples
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            writer.WriteEndElement();
        }

19 Source : SeeXmlElementRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            Entry entry = Doreplacedent.Find(_element.Member);
            string displayName = string.IsNullOrEmpty(_element.Member.ElementName)
                ? _element.Member.TypeName
                : _element.Member.ElementName;

            if (_element.Member.PathType != CRefTypes.Error)
            {
                writer.WriteStartElement("see");

                if (entry != null)
                {
                    displayName = entry.Name;
                    writer.WriteAttributeString("id", entry.Key.ToString());
                    writer.WriteAttributeString("cref", _element.Member.ToString());

                    switch (_element.Member.PathType)
                    {
                        case CRefTypes.Namespace:
                            writer.WriteAttributeString("type", "namespace");
                            writer.WriteAttributeString("name", displayName);
                            break;
                        // these could be generic and so will need to modify to
                        // a more appropriate display name
                        case CRefTypes.Method:
                            MethodDef method = entry.Item as MethodDef;
                            if (method != null)
                            {
                                displayName = method.GetDisplayName(false);
                            }
                            break;
                        case CRefTypes.Type:
                            TypeDef def = entry.Item as TypeDef;
                            if (def != null)
                            {
                                displayName = def.GetDisplayName(false);
                            }
                            break;
                    }
                }

                writer.WriteString(displayName);
                writer.WriteEndElement();   // element
            }
        }

19 Source : TypeMembersXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            writer.WriteStartDoreplacedent();

            writer.WriteStartElement("members");
            writer.WriteAttributeString("id", this.replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", this.replacedociatedEntry.SubKey);
            WriteCref(this.replacedociatedEntry, writer);

            string typeDisplayName = _containingType.GetDisplayName(false);
            string pageDisplayName = $"{typeDisplayName} {this.replacedociatedEntry.Name}";
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(pageDisplayName));
            writer.WriteAttributeString("type", typeDisplayName);
            writer.WriteString(pageDisplayName);
            writer.WriteEndElement();

            // we need to write the entries that appear as children to this doreplacedent map
            // entry. it is going to be easier to use the Entry elements
            writer.WriteStartElement("entries");
            switch (replacedociatedEntry.SubKey.ToLower())
            {
                case "properties":
                case "fields":
                case "constants":
                case "operators":
                case "constructors":
                    foreach (Entry current in replacedociatedEntry.Children)
                    {
                        ReflectedMember m = current.Item as ReflectedMember;
                        this.WriteEntry(writer, m, ReflectionHelper.GetDisplayName(m));
                    }
                    break;

                case "methods":
                    // write normal methods
                    foreach (Entry current in replacedociatedEntry.Children)
                    {
                        ReflectedMember m = current.Item as ReflectedMember;
                        WriteEntry(writer, m, ReflectionHelper.GetDisplayName(m));
                    }
                    // write extension methods
                    var extensionMethods = from method in ((TypeRef)replacedociatedEntry.Parent.Item).ExtensionMethods
                                           orderby method.Name
                                           select method;
                    foreach (MethodDef currentMethod in extensionMethods)
                    {
                        DisplayNameSignitureConvertor displayNameSig = new DisplayNameSignitureConvertor(currentMethod, false, true, true);
                        WriteEntry(writer, currentMethod, currentMethod.GetDisplayName(false, true), "extensionmethod");
                    }
                    break;
            }
            writer.WriteEndElement(); // entries
            writer.WriteEndElement();
            writer.WriteEndDoreplacedent();
        }

19 Source : TypeMembersXmlRenderer.cs
with MIT License
from barry-jones

private void WriteEntry(System.Xml.XmlWriter writer, ReflectedMember entryMember, string displayName, string type)
        {
            CRefPath currentPath = CRefPath.Create(entryMember);
            XmlCodeComment currentComment = _xmlComments.GetComment(currentPath);

            writer.WriteStartElement("entry");
            writer.WriteAttributeString("id", entryMember.GetGloballyUniqueId().ToString());
            writer.WriteAttributeString("subId", string.Empty);
            writer.WriteAttributeString("type", type);
            writer.WriteAttributeString("visibility", ReflectionHelper.GetVisibility(entryMember));
            writer.WriteAttributeString("cref", currentPath.ToString());

            writer.WriteStartElement("name");
            writer.WriteString(displayName);
            writer.WriteEndElement();

            // find and output the summary
            if (currentComment != XmlCodeComment.Empty && currentComment.Elements != null)
            {
                XmlCodeElement summary = currentComment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    Serialize(summary, writer);
                }
            }
            writer.WriteEndElement();
        }

19 Source : TypeXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath crefPath = new CRefPath(_member);
            XmlCodeComment comment = _xmlComments.GetComment(crefPath);

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", this.replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", this.replacedociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            WriteCref(replacedociatedEntry, writer);

            writer.WriteStartElement("replacedembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.replacedembly.FileName));
            writer.WriteString(_member.replacedembly.Name);
            writer.WriteEndElement();

            string displayName = _member.GetDisplayName(false);
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(displayName));
            writer.WriteString(displayName);
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = this.replacedociatedEntry.FindNamespace(_member.Namespace);
            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.Namespace}");
            writer.WriteString(_member.Namespace);
            writer.WriteEndElement();

            if (_member.IsGeneric)
            {
                RenderGenericTypeParameters(_member.GenericTypes, writer, comment);
            }

            // find and output the summary
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement summary = comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    this.Serialize(summary, writer);
                }
            }

            RenderSyntaxBlocks(_member, writer);
            RenderPermissionBlock(_member, writer, comment);

            // find and output the remarks
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            // find and output the examples
            if (comment != XmlCodeComment.Empty)
            {
                XmlCodeElement remarks = comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement);
                if (remarks != null)
                {
                    Serialize(remarks, writer);
                }
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            if (_member.IsEnumeration)
            {
                writer.WriteStartElement("values");
                List<FieldDef> fields = _member.Fields;
                for (int i = 0; i < fields.Count; i++)
                {
                    if (fields[i].IsSystemGenerated)
                        continue;
                    CRefPath currentPath = CRefPath.Create(fields[i]);
                    XmlCodeComment currentComment = _xmlComments.GetComment(currentPath);

                    writer.WriteStartElement("value");
                    writer.WriteStartElement("name");
                    writer.WriteString(fields[i].Name);
                    writer.WriteEndElement();
                    writer.WriteStartElement("description");
                    if (currentComment != XmlCodeComment.Empty && currentComment.Elements != null)
                    {
                        XmlCodeElement summary = currentComment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                        if (summary != null)
                        {
                            Serialize(summary, writer);
                        }
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else
            {
                if (_member.HasMembers)
                {
                    OutputMembers(writer);
                }
            }

            if (!_member.IsDelegate && !_member.IsEnumeration && !_member.IsInterface && !_member.IsStructure)
            {
                AddInheritanceTree(_member, writer);
            }

            writer.WriteEndElement();   // member
        }

19 Source : XmlRenderer.cs
with MIT License
from barry-jones

protected virtual void RenderExceptionBlock(ReflectedMember member, System.Xml.XmlWriter writer, XmlCodeComment comment)
        {
            // output doreplacedentation for expected exceptions if they are defined
            if (comment != XmlCodeComment.Empty)
            {
                List<XmlCodeElement> exceptions = comment.Elements.FindAll(node => node is ExceptionXmlCodeElement);
                if (exceptions != null && exceptions.Count > 0)
                {
                    writer.WriteStartElement("exceptions");
                    for (int i = 0; i < exceptions.Count; i++)
                    {
                        ExceptionXmlCodeElement current = (ExceptionXmlCodeElement)exceptions[i];
                        string exceptionName = string.Empty;
                        ReflectedMember found = null;

                        if (current.Member.PathType != CRefTypes.Error)
                        {
                            TypeDef def = member.replacedembly.FindType(current.Member.Namespace, current.Member.TypeName);
                            exceptionName = string.Format("{0}.{1}", current.Member.Namespace, current.Member.TypeName);

                            if (def != null)
                            {
                                found = def;
                                switch (current.Member.PathType)
                                {
                                    // these elements are named and the type of element will
                                    // not modify how it should be displayed
                                    case CRefTypes.Field:
                                    case CRefTypes.Property:
                                    case CRefTypes.Event:
                                    case CRefTypes.Namespace:
                                        break;

                                    // these could be generic and so will need to modify to
                                    // a more appropriate display name
                                    case CRefTypes.Method:
                                        MethodDef method = current.Member.FindIn(def) as MethodDef;
                                        if (method != null)
                                        {
                                            found = method;
                                            exceptionName = method.GetDisplayName(false);
                                        }
                                        break;
                                    case CRefTypes.Type:
                                        exceptionName = def.GetDisplayName(false);
                                        break;
                                }
                            }
                        }

                        writer.WriteStartElement("exception");
                        writer.WriteStartElement("name");
                        if (found != null)
                        {
                            writer.WriteAttributeString("key", found.GetGloballyUniqueId().ToString());
                            writer.WriteAttributeString("cref", current.Member.ToString());
                        }
                        writer.WriteString(exceptionName);
                        writer.WriteEndElement();
                        writer.WriteStartElement("condition");
                        for (int j = 0; j < current.Elements.Count; j++)
                        {
                            this.Serialize(current.Elements[j], writer);
                        }
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }
            }
        }

19 Source : XmlRenderer.cs
with MIT License
from barry-jones

protected virtual void RenderGenericTypeParameters(List<GenericTypeRef> genericTypes, System.Xml.XmlWriter writer, XmlCodeComment comment)
        {
            writer.WriteStartElement("genericparameters");
            for (int i = 0; i < genericTypes.Count; i++)
            {
                writer.WriteStartElement("parameter");
                writer.WriteElementString("name", genericTypes[i].Name);
                writer.WriteStartElement("description");
                // find and output the summary
                if (comment != XmlCodeComment.Empty)
                {
                    XmlCodeElement paramEntry = comment.Elements.Find(currentBlock =>
                        currentBlock is TypeParamXmlCodeElement
                        && ((TypeParamXmlCodeElement)currentBlock).Name == genericTypes[i].Name);
                    if (paramEntry != null)
                    {
                        writer.WriteString(paramEntry.Text);
                    }
                }
                writer.WriteEndElement(); // description
                writer.WriteEndElement(); // parameter
            }
            writer.WriteEndElement();
        }

19 Source : XmlRenderer.cs
with MIT License
from barry-jones

protected void Serialize(XmlCodeElement comment, System.Xml.XmlWriter writer)
        {
            if (comment != XmlCodeComment.Empty)
            {
                if (XmlElementRenderer.IsHandled(comment))
                {
                    XmlRenderer renderer = XmlElementRenderer.Create(this, this.replacedociatedEntry, comment);
                    renderer.Render(writer);
                }
                else
                {
                    if (comment is XmlContainerCodeElement)
                    {
                        writer.WriteStartElement(comment.Element.ToString().ToLower());
                        foreach (XmlCodeElement element in ((XmlContainerCodeElement)comment).Elements)
                        {
                            this.Serialize(element, writer);
                        }
                        writer.WriteEndElement();
                    }
                    else
                    {
                        writer.WriteStartElement(comment.Element.ToString().ToLower());
                        writer.WriteString(comment.Text);
                        writer.WriteEndElement();
                    }
                }
            }
        }

19 Source : IndexXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(XmlWriter writer)
        {
            writer.WriteStartDoreplacedent();
            writer.WriteStartElement("frontpage");
            writer.WriteAttributeString("id", "0");
            writer.WriteAttributeString("subId", string.Empty);

            writer.WriteStartElement("replacedle");
            writer.WriteString("Doreplacedentation produced by Live Doreplacedenter");
            writer.WriteEndElement();

            // write all the namespaces
            writer.WriteStartElement("namespaces");
            foreach (Entry current in _doreplacedentMap)
            {
                writer.WriteStartElement("namespace");
                writer.WriteAttributeString("key", current.Key.ToString());
                writer.WriteAttributeString("subkey", current.SubKey);

                writer.WriteStartElement("name");
                writer.WriteString(current.Name);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.WriteEndDoreplacedent();
        }

19 Source : IndexXmlRenderer.cs
with MIT License
from barry-jones

private void Render(Entry entry, System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("item");
            writer.WriteAttributeString("name", entry.Name);
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(entry.Name));
            writer.WriteAttributeString("key", entry.Key.ToString());
            writer.WriteAttributeString("subkey", entry.SubKey);

            foreach (Entry child in entry.Children)
            {
                this.Render(child, writer);
            }

            writer.WriteEndElement();
        }

19 Source : ProjectXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(XmlWriter writer)
        {
            writer.WriteStartDoreplacedent();
            writer.WriteStartElement("project");

            writer.WriteElementString("contentsfile", "toc.hhc");
            writer.WriteElementString("indexfile", "index.hhk");
            writer.WriteElementString("replacedle", "Test");
            Entry firstEntry = this.doreplacedentMap.First();
            writer.WriteElementString("defaulttopic", string.Format("{0}-{1}.htm", firstEntry.Key, firstEntry.SubKey));

            writer.WriteEndElement(); // project
            writer.WriteEndDoreplacedent();
        }

19 Source : DocumentMapXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("toc");

            foreach (Entry current in _doreplacedentMap)
            {
                writer.WriteStartElement("item");
                writer.WriteAttributeString("name", current.Name);
                if (_includeSafeName)
                    writer.WriteAttributeString("safename", Exporter.CreateSafeName(current.Name));
                writer.WriteAttributeString("key", current.Key.ToString());
                writer.WriteAttributeString("subkey", current.SubKey);
                WriteCref(current, writer);

                foreach (Entry child in current.Children)
                {
                    Render(child, writer);
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }

19 Source : MethodXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            CRefPath crefPath = new CRefPath(_member);
            XmlCodeComment comment = _xmlComments.GetComment(crefPath);
            string displayName = _member.GetDisplayName(false);

            writer.WriteStartElement("member");
            writer.WriteAttributeString("id", replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", replacedociatedEntry.SubKey);
            writer.WriteAttributeString("type", ReflectionHelper.GetType(_member));
            writer.WriteAttributeString("cref", crefPath.ToString());
            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(displayName));
            writer.WriteString(_member.GetDisplayName(false));
            writer.WriteEndElement();

            writer.WriteStartElement("namespace");
            Entry namespaceEntry = replacedociatedEntry.FindNamespace(_member.Type.Namespace);
            writer.WriteAttributeString("id", namespaceEntry.Key.ToString());
            writer.WriteAttributeString("name", namespaceEntry.SubKey);
            writer.WriteAttributeString("cref", $"N:{_member.Type.Namespace}");
            writer.WriteString(_member.Type.Namespace);
            writer.WriteEndElement();
            writer.WriteStartElement("replacedembly");
            writer.WriteAttributeString("file", System.IO.Path.GetFileName(_member.replacedembly.FileName));
            writer.WriteString(_member.replacedembly.Name);
            writer.WriteEndElement();

            if (_member.IsGeneric)
            {
                RenderGenericTypeParameters(_member.GetGenericTypes(), writer, comment);
            }

            RenderParameters(writer, comment);
            RenderExceptionBlock(_member, writer, comment);
            RenderPermissionBlock(_member, writer, comment);

            if (comment != XmlCodeComment.Empty)
            {
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement));
            }

            RenderSyntaxBlocks(_member, writer);
            RenderReturnsBlock(writer, comment);

            if (comment != XmlCodeComment.Empty)
            {
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is RemarksXmlCodeElement));
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is ExampleXmlCodeElement));
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is SeeAlsoXmlCodeElement));
            }

            RenderSeeAlsoBlock(_member, writer, comment);

            writer.WriteEndElement();
        }

19 Source : MethodXmlRenderer.cs
with MIT License
from barry-jones

private void RenderReturnsBlock(System.Xml.XmlWriter writer, XmlCodeComment comment)
        {
            TypeRef returnTypeRef = _member.GetReturnType();

            if (returnTypeRef == WellKnownTypeDef.Void)
                return;

            writer.WriteStartElement("return");

            // write the details of the type and link details if available
            writer.WriteStartElement("type");
            TypeDef foundEntry = _member.replacedembly.FindType(returnTypeRef.Namespace, returnTypeRef.Name);

            writer.WriteAttributeString("name", returnTypeRef.GetDisplayName(false));
            if (foundEntry != null)
            {
                writer.WriteAttributeString("key", foundEntry.GetGloballyUniqueId().ToString());
                writer.WriteAttributeString("cref", CRefPath.Create(foundEntry).ToString());
            }
            writer.WriteEndElement();

            // output the returns comment xml element if available
            if (comment != XmlCodeComment.Empty)
            {
                RenderXmlBlock(writer, comment.Elements.Find(currentBlock => currentBlock is ReturnsXmlCodeElement));
            }

            writer.WriteEndElement();
        }

19 Source : NamespaceContainerXmlRenderer.cs
with MIT License
from barry-jones

public override void Render(System.Xml.XmlWriter writer)
        {
            writer.WriteStartElement("namespaces");
            writer.WriteAttributeString("id", replacedociatedEntry.Key.ToString());
            writer.WriteAttributeString("subId", replacedociatedEntry.SubKey);
            this.WriteCref(replacedociatedEntry, writer);

            writer.WriteStartElement("name");
            writer.WriteAttributeString("safename", Exporter.CreateSafeName(replacedociatedEntry.Name));
            writer.WriteString(replacedociatedEntry.Name);
            writer.WriteEndElement();

            foreach (Entry current in replacedociatedEntry.Children)
            {
                writer.WriteStartElement("entry");
                writer.WriteAttributeString("name", current.Name);
                writer.WriteAttributeString("key", current.Key.ToString());
                writer.WriteAttributeString("subkey", current.SubKey);
                writer.WriteAttributeString("type", "namespace");
                WriteCref(current, writer);

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }

19 Source : TypeXmlRenderer.cs
with MIT License
from barry-jones

private void OutputMembers(System.Xml.XmlWriter writer)
        {
            if (this.replacedociatedEntry.Children.Count == 0) return;

            writer.WriteStartElement("entries");
            List<Entry> children = replacedociatedEntry.Children;

            Entry constructors = children.Find(entry => entry.Name == "Constructors");
            if (constructors != null)
            {
                var s = from child in constructors.Children orderby child.Name select child;
                foreach (Entry current in s)
                {
                    MethodDef currentMember = (MethodDef)current.Item;
                    WriteEntry(writer, currentMember, currentMember.GetDisplayName(false, true));
                }
            }

            Entry fields = children.Find(entry => entry.Name == "Fields");
            if (fields != null)
            {
                var s = from child in fields.Children orderby child.Name select child;
                foreach (Entry current in s)
                {
                    FieldDef currentMember = (FieldDef)current.Item;
                    WriteEntry(writer, currentMember, currentMember.Name);
                }
            }

            Entry properties = children.Find(entry => entry.Name == "Properties");
            if (properties != null)
            {
                var s = from child in properties.Children orderby child.Name select child;
                foreach (Entry current in s)
                {
                    PropertyDef currentMember = current.Item as PropertyDef;
                    WriteEntry(writer, currentMember, new DisplayNameSignitureConvertor(currentMember, false, true).Convert());
                }
            }

            Entry events = children.Find(entry => entry.Name == "Events");
            if (events != null)
            {
                var s = from child in events.Children orderby child.Name select child;
                foreach (Entry current in s)
                {
                    EventDef currentMember = (EventDef)current.Item;
                    WriteEntry(writer, currentMember, currentMember.Name);
                }
            }

            Entry methods = children.Find(entry => entry.Name == "Methods");
            if (methods != null)
            {
                var s = from child in methods.Children orderby child.Name select child;
                foreach (Entry current in s)
                {
                    MethodDef currentMember = (MethodDef)current.Item;
                    WriteEntry(writer, currentMember, currentMember.GetDisplayName(false, true));
                }
            }

            Entry operators = children.Find(entry => entry.Name == "Operators");
            if (operators != null)
            {
                var s = from child in operators.Children orderby child.Name select child;
                foreach (Entry current in s)
                {
                    MethodDef currentMember = (MethodDef)current.Item;
                    WriteEntry(writer, currentMember, currentMember.GetDisplayName(false));
                }
            }

            // I dont think we have any extension methods anymore - perhaps we can just delete this code?
            var extensionMethods = from method in this._member.ExtensionMethods orderby method.Name select method;
            foreach (MethodDef currentMethod in extensionMethods)
            {
                DisplayNameSignitureConvertor displayNameSig = new DisplayNameSignitureConvertor(currentMethod, false, true, true);
                WriteEntry(writer, currentMethod, currentMethod.GetDisplayName(false, true), "extensionmethod");
            }

            writer.WriteEndElement();
        }

19 Source : TypeXmlRenderer.cs
with MIT License
from barry-jones

private void WriteEntry(System.Xml.XmlWriter writer, ReflectedMember entryMember, string displayName, string type)
        {
            CRefPath currentPath = CRefPath.Create(entryMember);
            XmlCodeComment currentComment = this._xmlComments.GetComment(currentPath);

            writer.WriteStartElement("entry");
            writer.WriteAttributeString("id", entryMember.GetGloballyUniqueId().ToString());
            writer.WriteAttributeString("subId", string.Empty);
            writer.WriteAttributeString("type", type);
            writer.WriteAttributeString("visibility", ReflectionHelper.GetVisibility(entryMember));
            writer.WriteAttributeString("cref", currentPath.ToString());

            writer.WriteStartElement("name");
            writer.WriteString(displayName);
            writer.WriteEndElement();

            // find and output the summary
            if (currentComment != XmlCodeComment.Empty && currentComment.Elements != null)
            {
                XmlCodeElement summary = currentComment.Elements.Find(currentBlock => currentBlock is SummaryXmlCodeElement);
                if (summary != null)
                {
                    Serialize(summary, writer);
                }
            }
            writer.WriteEndElement();
        }

19 Source : TypeXmlRenderer.cs
with MIT License
from barry-jones

private void AddInheritanceTree(TypeDef type, System.Xml.XmlWriter writer)
        {
            List<TypeRef> reverseInheritanceTree = new List<TypeRef>();
            TypeRef parent = type.InheritsFrom;
            while (parent != null)
            {
                reverseInheritanceTree.Add(parent);

                // only add types that are referenced in the current library
                // TODO: for some types like system, we could link to MS website
                if (parent is TypeDef)
                {
                    parent = ((TypeDef)parent).InheritsFrom;
                }
                else
                {
                    parent = null;
                }
            }

            if (reverseInheritanceTree.Count > 0)
            {
                reverseInheritanceTree.Reverse();
                writer.WriteStartElement("inheritance");

                WriteType(0, reverseInheritanceTree, writer);

                writer.WriteEndElement(); // inheritance
            }
        }

19 Source : TypeXmlRenderer.cs
with MIT License
from barry-jones

private void WriteType(int index, List<TypeRef> tree, System.Xml.XmlWriter writer)
        {
            if (index < tree.Count)
            {
                writer.WriteStartElement("type");
                TypeRef current = tree[index];
                if (current is TypeDef)
                {   // only provide ids for internal clreplacedes
                    writer.WriteAttributeString("id", current.GetGloballyUniqueId().ToString());
                    writer.WriteAttributeString("cref", CRefPath.Create(current).ToString());
                }
                writer.WriteAttributeString("name", current.GetDisplayName(true));

                WriteType(++index, tree, writer);
                writer.WriteEndElement();
            }
            else if (index == tree.Count)
            {
                writer.WriteStartElement("type");
                writer.WriteAttributeString("current", "true");
                writer.WriteAttributeString("name", _member.GetDisplayName(true));
                WriteType(++index, tree, writer);
                writer.WriteEndElement();
            }
            else if (index > tree.Count)
            {
                foreach (TypeRef current in this._member.GetExtendingTypes())
                {
                    Entry found = this.Doreplacedent.Find(CRefPath.Create(current));
                    if (found != null)
                    {
                        writer.WriteStartElement("type");
                        if (current is TypeDef)
                        {   // only provide ids for internal clreplacedes not filtered
                            writer.WriteAttributeString("id", current.GetGloballyUniqueId().ToString());
                            writer.WriteAttributeString("cref", CRefPath.Create(current).ToString());
                        }
                        writer.WriteAttributeString("name", current.GetDisplayName(true));
                        writer.WriteEndElement();
                    }
                }
            }
        }

19 Source : XmlRenderer.cs
with MIT License
from barry-jones

protected virtual void RenderPermissionBlock(ReflectedMember member, System.Xml.XmlWriter writer, XmlCodeComment comment)
        {
            // output doreplacedentation for expected permissions if they are defined
            if (comment != XmlCodeComment.Empty)
            {
                List<XmlCodeElement> permissions = comment.Elements.FindAll(node => node is PermissionXmlCodeElement);
                if (permissions != null && permissions.Count > 0)
                {
                    writer.WriteStartElement("permissions");
                    for (int i = 0; i < permissions.Count; i++)
                    {
                        PermissionXmlCodeElement current = (PermissionXmlCodeElement)permissions[i];
                        string name = string.Empty;
                        ReflectedMember found = null;

                        if (current.Member.PathType != CRefTypes.Error)
                        {
                            TypeDef def = member.replacedembly.FindType(current.Member.Namespace, current.Member.TypeName);
                            name = string.Format("{0}.{1}", current.Member.Namespace, current.Member.TypeName);

                            if (def != null)
                            {
                                found = def;
                                switch (current.Member.PathType)
                                {
                                    // these elements are named and the type of element will
                                    // not modify how it should be displayed
                                    case CRefTypes.Field:
                                    case CRefTypes.Property:
                                    case CRefTypes.Event:
                                    case CRefTypes.Namespace:
                                        break;

                                    // these could be generic and so will need to modify to
                                    // a more appropriate display name
                                    case CRefTypes.Method:
                                        MethodDef method = current.Member.FindIn(def) as MethodDef;
                                        if (method != null)
                                        {
                                            found = method;
                                            name = method.GetDisplayName(false);
                                        }
                                        break;
                                    case CRefTypes.Type:
                                        name = def.GetDisplayName(false);
                                        break;
                                }
                            }
                        }

                        writer.WriteStartElement("permission");
                        writer.WriteStartElement("name");
                        if (found != null)
                        {
                            writer.WriteAttributeString("key", member.GetGloballyUniqueId().ToString());
                            writer.WriteAttributeString("cref", current.Member.ToString());
                        }
                        writer.WriteString(name);
                        writer.WriteEndElement();
                        writer.WriteStartElement("description");
                        for (int j = 0; j < current.Elements.Count; j++)
                        {
                            this.Serialize(current.Elements[j], writer);
                        }
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }
            }
        }

19 Source : XmlRenderer.cs
with MIT License
from barry-jones

protected void RenderSyntaxBlocks(ReflectedMember member, System.Xml.XmlWriter writer)
        {
            IFormatter formatter = SyntaxFactory.Create(member, Languages.CSharp);
            if (formatter != null)
            {
                writer.WriteStartElement("syntaxblocks");
                writer.WriteStartElement("syntax");
                writer.WriteAttributeString("language", "C#");

                foreach (SyntaxToken token in formatter.Format())
                {
                    writer.WriteStartElement(token.TokenType.ToString().ToLower());
                    writer.WriteString(token.Content);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        }

19 Source : XmlRenderer.cs
with MIT License
from barry-jones

protected void RenderSeeAlsoBlock(ReflectedMember member, System.Xml.XmlWriter writer, XmlCodeComment comment)
        {
            if (comment != XmlCodeComment.Empty)
            {
                List<XmlCodeElement> elements = comment.Elements.FindAll(e => e.Element == XmlCodeElements.SeeAlso);
                if (elements != null && elements.Count > 0)
                {
                    writer.WriteStartElement("seealsolist");
                    foreach (SeeAlsoXmlCodeElement current in elements)
                    {
                        string displayName = current.Member.TypeName;
                        Entry entry = this.Doreplacedent.Find(current.Member);

                        writer.WriteStartElement("seealso");
                        if (entry != null)
                        {
                            displayName = entry.Name;
                            ReflectedMember foundMember = entry.Item as ReflectedMember;
                            if (foundMember != null)
                            {
                                writer.WriteAttributeString("id", foundMember.GetGloballyUniqueId().ToString());
                                this.WriteCref(entry, writer);
                            }
                        }
                        writer.WriteString(displayName);
                        writer.WriteEndElement(); // seealso
                    }
                    writer.WriteEndElement(); // seealsolist
                }
            }
        }

19 Source : BasicDanmakuWriter.cs
with GNU General Public License v3.0
from Bililive

private static void WriteStartDoreplacedent(XmlWriter writer, IRoom room)
        {
            writer.WriteStartDoreplacedent();
            writer.WriteProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"#s\"");
            writer.WriteStartElement("i");
            writer.WriteComment("\nB站录播姬 " + GitVersionInformation.FullSemVer + "\n本文件的弹幕信息兼容B站主站视频弹幕XML格式\n本XML自带样式可以在浏览器里打开(推荐使用Chrome)\n\nsc 为SuperChat\ngift为礼物\nguard为上船\n\nattribute \"raw\" 为原始数据\n");
            writer.WriteElementString("chatserver", "chat.bilibili.com");
            writer.WriteElementString("chatid", "0");
            writer.WriteElementString("mission", "0");
            writer.WriteElementString("maxlimit", "1000");
            writer.WriteElementString("state", "0");
            writer.WriteElementString("real_name", "0");
            writer.WriteElementString("source", "0");

            writer.WriteStartElement("BililiveRecorder");
            writer.WriteAttributeString("version", GitVersionInformation.FullSemVer);
            writer.WriteEndElement();

            writer.WriteStartElement("BililiveRecorderRecordInfo");
            writer.WriteAttributeString("roomid", room.RoomConfig.RoomId.ToString());
            writer.WriteAttributeString("shortid", room.ShortId.ToString());
            writer.WriteAttributeString("name", RemoveInvalidXMLChars(room.Name));
            writer.WriteAttributeString("replacedle", RemoveInvalidXMLChars(room.replacedle));
            writer.WriteAttributeString("areanameparent", RemoveInvalidXMLChars(room.AreaNameParent));
            writer.WriteAttributeString("areanamechild", RemoveInvalidXMLChars(room.AreaNameChild));
            writer.WriteAttributeString("start_time", DateTimeOffset.Now.ToString("O"));
            writer.WriteEndElement();

            // see BililiveRecorder.ToolBox\Tool\DanmakuMerger\DanmakuMergerHandler.cs
            const string style = @"<z:stylesheet version=""1.0"" id=""s"" xml:id=""s"" xmlns:z=""http://www.w3.org/1999/XSL/Transform""><z:output method=""html""/><z:template match=""/""><html><meta name=""viewport"" content=""width=device-width""/><replacedle>B站录播姬弹幕文件 - <z:value-of select=""/i/BililiveRecorderRecordInfo/@name""/></replacedle><style>body{margin:0}h1,h2,p,table{margin-left:5px}table{border-spacing:0}td,th{border:1px solid grey;padding:1px}th{position:sticky;top:0;background:#4098de}tr:hover{background:#d9f4ff}div{overflow:auto;max-height:80vh;max-width:100vw;width:fit-content}</style><h1>B站录播姬弹幕XML文件</h1><p>本文件的弹幕信息兼容B站主站视频弹幕XML格式,可以使用现有的转换工具把文件中的弹幕转为replaced字幕文件</p><table><tr><td>录播姬版本</td><td><z:value-of select=""/i/BililiveRecorder/@version""/></td></tr><tr><td>房间号</td><td><z:value-of select=""/i/BililiveRecorderRecordInfo/@roomid""/></td></tr><tr><td>主播名</td><td><z:value-of select=""/i/BililiveRecorderRecordInfo/@name""/></td></tr><tr><td>录制开始时间</td><td><z:value-of select=""/i/BililiveRecorderRecordInfo/@start_time""/></td></tr><tr><td><a href=""#d"">弹幕</a></td><td>共 <z:value-of select=""count(/i/d)""/> 条记录</td></tr><tr><td><a href=""#guard"">上船</a></td><td>共 <z:value-of select=""count(/i/guard)""/> 条记录</td></tr><tr><td><a href=""#sc"">SC</a></td><td>共 <z:value-of select=""count(/i/sc)""/> 条记录</td></tr><tr><td><a href=""#gift"">礼物</a></td><td>共 <z:value-of select=""count(/i/gift)""/> 条记录</td></tr></table><h2 id=""d"">弹幕</h2><div><table><tr><th>用户名</th><th>弹幕</th><th>参数</th></tr><z:for-each select=""/i/d""><tr><td><z:value-of select=""@user""/></td><td><z:value-of select="".""/></td><td><z:value-of select=""@p""/></td></tr></z:for-each></table></div><h2 id=""guard"">舰长购买</h2><div><table><tr><th>用户名</th><th>舰长等级</th><th>购买数量</th><th>出现时间</th></tr><z:for-each select=""/i/guard""><tr><td><z:value-of select=""@user""/></td><td><z:value-of select=""@level""/></td><td><z:value-of select=""@count""/></td><td><z:value-of select=""@ts""/></td></tr></z:for-each></table></div><h2 id=""sc"">SuperChat 醒目留言</h2><div><table><tr><th>用户名</th><th>内容</th><th>显示时长</th><th>价格</th><th>出现时间</th></tr><z:for-each select=""/i/sc""><tr><td><z:value-of select=""@user""/></td><td><z:value-of select="".""/></td><td><z:value-of select=""@time""/></td><td><z:value-of select=""@price""/></td><td><z:value-of select=""@ts""/></td></tr></z:for-each></table></div><h2 id=""gift"">礼物</h2><div><table><tr><th>用户名</th><th>礼物名</th><th>礼物数量</th><th>出现时间</th></tr><z:for-each select=""/i/gift""><tr><td><z:value-of select=""@user""/></td><td><z:value-of select=""@giftname""/></td><td><z:value-of select=""@giftcount""/></td><td><z:value-of select=""@ts""/></td></tr></z:for-each></table></div></html></z:template></z:stylesheet>";

            writer.WriteStartElement("BililiveRecorderXmlStyle");
            writer.WriteRaw(style);
            writer.WriteEndElement();
            writer.Flush();
        }

19 Source : TraversalTree.cs
with MIT License
from BIMrxLAB

public void DumpIntoXML(XmlWriter writer)
        {
            // Write node information
            Element element = GetElementById(m_Id);
            FamilyInstance fi = element as FamilyInstance;
            if (fi != null)
            {
                MEPModel mepModel = fi.MEPModel;
                String type = String.Empty;
                if (mepModel is MechanicalEquipment)
                {
                    type = "MechanicalEquipment";
                    writer.WriteStartElement(type);
                }
                else if (mepModel is MechanicalFitting)
                {
                    MechanicalFitting mf = mepModel as MechanicalFitting;
                    type = "MechanicalFitting";
                    writer.WriteStartElement(type);
                    writer.WriteAttributeString("Category", element.Category.Name);
                    writer.WriteAttributeString("PartType", mf.PartType.ToString());
                }
                else
                {
                    type = "FamilyInstance";
                    writer.WriteStartElement(type);
                    writer.WriteAttributeString("Category", element.Category.Name);
                }

                writer.WriteAttributeString("Name", element.Name);
                writer.WriteAttributeString("Id", element.Id.IntegerValue.ToString());
                writer.WriteAttributeString("Direction", m_direction.ToString());
                writer.WriteEndElement();
            }
            else
            {
                String type = element.GetType().Name;

                writer.WriteStartElement(type);
                writer.WriteAttributeString("Name", element.Name);
                writer.WriteAttributeString("Id", element.Id.IntegerValue.ToString());
                writer.WriteAttributeString("Direction", m_direction.ToString());
                writer.WriteEndElement();
            }

            foreach (TreeNode node in m_childNodes)
            {
                if (m_childNodes.Count > 1)
                {
                    writer.WriteStartElement("Path");
                }

                node.DumpIntoXML(writer);

                if (m_childNodes.Count > 1)
                {
                    writer.WriteEndElement();
                }
            }
        }

19 Source : TraversalTree.cs
with MIT License
from BIMrxLAB

private void WriteBasicInfo(XmlWriter writer)
        {
            MechanicalSystem ms = null;
            PipingSystem ps = null;
            if (m_isMechanicalSystem)
            {
                ms = m_system as MechanicalSystem;
            }
            else
            {
                ps = m_system as PipingSystem;
            }

            // Write basic information of the system
            writer.WriteStartElement("BasicInformation");

            // Write Name property
            writer.WriteStartElement("Name");
            writer.WriteString(m_system.Name);
            writer.WriteEndElement();

            // Write Id property
            writer.WriteStartElement("Id");
            writer.WriteValue(m_system.Id.IntegerValue);
            writer.WriteEndElement();

            // Write UniqueId property
            writer.WriteStartElement("UniqueId");
            writer.WriteString(m_system.UniqueId);
            writer.WriteEndElement();

            // Write SystemType property
            writer.WriteStartElement("SystemType");
            if (m_isMechanicalSystem)
            {
                writer.WriteString(ms.SystemType.ToString());
            }
            else
            {
                writer.WriteString(ps.SystemType.ToString());
            }
            writer.WriteEndElement();

            // Write Category property
            writer.WriteStartElement("Category");
            writer.WriteAttributeString("Id", m_system.Category.Id.IntegerValue.ToString());
            writer.WriteAttributeString("Name", m_system.Category.Name);
            writer.WriteEndElement();

            // Write IsWellConnected property
            writer.WriteStartElement("IsWellConnected");
            if (m_isMechanicalSystem)
            {
                writer.WriteValue(ms.IsWellConnected);
            }
            else
            {
                writer.WriteValue(ps.IsWellConnected);
            }
            writer.WriteEndElement();

            // Write HasBaseEquipment property
            writer.WriteStartElement("HasBaseEquipment");
            bool hasBaseEquipment = ((m_system.BaseEquipment == null) ? false : true);
            writer.WriteValue(hasBaseEquipment);
            writer.WriteEndElement();

            // Write TerminalElementsCount property
            writer.WriteStartElement("TerminalElementsCount");
            writer.WriteValue(m_system.Elements.Size);
            writer.WriteEndElement();

            // Write Flow property
            //writer.WriteStartElement( "Flow" );
            //if( m_isMechanicalSystem )
            //{
            //  writer.WriteValue( ms.GetFlow() );
            //}
            //else
            //{
            //  writer.WriteValue( ps.GetFlow() );
            //}
            //writer.WriteEndElement();

            // Close basic information
            writer.WriteEndElement();
        }

19 Source : TraversalTree.cs
with MIT License
from BIMrxLAB

private void WritePaths(XmlWriter writer)
        {
            writer.WriteStartElement("Path");
            m_startingElementNode.DumpIntoXML(writer);
            writer.WriteEndElement();
        }

19 Source : TraversalTree.cs
with MIT License
from BIMrxLAB

public void DumpIntoXML(String fileName)
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.IndentChars = "    ";
            XmlWriter writer = XmlWriter.Create(fileName, settings);

            // Write the root element
            String mepSystemType = String.Empty;
            mepSystemType = (m_system is MechanicalSystem ? "MechanicalSystem" : "PipingSystem");
            writer.WriteStartElement(mepSystemType);

            // Write basic information of the MEP system
            WriteBasicInfo(writer);
            // Write paths of the traversal
            WritePaths(writer);

            // Close the root element
            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
        }

19 Source : EditorSettings.cs
with MIT License
from bonsai-rx

public void Save()
        {
            using (var writer = XmlWriter.Create(SettingsPath, new XmlWriterSettings { Indent = true }))
            {
                writer.WriteStartElement(typeof(EditorSettings).Name);
                writer.WriteElementString(WindowStateElement, WindowState.ToString());
                writer.WriteElementString(EditorThemeElement, EditorTheme.ToString());

                writer.WriteStartElement(DesktopBoundsElement);
                writer.WriteElementString(RectangleXElement, DesktopBounds.X.ToString(CultureInfo.InvariantCulture));
                writer.WriteElementString(RectangleYElement, DesktopBounds.Y.ToString(CultureInfo.InvariantCulture));
                writer.WriteElementString(RectangleWidthElement, DesktopBounds.Width.ToString(CultureInfo.InvariantCulture));
                writer.WriteElementString(RectangleHeightElement, DesktopBounds.Height.ToString(CultureInfo.InvariantCulture));
                writer.WriteEndElement();

                if (recentlyUsedFiles.Count > 0)
                {
                    writer.WriteStartElement(RecentlyUsedFilesElement);
                    foreach (var file in recentlyUsedFiles)
                    {
                        writer.WriteStartElement(RecentlyUsedFileElement);
                        writer.WriteElementString(FileTimestampElement, file.Timestamp.ToString("o"));
                        writer.WriteElementString(FileNameElement, file.FileName);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }
        }

19 Source : XmlnsIndentedWriter.cs
with MIT License
from bonsai-rx

public override void WriteEndElement()
        {
            writer.WriteEndElement();
        }

19 Source : SerializableDictionary.cs
with MIT License
from cabarius

public void WriteXml(XmlWriter writer) {
            XmlSerializer keySerializer = new(typeof(TKey));
            XmlSerializer valueSerializer = new(typeof(TValue));

            foreach (var key in Keys) {
                writer.WriteStartElement("item");

                writer.WriteStartElement("key");
                keySerializer.Serialize(writer, key);
                writer.WriteEndElement();

                writer.WriteStartElement("value");
                var value = this[key];
                valueSerializer.Serialize(writer, value);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }
        }

19 Source : SerializableDictionary.cs
with MIT License
from CslaGenFork

public void WriteXml(System.Xml.XmlWriter writer)
        {
            var keySerializer = new XmlSerializer(typeof (TKey));
            var valueSerializer = new XmlSerializer(typeof (TValue));

            foreach (var key in Keys)
            {
                writer.WriteStartElement("item");
                writer.WriteStartElement("key");
                keySerializer.Serialize(writer, key);
                writer.WriteEndElement();
                writer.WriteStartElement("value");
                var value = this[key];
                valueSerializer.Serialize(writer, value);
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        }

19 Source : Snapshot.cs
with MIT License
from dahall

void IXmlSerializable.WriteXml(XmlWriter writer)
		{
			writer.WriteAttributeString("timestamp", TimeStamp.ToString("o"));
			if (TargetServer != null)
				writer.WriteAttributeString("machine", TargetServer);
			writer.WriteAttributeString("version", "1.0");
			foreach (var i in items)
			{
				if (i is TaskSnapshot t)
				{
					writer.WriteStartElement("Task");
					writer.WriteAttributeString("path", t.Path);
					writer.WriteAttributeString("sddl", t.Sddl);
					if (!t.Enabled)
						writer.WriteAttributeString("enabled", "false");
					writer.WriteEndElement();
				}
				else if (i is TaskFolderSnapshot f)
				{
					writer.WriteStartElement("TaskFolder");
					writer.WriteAttributeString("path", f.Path);
					writer.WriteAttributeString("sddl", f.Sddl);
					writer.WriteEndElement();
				}
			}
		}

19 Source : XmlSerializationHelper.cs
with MIT License
from dahall

public static bool WriteProperty([NotNull] XmlWriter writer, [NotNull] PropertyInfo pi, [NotNull] Object obj, PropertyConversionHandler handler = null)
		{
			if (Attribute.IsDefined(pi, typeof(XmlIgnoreAttribute), false) || Attribute.IsDefined(pi, typeof(XmlAttributeAttribute), false))
				return false;

			object value = pi.GetValue(obj, null);
			object defValue = GetDefaultValue(pi);
			if ((value == null && defValue == null) || (value != null && value.Equals(defValue)))
				return false;

			Type propType = pi.PropertyType;
			if (handler != null && handler(pi, obj, ref value))
				propType = value.GetType();

			bool isStdType = IsStandardType(propType);
			bool rw = pi.CanRead && pi.CanWrite;
			bool ro = pi.CanRead && !pi.CanWrite;
			string eName = GetPropertyElementName(pi);
			if (isStdType && rw)
			{
				string output = GetXmlValue(value, propType);
				if (output != null)
					writer.WriteElementString(eName, output);
			}
			else if (!isStdType)
			{
				object outVal = null;
				if (propType.GetInterface("IXmlSerializable") == null && GetAttributeValue(pi, typeof(XmlArrayAttribute), "ElementName", true, ref outVal) && propType.GetInterface("IEnumerable") != null)
				{
					if (string.IsNullOrEmpty(outVal.ToString())) outVal = eName;
					writer.WriteStartElement(outVal.ToString());
					var attributes = Attribute.GetCustomAttributes(pi, typeof(XmlArrayItemAttribute), true);
					var dict = new Dictionary<Type, string>(attributes.Length);
					foreach (XmlArrayItemAttribute a in attributes)
						dict.Add(a.Type, a.ElementName);
					foreach (object item in ((System.Collections.IEnumerable)value))
					{
						string aeName;
						Type itemType = item.GetType();
						if (dict.TryGetValue(itemType, out aeName))
						{
							if (IsStandardType(itemType))
								writer.WriteElementString(aeName, GetXmlValue(item, itemType));
							else
								WriteObject(writer, item, null, false, aeName);
						}
					}
					writer.WriteEndElement();
				}
				else
					WriteObject(writer, value);
			}
			return false;
		}

See More Examples