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 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

object IXshdVisitor.VisitImport(XshdImport import)
		{
			_writer.WriteStartElement("Import", Namespace);
			WriteRuleSetReference(import.RuleSetReference);
			_writer.WriteEndElement();
			return null;
		}

19 View Source File : PSHelpGenerator.cs
License : Apache License 2.0
Project Creator : aws

private static void WriteDetails(XmlWriter psHelpWriter, CmdletAttribute cmdletAttribute, string typeDoreplacedentation, string cmdletName, string synopsis)
        {
            psHelpWriter.WriteStartElement("details");
            {
                psHelpWriter.WriteElementString("name", cmdletName);
                psHelpWriter.WriteStartElement("description");
                {
                    if (string.IsNullOrEmpty(synopsis))
                    {
                        synopsis = string.Format("{0}-{1}", cmdletAttribute.VerbName, cmdletAttribute.NounName);
                    }
                    psHelpWriter.WriteUnescapedElementString("para", synopsis);
                }
                psHelpWriter.WriteEndElement();

                psHelpWriter.WriteElementString("verb", cmdletAttribute.VerbName);
                psHelpWriter.WriteElementString("noun", cmdletAttribute.NounName);
                psHelpWriter.WriteStartElement("copyright");
                {
                    psHelpWriter.WriteElementString("para",
                                                    string.Format("© Copyright 2012 - {0} Amazon.com, Inc.or its affiliates.All Rights Reserved.",
                                                                  DateTime.UtcNow.Year));
                }
                psHelpWriter.WriteEndElement();
            }
            psHelpWriter.WriteEndElement();

            psHelpWriter.WriteStartElement("description");
            {
                psHelpWriter.WriteUnescapedElementString("para", typeDoreplacedentation);
            }
            psHelpWriter.WriteEndElement();
        }

19 View Source File : UriList.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            foreach (var el in this)
            {
                writer.WriteStartElement("Uri");
                writer.WriteAttributeString("AbsoluteUri", el.AbsoluteUri);
                writer.WriteEndElement();
            }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

object IXshdVisitor.VisitRule(XshdRule rule)
		{
			_writer.WriteStartElement("Rule", Namespace);
			WriteColorReference(rule.ColorReference);
			
			_writer.WriteString(rule.Regex);
			
			_writer.WriteEndElement();
			return null;
		}

19 View Source File : ProfileRefList.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            foreach (var el in this)
            {
                writer.WriteStartElement(nameof(ProfileRef));
                el.WriteXml(writer);
                writer.WriteEndElement();
            }
        }

19 View Source File : MinisignPublicKeyDictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            foreach (var el in this)
            {
                writer.WriteStartElement("PublicKey");
                using (var s = new MemoryStream(42))
                {
                    using (var w = new BinaryWriter(s))
                    {
                        w.Write('E');
                        w.Write('d');
                        w.Write(el.Key);
                        w.Write(el.Value);
                    }
                    writer.WriteBase64(s.GetBuffer(), 0, (int)s.Length);
                }
                writer.WriteEndElement();
            }
        }

19 View Source File : HelpGeneratorBase.cs
License : Apache License 2.0
Project Creator : aws

public static void WriteUnescapedElementString(this XmlWriter self, string localName, string value)
        {
            if (self == null) throw new ArgumentNullException("self");

            self.WriteStartElement(localName);
            var escapedString = EscapeString(value);
            self.WriteRaw(escapedString);
            self.WriteEndElement();
        }

protected override void WriteFileContent()
        {
            useLazyLoading = Settings.Default.DefaultLazyFetching;
            useLowercaseUnderscored = Settings.Default.UseUnderscoreAndLowercaseInDB;

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.NewLineOnAttributes = true;
            settings.Encoding = System.Text.Encoding.Unicode;

            ClreplacedType _clreplaced = (ClreplacedType)Type;
            
            if(_clreplaced.IdGenerator == null)
                idGeneratorType = EnumExtensions.GetDescription(Settings.Default.DefaultIdenreplacedyGenerator);
            else
                idGeneratorType = EnumExtensions.GetDescription((IdenreplacedyGeneratorType)Enum.Parse(typeof(IdenreplacedyGeneratorType), _clreplaced.IdGenerator));
            
            using (XmlWriter xml = XmlWriter.Create(CodeBuilder, settings))
            {
                xml.WriteStartDoreplacedent();
                xml.WriteComment(
                    string.Format(
                    " This code was generated by {0} ", 
                    GetVersionString()
                    ));
                xml.WriteStartElement("hibernate-mapping", "urn:nhibernate-mapping-2.2");
                xml.WriteAttributeString("replacedembly", ProjectName);
                xml.WriteAttributeString("namespace", RootNamespace);
                xml.WriteStartElement("clreplaced");
                xml.WriteAttributeString("name", _clreplaced.Name);
                xml.WriteAttributeString("table", 
                    string.Format("`{0}`",
                    PrefixedText(
                        useLowercaseUnderscored 
                        ? LowercaseAndUnderscoredWord(_clreplaced.Name) 
                        : string.IsNullOrEmpty(_clreplaced.NHMTableName)
                        ? _clreplaced.Name
                        : _clreplaced.NHMTableName
                    )));
                xml.WriteAttributeString("lazy", useLazyLoading.ToString().ToLower());

                List<Operation> ids = _clreplaced.Operations.Where(o => o is Property && o.IsIdenreplacedy).ToList<Operation>();

                if(ids.Count > 1)
                {
                    xml.WriteStartElement("composite-id");
                    foreach (var id in ids)
                    {
                        if(!string.IsNullOrEmpty(id.ManyToOne))
                        {
                            xml.WriteStartElement("key-many-to-one");
                            xml.WriteAttributeString("name", id.Name);
                            xml.WriteAttributeString("column",
                                string.Format("`{0}`",
                                    useLowercaseUnderscored
                                    ? LowercaseAndUnderscoredWord(id.Name)
                                    : string.IsNullOrEmpty(id.NHMColumnName)
                                    ? id.Name
                                    : id.NHMColumnName
                                ));
                            xml.WriteAttributeString("clreplaced", id.Type);
                            xml.WriteEndElement();
                        }
                        else
                        {
                            xml.WriteStartElement("key-property");
                            xml.WriteAttributeString("name", id.Name);
                            xml.WriteAttributeString("column",
                                string.Format("`{0}`",
                                    useLowercaseUnderscored
                                    ? LowercaseAndUnderscoredWord(id.Name)
                                    : string.IsNullOrEmpty(id.NHMColumnName)
                                    ? id.Name
                                    : id.NHMColumnName
                                ));
                            xml.WriteAttributeString("type", id.Type);
                            xml.WriteEndElement();
                        }
                    }
                    xml.WriteEndElement();
                }
                else if (ids.Count == 1)
                {
                    xml.WriteStartElement("id");
                    xml.WriteAttributeString("name", ids[0].Name);
                    xml.WriteAttributeString("column",
                        string.Format("`{0}`",
                            useLowercaseUnderscored
                            ? LowercaseAndUnderscoredWord(ids[0].Name)
                            : string.IsNullOrEmpty(ids[0].NHMColumnName)
                            ? ids[0].Name
                            : ids[0].NHMColumnName
                        ));
                    xml.WriteAttributeString("type", ids[0].Type);
                    xml.WriteStartElement("generator");
                    
                    if (_clreplaced.IdGenerator != "Custom")
                        xml.WriteAttributeString("clreplaced", idGeneratorType);

                    if (_clreplaced.IdGenerator == "HiLo")
                    {
                        HiLoIdenreplacedyGeneratorParameters hiLo = GeneratorParametersDeSerializer.Deserialize<HiLoIdenreplacedyGeneratorParameters>(_clreplaced.GeneratorParameters);
                        
                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "table");
                        xml.WriteValue(hiLo.Table);
                        xml.WriteEndElement();

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "column");
                        xml.WriteValue(hiLo.Column);
                        xml.WriteEndElement();

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "max_lo");
                        xml.WriteValue(hiLo.MaxLo);
                        xml.WriteEndElement();

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "where");
                        xml.WriteValue(hiLo.Where);
                        xml.WriteEndElement();
                    }
                    else if (_clreplaced.IdGenerator == "SeqHiLo")
                    {
                        SeqHiLoIdenreplacedyGeneratorParameters seqHiLo = GeneratorParametersDeSerializer.Deserialize<SeqHiLoIdenreplacedyGeneratorParameters>(_clreplaced.GeneratorParameters);

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "sequence");
                        xml.WriteValue(seqHiLo.Sequence);
                        xml.WriteEndElement();

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "max_lo");
                        xml.WriteValue(seqHiLo.MaxLo);
                        xml.WriteEndElement();
                    }
                    else if (_clreplaced.IdGenerator == "Sequence")
                    {
                        SequenceIdenreplacedyGeneratorParameters sequence = GeneratorParametersDeSerializer.Deserialize<SequenceIdenreplacedyGeneratorParameters>(_clreplaced.GeneratorParameters);

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "sequence");
                        xml.WriteValue(sequence.Sequence);
                        xml.WriteEndElement();
                    }
                    else if (_clreplaced.IdGenerator == "UuidHex")
                    {
                        UuidHexIdenreplacedyGeneratorParameters uuidHex = GeneratorParametersDeSerializer.Deserialize<UuidHexIdenreplacedyGeneratorParameters>(_clreplaced.GeneratorParameters);

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "format_value");
                        xml.WriteValue(uuidHex.Format);
                        xml.WriteEndElement();

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "separator_value");
                        xml.WriteValue(uuidHex.Separator);
                        xml.WriteEndElement();
                    }
                    else if (_clreplaced.IdGenerator == "Foreign")
                    {
                        ForeignIdenreplacedyGeneratorParameters foreign = GeneratorParametersDeSerializer.Deserialize<ForeignIdenreplacedyGeneratorParameters>(_clreplaced.GeneratorParameters);

                        xml.WriteStartElement("param");
                        xml.WriteAttributeString("name", "property");
                        xml.WriteValue(foreign.Property);
                        xml.WriteEndElement();
                    }
                    else if (_clreplaced.IdGenerator == "Custom")
                    {
                        CustomIdenreplacedyGeneratorParameters custom = GeneratorParametersDeSerializer.Deserialize<CustomIdenreplacedyGeneratorParameters>(_clreplaced.GeneratorParameters);

                        xml.WriteAttributeString("clreplaced", custom.Clreplaced);

                        foreach(var param in custom.Parameters)
                        {
                            xml.WriteStartElement("param");
                            xml.WriteAttributeString("name", param.Name);
                            xml.WriteValue(param.Value);
                            xml.WriteEndElement();
                        }
                    }

                    xml.WriteEndElement();
                    xml.WriteEndElement();
                }

                foreach (var property in _clreplaced.Operations.Where(o => o is Property && !o.IsIdenreplacedy).ToList<Operation>())
                {
                    if (!string.IsNullOrEmpty(property.ManyToOne))
                    {
                        xml.WriteStartElement("many-to-one");
                        xml.WriteAttributeString("name", property.Name);
                        xml.WriteAttributeString("clreplaced", property.Type);
                        xml.WriteAttributeString("column",
                            string.Format("`{0}`",
                                useLowercaseUnderscored
                                ? LowercaseAndUnderscoredWord(property.Name)
                                : string.IsNullOrEmpty(property.NHMColumnName)
                                ? property.Name
                                : property.NHMColumnName
                            ));
                        
                        if (property.IsUnique)
                            xml.WriteAttributeString("unique", "true");
                        
                        xml.WriteAttributeString("not-null", property.IsNotNull.ToString().ToLower());
                        xml.WriteEndElement();
                    }
                    else
                    {
                        xml.WriteStartElement("property");
                        xml.WriteAttributeString("name", property.Name);
                        xml.WriteAttributeString("column",
                            string.Format("`{0}`",
                                useLowercaseUnderscored
                                ? LowercaseAndUnderscoredWord(property.Name)
                                : string.IsNullOrEmpty(property.NHMColumnName)
                                ? property.Name
                                : property.NHMColumnName
                            ));
                        xml.WriteAttributeString("type", property.Type);

                        if (property.IsUnique)
                            xml.WriteAttributeString("unique", "true");

                        xml.WriteAttributeString("not-null", property.IsNotNull.ToString().ToLower());
                        xml.WriteEndElement();
                    }
                }

                xml.WriteEndElement();
                xml.WriteEndElement();
                xml.WriteEndDoreplacedent();
            }
        }

19 View Source File : PSHelpGenerator.cs
License : Apache License 2.0
Project Creator : aws

private static void WriteParameters(XmlWriter writer, string cmdletName, IEnumerable<SimplePropertyInfo> allProperties)
        {
            writer.WriteStartElement("parameters");
            {
                // Microsoft cmdlets list the parameters in alpha order here, so do the same (leaving metadata/paging
                // params in the correct order)
                foreach (var property in allProperties.OrderBy(p => p.Name))
                {
                    writer.WriteStartElement("parameter");
                    {
                        InspectParameter(property, out var isRequiredForParametersets, out var pipelineInput, out var position, out var aliases);
                        var isRequiredForCurrentParameterset = isRequiredForParametersets?.Count == 0;

                        writer.WriteAttributeString("required", isRequiredForCurrentParameterset.ToString());
                        writer.WriteAttributeString("variableLength", "false");
                        writer.WriteAttributeString("globbing", "false");
                        writer.WriteAttributeString("pipelineInput", pipelineInput);
                        writer.WriteAttributeString("position", position);

                        writer.WriteElementString("name", property.Name);
                        writer.WriteStartElement("description");
                        {
                            writer.WriteRawElementString("para", property.PowershellDoreplacedentation);
                        }
                        writer.WriteEndElement();

                        writer.WriteStartElement("parameterValue");
                        {
                            writer.WriteAttributeString("required", "true");
                            writer.WriteAttributeString("variableLength", "false");
                            writer.WriteString(property.PropertyTypeName);
                        }
                        writer.WriteEndElement();

                        writer.WriteStartElement("type");
                        {
                            writer.WriteElementString("name", property.PropertyTypeName);
                            writer.WriteElementString("uri", string.Empty);
                        }
                        writer.WriteEndElement();

                        writer.WriteElementString("defaultValue", "None");
                    }
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
        }

19 View Source File : USPSProvider.cs
License : MIT License
Project Creator : alexeybusygin

public async Task GetRates(bool baseRatesOnly)
        {
            // USPS only available for domestic addresses. International is a different API.
            if (!IsDomesticUSPSAvailable())
            {
                return;
            }

            var sb = new StringBuilder();
            var specialServices = GetSpecialServicesForShipment(Shipment);

            var settings = new XmlWriterSettings
            {
                Indent = false,
                OmitXmlDeclaration = true,
                NewLineHandling = NewLineHandling.None
            };

            using (var writer = XmlWriter.Create(sb, settings))
            {
                writer.WriteStartElement("RateV4Request");
                writer.WriteAttributeString("USERID", _userId);
                if (!baseRatesOnly)
                {
                    writer.WriteElementString("Revision", "2");
                }
                var i = 0;
                foreach (var package in Shipment.Packages)
                {
                    string size;
                    var container = package.Container;
                    if (IsPackageLarge(package))
                    {
                        size = "LARGE";
                        // Container must be RECTANGULAR or NONRECTANGULAR when SIZE is LARGE
                        if (container == null || container.ToUpperInvariant() != "NONRECTANGULAR")
                        {
                            container = "RECTANGULAR";
                        }
                    }
                    else
                    {
                        size = "REGULAR";
                        if (container == null)
                        {
                            container = string.Empty;
                        }
                    }

                    writer.WriteStartElement("Package");
                    writer.WriteAttributeString("ID", i.ToString());
                    writer.WriteElementString("Service", _service);
                    writer.WriteElementString("ZipOrigination", Shipment.OriginAddress.CountryCode == "US" && Shipment.OriginAddress.PostalCode.Length > 5? Shipment.OriginAddress.PostalCode.Substring(0, 5) : Shipment.OriginAddress.PostalCode);
                    writer.WriteElementString("ZipDestination", Shipment.DestinationAddress.CountryCode == "US" && Shipment.DestinationAddress.PostalCode.Length > 5 ? Shipment.DestinationAddress.PostalCode.Substring(0, 5) : Shipment.DestinationAddress.PostalCode);
                    writer.WriteElementString("Pounds", package.PoundsAndOunces.Pounds.ToString());
                    writer.WriteElementString("Ounces", package.PoundsAndOunces.Ounces.ToString());

                    writer.WriteElementString("Container", container);
                    writer.WriteElementString("Size", size);
                    writer.WriteElementString("Width", package.RoundedWidth.ToString());
                    writer.WriteElementString("Length", package.RoundedLength.ToString());
                    writer.WriteElementString("Height", package.RoundedHeight.ToString());
                    writer.WriteElementString("Girth", package.CalculatedGirth.ToString());
                    writer.WriteElementString("Value", package.InsuredValue.ToString());
                    if (RequiresMachinable(_service))
                    {
                        writer.WriteElementString("Machinable", IsPackageMachinable(package).ToString());
                    }
                    if (Shipment.Options.ShippingDate != null)
                    {
                        writer.WriteElementString("ShipDate",
                            Shipment.Options.ShippingDate.Value.ToString("yyyy-MM-dd"));
                    }

                    if (AllowsSpecialServices(_service) && specialServices.Any())
                    {
                        writer.WriteStartElement("SpecialServices");
                        foreach (var service in specialServices)
                        {
                            writer.WriteElementString("SpecialService", ((int)service).ToString());
                        }
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                    i++;
                }

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

            try
            {
                using (var httpClient = new HttpClient())
                {
                    var rateUri = new Uri($"{ProductionUrl}?API=RateV4&XML={sb}");
                    var response = await httpClient.GetStringAsync(rateUri).ConfigureAwait(false);

                    ParseResult(response, specialServices);
                }
            }
            catch (Exception ex)
            {
                AddInternalError($"USPS provider exception: {ex.Message}");
            }
        }

19 View Source File : ElementInfo.cs
License : MIT License
Project Creator : Arkhist

public void WriteToXML(XmlWriter writer)
        {
            writer.WriteStartElement(Name, "");
            foreach (var attr in Attributes)
                writer.WriteAttributeString(attr.Key, attr.Value);
            if (Content == null)
            {
                foreach (var child in Children)
                    child.WriteToXML(writer);
            }
            else
            {
                writer.WriteValue(Content);
            }
            writer.WriteEndElement();
        }

19 View Source File : WrapperProject.cs
License : MIT License
Project Creator : AndresTraks

public void WriteSourceItemXml(XmlWriter writer, SourceItemDefinition item, string xmlFilePath = "")
        {
            string name = item.IsFolder
                ? ((item is RootFolderDefinition) ? "RootFolder" : "Folder")
                : "Header";

            writer.WriteStartElement(name);
            if (item == RootFolder)
            {
                writer.WriteAttributeString("Name", PathUtility.MakeRelativePath(xmlFilePath, item.Name));
            }
            else
            {
                writer.WriteAttributeString("Name", item.Name);
            }

            if (item.IsExcluded)
            {
                writer.WriteAttributeString("IsExcluded", "true");
            }

            if (!item.HasDefaultIncludeFolders)
            {
                WriteIncludeFolders(writer, item);
            }

            foreach (var child in item.Children)
            {
                WriteSourceItemXml(writer, child);
            }

            writer.WriteEndElement();
        }

19 View Source File : AccessTokenDictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            foreach (var entry in this)
            {
                writer.WriteStartElement("AccessToken");
                writer.WriteAttributeString("Key", entry.Key);
                writer.WriteAttributeString("Value", entry.Value.ToBase64String());
                writer.WriteEndElement();
            }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

object IXshdVisitor.VisitColor(XshdColor color)
		{
			_writer.WriteStartElement("Color", Namespace);
			if (color.Name != null)
				_writer.WriteAttributeString("name", color.Name);
			WriteColorAttributes(color);
			if (color.ExampleText != null)
				_writer.WriteAttributeString("exampleText", color.ExampleText);
			_writer.WriteEndElement();
			return null;
		}

19 View Source File : ReferenceLinks.cs
License : MIT License
Project Creator : actions

void IXmlSerializable.WriteXml(XmlWriter writer)
        {
            XmlSerializer keySerializer = new XmlSerializer(typeof(string));
            XmlSerializer valueSerializer = new XmlSerializer(typeof(List<ReferenceLink>));

            foreach (var item in this.referenceLinks)
            {
                writer.WriteStartElement("item");

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

                writer.WriteStartElement("value");
                var links = item.Value as List<ReferenceLink>;
                if (links == null)
                {
                    links = new List<ReferenceLink>()
                    {
                        (ReferenceLink)item.Value
                    };
                }

                valueSerializer.Serialize(writer, links);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

object IXshdVisitor.VisitSpan(XshdSpan span)
		{
			_writer.WriteStartElement("Span", Namespace);
			WriteColorReference(span.SpanColorReference);
			if (span.BeginRegexType == XshdRegexType.Default && span.BeginRegex != null)
				_writer.WriteAttributeString("begin", span.BeginRegex);
			if (span.EndRegexType == XshdRegexType.Default && span.EndRegex != null)
				_writer.WriteAttributeString("end", span.EndRegex);
			WriteRuleSetReference(span.RuleSetReference);
			if (span.Multiline)
				_writer.WriteAttributeString("multiline", "true");
			
			if (span.BeginRegexType == XshdRegexType.IgnorePatternWhitespace)
				WriteBeginEndElement("Begin", span.BeginRegex, span.BeginColorReference);
			if (span.EndRegexType == XshdRegexType.IgnorePatternWhitespace)
				WriteBeginEndElement("End", span.EndRegex, span.EndColorReference);

		    span.RuleSetReference.InlineElement?.AcceptVisitor(this);

		    _writer.WriteEndElement();
			return null;
		}

19 View Source File : SerializableStringDictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            foreach (var entry in this)
            {
                writer.WriteStartElement("DictionaryEntry");
                writer.WriteAttributeString("Key", entry.Key);
                writer.WriteAttributeString("Value", entry.Value);
                writer.WriteEndElement();
            }
        }

19 View Source File : PSHelpGenerator.cs
License : Apache License 2.0
Project Creator : aws

protected override void GenerateHelper()
        {
            Console.WriteLine("Generating Native PowerShell help (Get-Help) doreplacedentation file");
            base.GenerateHelper();

            var buildLogsPath = Path.Combine(this.Options.RootPath, "logs");
            if (!Directory.Exists(buildLogsPath))
                Directory.CreateDirectory(buildLogsPath);

            var logFilename = Path.Combine(buildLogsPath, Name + ".dll-Help.log");
            var oldWriter = Console.Out;
            try
            {
                using (var consoleWriter = new StreamWriter(File.OpenWrite(logFilename)))
                {
                    Console.SetOut(consoleWriter);
                    var outputFile = Path.Combine(this.OutputFolder, Name + PsHelpFilenameTail);

                    var settings = new XmlWriterSettings
                    {
                        Indent = true
                    };

                    using (var psHelpWriter = new XmlTextWriter(outputFile, Encoding.UTF8))
                    {
                        psHelpWriter.Formatting = Formatting.Indented;

                        psHelpWriter.WriteStartElement("helpItems");
                        psHelpWriter.WriteAttributeString("schema", "maml");

                        Parallel.ForEach(CmdletTypes, (cmdletType) =>
                        {
                            CmdletInfo cmdletInfo = InspectCmdletAttributes(cmdletType);

                            using (StringWriter sectionWriter = new StringWriter())
                            using (var sectionXmlWriter = XmlWriter.Create(sectionWriter, new XmlWriterSettings()
                            {
                                OmitXmlDeclaration = true,
                                ConformanceLevel = ConformanceLevel.Fragment,
                                CloseOutput = true
                            }))
                            {
                                string synopsis = null;
                                if (cmdletInfo.AWSCmdletAttribute == null)
                                {
                                    Console.WriteLine("Unable to find AWSCmdletAttribute for type " + cmdletType.FullName);
                                }
                                else
                                {
                                    var cmdletReturnAttributeType = cmdletInfo.AWSCmdletAttribute.GetType();
                                    synopsis = cmdletReturnAttributeType.GetProperty("Synopsis").GetValue(cmdletInfo.AWSCmdletAttribute, null) as string;
                                }

                                foreach (var cmdletAttribute in cmdletInfo.CmdletAttributes)
                                {
                                    sectionXmlWriter.WriteStartElement("command");
                                    sectionXmlWriter.WriteAttributeString("xmlns", "maml", null, "http://schemas.microsoft.com/maml/2004/10");
                                    sectionXmlWriter.WriteAttributeString("xmlns", "command", null, "http://schemas.microsoft.com/maml/dev/command/2004/10");
                                    sectionXmlWriter.WriteAttributeString("xmlns", "dev", null, "http://schemas.microsoft.com/maml/dev/2004/10");
                                    {
                                        var typeDoreplacedentation = DoreplacedentationUtils.GetTypeDoreplacedentation(cmdletType, replacedemblyDoreplacedentation);
                                        typeDoreplacedentation = DoreplacedentationUtils.FormatXMLForPowershell(typeDoreplacedentation);
                                        Console.WriteLine($"Cmdlet = {cmdletType.FullName}");
                                        Console.WriteLine($"Doreplacedentation = {typeDoreplacedentation}");

                                        var cmdletName = cmdletAttribute.VerbName + "-" + cmdletAttribute.NounName;

                                        var allProperties = GetRootSimpleProperties(cmdletType);
                                        var parameterParreplacedioning = new CmdletParameterSetParreplacedions(allProperties, cmdletAttribute.DefaultParameterSetName);

                                        var serviceAbbreviation = GetServiceAbbreviation(cmdletType);

                                        WriteDetails(sectionXmlWriter, cmdletAttribute, typeDoreplacedentation, cmdletName, synopsis);
                                        WriteSyntax(sectionXmlWriter, cmdletName, parameterParreplacedioning);
                                        WriteParameters(sectionXmlWriter, cmdletName, allProperties);
                                        WriteReturnValues(sectionXmlWriter, cmdletInfo.AWSCmdletOutputAttributes);
                                        WriteRelatedLinks(sectionXmlWriter, serviceAbbreviation, cmdletName);
                                        WriteExamples(sectionXmlWriter, cmdletName);
                                    }
                                    sectionXmlWriter.WriteEndElement();
                                }

                                sectionXmlWriter.Close();
                                lock (psHelpWriter)
                                {
                                    psHelpWriter.WriteRaw(sectionWriter.ToString());
                                }
                            }
                        });

                        psHelpWriter.WriteEndElement();
                    }

                    Console.WriteLine($"Verifying help file {outputFile} using XmlDoreplacedent...");
                    try
                    {
                        var doreplacedent = new XmlDoreplacedent();
                        doreplacedent.Load(outputFile);
                    }
                    catch (Exception e)
                    {
                        Logger.LogError(e, $"Error when loading file {outputFile} as XmlDoreplacedent");
                    }
                }
            }
            finally
            {
                Console.SetOut(oldWriter);
            }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

object IXshdVisitor.VisitRuleSet(XshdRuleSet ruleSet)
		{
			writer.WriteStartElement("RuleSet", Namespace);

			if (ruleSet.Name != null)
				writer.WriteAttributeString("name", ruleSet.Name);
			WriteBoolAttribute("ignoreCase", ruleSet.IgnoreCase);

			ruleSet.AcceptElements(this);

			writer.WriteEndElement();
			return null;
		}

19 View Source File : PSHelpGenerator.cs
License : Apache License 2.0
Project Creator : aws

private static void WriteSyntaxItem(XmlWriter writer, string cmdletName, string setName, CmdletParameterSetParreplacedions parameterSetParreplacedioning)
        {
            var isCustomNamedSet = !setName.Equals(CmdletParameterSetParreplacedions.AllSetsKey);
            var isDefaultSet = isCustomNamedSet && setName.Equals(parameterSetParreplacedioning.DefaultParameterSetName, StringComparison.Ordinal);
            var setParameterNames = parameterSetParreplacedioning.ParameterNamesForSet(setName, parameterSetParreplacedioning.HasNamedParameterSets);

            writer.WriteStartElement("syntaxItem");
            {
                writer.WriteElementString("name", cmdletName);

                var allParameters = parameterSetParreplacedioning.Parameters;
                // Microsoft cmdlets show params in syntax in defined but non-alpha order. Use the ordering we found
                // during reflection here in the hope the sdk has them in 'most important' order
                foreach (var parameter in allParameters)
                {
                    if (!setParameterNames.Contains(parameter.CmdletParameterName))
                        continue;

                    InspectParameter(parameter, out var isRequiredForParametersets, out var pipelineInput, out var position, out var aliases);
                    var isRequiredForCurrentParameterset = isRequiredForParametersets != null && (isRequiredForParametersets.Count == 0 || isRequiredForParametersets.Contains(setName));

                    writer.WriteStartElement("parameter");
                    {
                        writer.WriteAttributeString("required", isRequiredForCurrentParameterset.ToString());
                        writer.WriteAttributeString("variableLength", "false");
                        writer.WriteAttributeString("globbing", "false");
                        writer.WriteAttributeString("pipelineInput", pipelineInput);
                        writer.WriteAttributeString("position", position);

                        writer.WriteElementString("name", parameter.CmdletParameterName);
                        writer.WriteStartElement("description");
                        {
                            writer.WriteRawElementString("para", parameter.PowershellDoreplacedentation);
                        }
                        writer.WriteEndElement();

                        writer.WriteStartElement("parameterValue");
                        {
                            writer.WriteAttributeString("required", "true");
                            writer.WriteAttributeString("variableLength", "false");
                            writer.WriteString(parameter.PropertyTypeName);
                        }
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
        }

19 View Source File : InstanceRefList.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            foreach (var el in this)
            {
                writer.WriteStartElement(nameof(InstanceRef));
                el.WriteXml(writer);
                writer.WriteEndElement();
            }
        }

19 View Source File : InstanceSourceSettings.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public virtual void WriteXml(XmlWriter writer)
        {
            if (InstanceSource != null)
            {
                writer.WriteStartElement(InstanceSource.GetType().Name);
                writer.WriteAttributeString("Key", nameof(InstanceSource));
                InstanceSource.WriteXml(writer);
                writer.WriteEndElement();
            }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

object IXshdVisitor.VisitColor(XshdColor color)
		{
			writer.WriteStartElement("Color", Namespace);
			if (color.Name != null)
				writer.WriteAttributeString("name", color.Name);
			WriteColorAttributes(color);
			if (color.ExampleText != null)
				writer.WriteAttributeString("exampleText", color.ExampleText);
			writer.WriteEndElement();
			return null;
		}

19 View Source File : SvnItemAnnotation.cs
License : Apache License 2.0
Project Creator : AmpScm

public void Write(ISvnStatusCache context, XmlWriter to, string wcRoot)
        {
            to.WriteStartElement(ElemNode);
            to.WriteAttributeString(AttrName, new Uri(wcRoot).MakeRelativeUri(new Uri(wcRoot)).ToString());

            // TODO: Write explicit values

            if (_justStored != null)
                foreach (KeyValuePair<string, string> kv in _justStored)
                {
                    to.WriteAttributeString(kv.Key, kv.Value);
                }
            to.WriteEndElement();
        }

19 View Source File : USPSInternationalProvider.cs
License : MIT License
Project Creator : alexeybusygin

public override async Task GetRates()
        {
            var sb = new StringBuilder();

            var settings = new XmlWriterSettings
            {
                Indent = false,
                OmitXmlDeclaration = true,
                NewLineHandling = NewLineHandling.None
            };

            using (var writer = XmlWriter.Create(sb, settings))
            {
                writer.WriteStartElement("IntlRateV2Request");
                writer.WriteAttributeString("USERID", _userId);

                writer.WriteElementString("Revision", "2");
                var i = 0;
                foreach (var package in Shipment.Packages)
                {
                    //<Package ID="2ND">
                    //  <Pounds>0</Pounds>
                    //  <Ounces>3</Ounces>
                    //  <MailType>Envelope</MailType>
                    //  <ValueOfContents>750</ValueOfContents>
                    //  <Country>Algeria</Country>
                    //  <Container></Container>
                    //  <Size>REGULAR</Size>
                    //  <Width></Width>
                    //  <Length></Length>
                    //  <Height></Height>
                    //  <Girth></Girth>
                    //  <CommercialFlag>N</CommercialFlag>
                    //</Package>

                    writer.WriteStartElement("Package");
                    writer.WriteAttributeString("ID", i.ToString());
                    writer.WriteElementString("Pounds", package.PoundsAndOunces.Pounds.ToString());
                    writer.WriteElementString("Ounces", package.PoundsAndOunces.Ounces.ToString());
                    writer.WriteElementString("MailType", "All");
                    writer.WriteElementString("ValueOfContents", package.InsuredValue.ToString());
                    writer.WriteElementString("Country", Shipment.DestinationAddress.GetCountryName());
                    writer.WriteElementString("Container", "RECTANGULAR");
                    writer.WriteElementString("Size", "REGULAR");
                    writer.WriteElementString("Width", package.RoundedWidth.ToString());
                    writer.WriteElementString("Length", package.RoundedLength.ToString());
                    writer.WriteElementString("Height", package.RoundedHeight.ToString());
                    writer.WriteElementString("Girth", package.CalculatedGirth.ToString());
                    writer.WriteElementString("OriginZip", Shipment.OriginAddress.PostalCode);
                    writer.WriteElementString("CommercialFlag", Commercial ? "Y" : "N");

                    // ContentType must be set to Doreplacedents to get First-Clreplaced International Mail rates
                    if (package is DoreplacedentsPackage)
                    {
                        writer.WriteStartElement("Content");
                        writer.WriteElementString("ContentType", "Doreplacedents");
                        writer.WriteEndElement();
                    }

                    //TODO: Figure out DIM Weights
                    //writer.WriteElementString("Size", package.IsOversize ? "LARGE" : "REGULAR");
                    //writer.WriteElementString("Length", package.RoundedLength.ToString());
                    //writer.WriteElementString("Width", package.RoundedWidth.ToString());
                    //writer.WriteElementString("Height", package.RoundedHeight.ToString());
                    //writer.WriteElementString("Girth", package.CalculatedGirth.ToString());
                    i++;
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.Flush();
            }

            try
            {
                using (var httpClient = new HttpClient())
                {
                    var rateUri = new Uri($"{ProductionUrl}?API=IntlRateV2&XML={sb}");
                    var response = await httpClient.GetStringAsync(rateUri).ConfigureAwait(false);

                    ParseResult(response);
                }
            }
            catch (Exception ex)
            {
                AddInternalError($"USPS International provider exception: {ex.Message}");
            }
        }

19 View Source File : XmlLayoutSchemaLog4j.cs
License : Apache License 2.0
Project Creator : apache

protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
		{
			// Translate logging events for log4j

			// Translate hostname property
			if (loggingEvent.LookupProperty(LoggingEvent.HostNameProperty) != null && 
				loggingEvent.LookupProperty("log4jmachinename") == null)
			{
				loggingEvent.GetProperties()["log4jmachinename"] = loggingEvent.LookupProperty(LoggingEvent.HostNameProperty);
			}

			// translate appdomain name
			if (loggingEvent.LookupProperty("log4replacedp") == null && 
				loggingEvent.Domain != null && 
				loggingEvent.Domain.Length > 0)
			{
				loggingEvent.GetProperties()["log4replacedp"] = loggingEvent.Domain;
			}

			// translate idenreplacedy name
			if (loggingEvent.Idenreplacedy != null && 
				loggingEvent.Idenreplacedy.Length > 0 && 
				loggingEvent.LookupProperty(LoggingEvent.IdenreplacedyProperty) == null)
			{
				loggingEvent.GetProperties()[LoggingEvent.IdenreplacedyProperty] = loggingEvent.Idenreplacedy;
			}

			// translate user name
			if (loggingEvent.UserName != null && 
				loggingEvent.UserName.Length > 0 && 
				loggingEvent.LookupProperty(LoggingEvent.UserNameProperty) == null)
			{
				loggingEvent.GetProperties()[LoggingEvent.UserNameProperty] = loggingEvent.UserName;
			}

			// Write the start element
			writer.WriteStartElement("log4j", "event", "log4net");
			writer.WriteAttributeString("logger", loggingEvent.LoggerName);

			// Calculate the timestamp as the number of milliseconds since january 1970
			// 
			// We must convert the TimeStamp to UTC before performing any mathematical
			// operations. This allows use to take into account discontinuities
			// caused by daylight savings time transitions.
			TimeSpan timeSince1970 = loggingEvent.TimeStampUtc - s_date1970;

			writer.WriteAttributeString("timestamp", XmlConvert.ToString((long)timeSince1970.TotalMilliseconds));
			writer.WriteAttributeString("level", loggingEvent.Level.DisplayName);
			writer.WriteAttributeString("thread", loggingEvent.ThreadName);
    
			// Append the message text
			writer.WriteStartElement("log4j", "message", "log4net");
			Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage,this.InvalidCharReplacement);
			writer.WriteEndElement();

			object ndcObj = loggingEvent.LookupProperty("NDC");
			if (ndcObj != null)
			{
				string valueStr = loggingEvent.Repository.RendererMap.FindAndRender(ndcObj);

				if (valueStr != null && valueStr.Length > 0)
				{
					// Append the NDC text
					writer.WriteStartElement("log4j", "NDC", "log4net");
					Transform.WriteEscapedXmlString(writer, valueStr,this.InvalidCharReplacement);
					writer.WriteEndElement();
				}
			}

			// Append the properties text
			PropertiesDictionary properties = loggingEvent.GetProperties();
			if (properties.Count > 0)
			{
				writer.WriteStartElement("log4j", "properties", "log4net");
				foreach(System.Collections.DictionaryEntry entry in properties)
				{
					writer.WriteStartElement("log4j", "data", "log4net");
					writer.WriteAttributeString("name", (string)entry.Key);

					// Use an ObjectRenderer to convert the object to a string
					string valueStr = loggingEvent.Repository.RendererMap.FindAndRender(entry.Value);
					writer.WriteAttributeString("value", valueStr);

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

			string exceptionStr = loggingEvent.GetExceptionString();
			if (exceptionStr != null && exceptionStr.Length > 0)
			{
				// Append the stack trace line
				writer.WriteStartElement("log4j", "throwable", "log4net");
				Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
				writer.WriteEndElement();
			}

			if (LocationInfo)
			{ 
				LocationInfo locationInfo = loggingEvent.LocationInformation;

				writer.WriteStartElement("log4j", "locationInfo", "log4net");
				writer.WriteAttributeString("clreplaced", locationInfo.ClreplacedName);
				writer.WriteAttributeString("method", locationInfo.MethodName);
				writer.WriteAttributeString("file", locationInfo.FileName);
				writer.WriteAttributeString("line", locationInfo.LineNumber);
				writer.WriteEndElement();
			}

			writer.WriteEndElement();
		}

19 View Source File : WrapperProject.cs
License : MIT License
Project Creator : AndresTraks

private void WriteIncludeFolders(XmlWriter writer, SourceItemDefinition item)
        {
            foreach (string includeFolder in item.IncludeFolders)
            {
                writer.WriteStartElement("IncludeFolder");
                writer.WriteString(includeFolder);
                writer.WriteEndElement();
            }
        }

19 View Source File : Settings.xaml.cs
License : MIT License
Project Creator : Alkl58

public void SaveSettingsTab()
        {
            try
            {
                if (!MainWindow.StartUp)
                {
                    XmlWriter writer = XmlWriter.Create(Path.Combine(Directory.GetCurrentDirectory(), "settings.xml"));
                    writer.WriteStartElement("Settings");
                    writer.WriteElementString("DeleteTempFiles", ToggleSwitchDeleteTempFiles.IsOn.ToString());
                    writer.WriteElementString("PlaySound", ToggleSwitchUISounds.IsOn.ToString());
                    writer.WriteElementString("Logging", ToggleSwitchLogging.IsOn.ToString());
                    writer.WriteElementString("ShowDialog", ToggleSwitchShowWindow.IsOn.ToString());
                    writer.WriteElementString("Shutdown", ToggleSwitchShutdownAfterEncode.IsOn.ToString());
                    writer.WriteElementString("TempPathActive", ToggleSwitchTempFolder.IsOn.ToString());
                    writer.WriteElementString("TempPath", TextBoxCustomTempPath.Text);
                    writer.WriteElementString("Terminal", ToggleSwitchHideTerminal.IsOn.ToString());
                    writer.WriteElementString("ThemeAccent", ComboBoxAccentTheme.SelectedIndex.ToString());
                    writer.WriteElementString("ThemeBase", ComboBoxBaseTheme.SelectedIndex.ToString());
                    writer.WriteElementString("BatchContainer", ComboBoxContainerBatchEncoding.SelectedIndex.ToString());
                    writer.WriteElementString("ReencodeMessage", MainWindow.reencodeMessage.ToString());
                    writer.WriteElementString("Language", ComboBoxUILanguage.Text ?? "English");
                    writer.WriteElementString("SkipSubreplacedles", ToggleSkipSubreplacedleExtraction.IsOn.ToString());
                    writer.WriteElementString("OverrideWorkerCount", ToggleOverrideWorkerCount.IsOn.ToString());
                    writer.WriteEndElement();
                    writer.Close();
                }
            }
            catch { }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

object IXshdVisitor.VisitRuleSet(XshdRuleSet ruleSet)
		{
			_writer.WriteStartElement("RuleSet", Namespace);
			
			if (ruleSet.Name != null)
				_writer.WriteAttributeString("name", ruleSet.Name);
			WriteBoolAttribute("ignoreCase", ruleSet.IgnoreCase);
			
			ruleSet.AcceptElements(this);
			
			_writer.WriteEndElement();
			return null;
		}

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

object IXshdVisitor.VisitSpan(XshdSpan span)
		{
			writer.WriteStartElement("Span", Namespace);
			WriteColorReference(span.SpanColorReference);
			if (span.BeginRegexType == XshdRegexType.Default && span.BeginRegex != null)
				writer.WriteAttributeString("begin", span.BeginRegex);
			if (span.EndRegexType == XshdRegexType.Default && span.EndRegex != null)
				writer.WriteAttributeString("end", span.EndRegex);
			WriteRuleSetReference(span.RuleSetReference);
			if (span.Multiline)
				writer.WriteAttributeString("multiline", "true");

			if (span.BeginRegexType == XshdRegexType.IgnorePatternWhitespace)
				WriteBeginEndElement("Begin", span.BeginRegex, span.BeginColorReference);
			if (span.EndRegexType == XshdRegexType.IgnorePatternWhitespace)
				WriteBeginEndElement("End", span.EndRegex, span.EndColorReference);

			if (span.RuleSetReference.InlineElement != null)
				span.RuleSetReference.InlineElement.AcceptVisitor(this);

			writer.WriteEndElement();
			return null;
		}

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

public void WriteDefinition(XshdSyntaxDefinition definition)
		{
			if (definition == null)
				throw new ArgumentNullException(nameof(definition));
			_writer.WriteStartElement("SyntaxDefinition", Namespace);
			if (definition.Name != null)
				_writer.WriteAttributeString("name", definition.Name);
			if (definition.Extensions != null)
				_writer.WriteAttributeString("extensions", string.Join(";", definition.Extensions.ToArray()));
			
			definition.AcceptElements(this);
			
			_writer.WriteEndElement();
		}

19 View Source File : Dictionary.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            foreach (var entry in this)
            {
                writer.WriteStartElement(entry.Value.GetType().Name);
                writer.WriteAttributeString("Key", entry.Key);
                entry.Value.WriteXml(writer);
                writer.WriteEndElement();
            }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

private void WriteBeginEndElement(string elementName, string regex, XshdReference<XshdColor> colorReference)
		{
			if (regex != null) {
				_writer.WriteStartElement(elementName, Namespace);
				WriteColorReference(colorReference);
				_writer.WriteString(regex);
				_writer.WriteEndElement();
			}
		}

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

public void WriteDefinition(XshdSyntaxDefinition definition)
		{
			if (definition == null)
				throw new ArgumentNullException("definition");
			writer.WriteStartElement("SyntaxDefinition", Namespace);
			if (definition.Name != null)
				writer.WriteAttributeString("name", definition.Name);
			if (definition.Extensions != null)
				writer.WriteAttributeString("extensions", string.Join(";", definition.Extensions.ToArray()));

			definition.AcceptElements(this);

			writer.WriteEndElement();
		}

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : AvaloniaUI

object IXshdVisitor.VisitKeywords(XshdKeywords keywords)
		{
			_writer.WriteStartElement("Keywords", Namespace);
			WriteColorReference(keywords.ColorReference);
			foreach (string word in keywords.Words) {
				_writer.WriteElementString("Word", Namespace, word);
			}
			_writer.WriteEndElement();
			return null;
		}

19 View Source File : ResourceRef.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            writer.WriteAttributeString(nameof(Uri), Uri.AbsoluteUri);

            if (PublicKeys != null)
            {
                writer.WriteStartElement(nameof(MinisignPublicKeyDictionary));
                writer.WriteAttributeString("Key", nameof(PublicKeys));
                PublicKeys.WriteXml(writer);
                writer.WriteEndElement();
            }
        }

19 View Source File : FormatGenerator.cs
License : Apache License 2.0
Project Creator : aws

private void GenerateView_NonReflective(ConfigModel config, XmlWriter writer, Type targetType)
        {
            if (config.Columns.Count == 0) return;
            bool isTableView = config.Columns.Count <= 4;

            writer.WriteStartElement("View");
            {
                writer.WriteElementString("Name", string.Format("View node for {0}", targetType.FullName));

                writer.WriteStartElement("ViewSelectedBy");
                {
                    if (config.ApplicableTypes != null && config.ApplicableTypes.Count > 0)
                    {
                        foreach (var type in config.ApplicableTypes)
                        {
                            writer.WriteElementString("TypeName", type);
                        }
                    }
                    else
                    {
                        writer.WriteElementString("TypeName", targetType.FullName);
                    }
                }
                writer.WriteEndElement();

                writer.WriteStartElement(isTableView ? "TableControl" : "ListControl");
                {
                    if (isTableView)
                    {
                        writer.WriteStartElement("TableHeaders");
                        {
                            foreach (var header in config.Columns)
                            {
                                writer.WriteStartElement("TableColumnHeader");
                                {
                                    writer.WriteElementString("Label", header.HeaderLabel);
                                    if (header.HeaderWidth != 0)
                                        writer.WriteElementString("Width", header.HeaderWidth.ToString());
                                    if (header.HeaderAlignment != HeaderAlignment.None)
                                        writer.WriteElementString("Alignment", header.HeaderAlignment.ToString());
                                }
                                writer.WriteEndElement();
                            }
                        }
                        writer.WriteEndElement();
                    }

                    writer.WriteStartElement(isTableView ? "TableRowEntries" : "ListEntries");
                    {
                        writer.WriteStartElement(isTableView ? "TableRowEntry" : "ListEntry");
                        {
                            writer.WriteStartElement(isTableView ? "TableColumnItems" : "Lisreplacedems");
                            {
                                foreach (var column in config.Columns)
                                {
                                    writer.WriteStartElement(isTableView ? "TableColumnItem" : "Lisreplacedem");
                                    {
                                        if (!string.IsNullOrEmpty(column.PropertyName))
                                            writer.WriteElementString("PropertyName", column.PropertyName);
                                        else if (!string.IsNullOrEmpty(column.ScriptBlock))
                                            writer.WriteElementString("ScriptBlock", column.ScriptBlock);
                                        else
                                            throw new InvalidDataException("PropertyName and ScriptBlock are not set");
                                    }
                                    writer.WriteEndElement();
                                }
                            }
                            writer.WriteEndElement();
                        }
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }

19 View Source File : DHLProvider.cs
License : MIT License
Project Creator : alexeybusygin

private static void WriteAddress(XmlWriter writer, string name, Address address)
        {
            writer.WriteStartElement(name);
            writer.WriteElementString("CountryCode",address.CountryCode);
            writer.WriteElementString("Postalcode", address.PostalCode);
            if (!string.IsNullOrWhiteSpace(address.City))
            {
                writer.WriteElementString("City", address.City);
            }
            writer.WriteEndElement(); // </From>
        }

19 View Source File : HelpGeneratorBase.cs
License : Apache License 2.0
Project Creator : aws

public static void WriteRawElementString(this XmlWriter self, string localName, string value)
        {
            if (self == null) throw new ArgumentNullException("self");

            self.WriteStartElement(localName);
            self.WriteRaw(value);
            self.WriteEndElement();
        }

19 View Source File : LocalInstanceSourceSettings.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public override void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement(nameof(InstanceRefList));
            writer.WriteAttributeString("Key", nameof(ConnectingInstanceList));
            ConnectingInstanceList.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteStartElement(nameof(InstanceSourceSettingsBase));
            base.WriteXml(writer);
            writer.WriteEndElement();
        }

19 View Source File : PSHelpGenerator.cs
License : Apache License 2.0
Project Creator : aws

private static void WriteReturnValues(XmlWriter writer, IEnumerable<object> outputAttributes)
        {
            writer.WriteStartElement("returnValues");
            foreach (var outputAttribute in outputAttributes)
            {
                var attributeType = outputAttribute.GetType();
                writer.WriteStartElement("returnValue");
                {
                    writer.WriteStartElement("type");
                    {
                        var returnType = attributeType.GetProperty("ReturnType").GetValue(outputAttribute, null) as string;
                        writer.WriteElementString("name", returnType);
                        writer.WriteElementString("uri", string.Empty);
                        writer.WriteElementString("description", string.Empty);
                    }
                    writer.WriteEndElement();

                    writer.WriteStartElement("description");
                    writer.WriteStartElement("para");
                    {
                        var description = attributeType.GetProperty("Description").GetValue(outputAttribute, null) as string;
                        writer.WriteString(description);
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

object IXshdVisitor.VisitImport(XshdImport import)
		{
			writer.WriteStartElement("Import", Namespace);
			WriteRuleSetReference(import.RuleSetReference);
			writer.WriteEndElement();
			return null;
		}

19 View Source File : PSHelpGenerator.cs
License : Apache License 2.0
Project Creator : aws

private static void WriteSyntax(XmlWriter writer, string cmdletName, CmdletParameterSetParreplacedions parameterSetParreplacedioning)
        {
            writer.WriteStartElement("syntax");
            if (parameterSetParreplacedioning.HasNamedParameterSets)
            {
                var sets = parameterSetParreplacedioning.NamedParameterSets;
                foreach (var set in sets)
                {
                    WriteSyntaxItem(writer, cmdletName, set, parameterSetParreplacedioning);
                }
            }
            else
            {
                WriteSyntaxItem(writer, cmdletName, CmdletParameterSetParreplacedions.AllSetsKey, parameterSetParreplacedioning);
            }
            writer.WriteEndElement();
        }

19 View Source File : InstanceRef.cs
License : GNU General Public License v3.0
Project Creator : Amebis

public void WriteXml(XmlWriter writer)
        {
            writer.WriteAttributeString(nameof(Base), Base.AbsoluteUri);
            writer.WriteAttributeString(nameof(Popularity), Popularity.ToString(CultureInfo.InvariantCulture));

            if (Profiles != null)
            {
                writer.WriteStartElement(nameof(ProfileRefList));
                writer.WriteAttributeString("Key", nameof(Profiles));
                Profiles.WriteXml(writer);
                writer.WriteEndElement();
            }
        }

19 View Source File : DHLProvider.cs
License : MIT License
Project Creator : alexeybusygin

private string BuildRatesRequestMessage(
            DateTime requestDateTime,
            DateTime pickupDateTime,
            string messageReference)
        {
            var requestCulture = CultureInfo.CreateSpecificCulture("en-US");
            var xmlSettings = new XmlWriterSettings()
            {
                Indent = true,
                Encoding = Encoding.UTF8
            };

            var isDomestic = Shipment.OriginAddress.CountryCode == Shipment.DestinationAddress.CountryCode;
            var isDutiable = !Shipment.HasDoreplacedentsOnly && !isDomestic;

            using (var memoryStream = new MemoryStream())
            {
                using (var writer = XmlWriter.Create(memoryStream, xmlSettings))
                {
                    writer.WriteStartDoreplacedent();
                    writer.WriteStartElement("p", "DCTRequest", "http://www.dhl.com");
                    writer.WriteStartElement("GetQuote");

                    writer.WriteStartElement("Request");
                    writer.WriteStartElement("ServiceHeader");
                    writer.WriteElementString("MessageTime", requestDateTime.ToString("O", requestCulture));
                    writer.WriteElementString("MessageReference", messageReference);
                    writer.WriteElementString("SiteID", _configuration.SiteId);
                    writer.WriteElementString("Preplacedword", _configuration.Preplacedword);
                    writer.WriteEndElement(); // </ServiceHeader>
                    writer.WriteEndElement(); // </Request>

                    WriteAddress(writer, "From", Shipment.OriginAddress);

                    writer.WriteStartElement("BkgDetails");
                    writer.WriteElementString("PaymentCountryCode", Shipment.OriginAddress.CountryCode);
                    writer.WriteElementString("Date", pickupDateTime.ToString("yyyy-MM-dd", requestCulture));
                    writer.WriteElementString("ReadyTime", $"PT{pickupDateTime:HH}H{pickupDateTime:mm}M");
                    writer.WriteElementString("ReadyTimeGMTOffset", pickupDateTime.ToString("zzz", requestCulture));
                    writer.WriteElementString("DimensionUnit", "IN");
                    writer.WriteElementString("WeightUnit", "LB");

                    writer.WriteStartElement("Pieces");
                    for (var i = 0; i < Shipment.Packages.Count; i++)
                    {
                        writer.WriteStartElement("Piece");
                        writer.WriteElementString("PieceID", $"{i + 1}");
                        writer.WriteElementString("Height", Shipment.Packages[i].RoundedHeight.ToString(requestCulture));
                        writer.WriteElementString("Depth", Shipment.Packages[i].RoundedLength.ToString(requestCulture));
                        writer.WriteElementString("Width", Shipment.Packages[i].RoundedWidth.ToString(requestCulture));
                        writer.WriteElementString("Weight", Shipment.Packages[i].RoundedWeight.ToString(requestCulture));
                        writer.WriteEndElement(); // </Piece>
                    }
                    writer.WriteEndElement(); // </Pieces>

                    if (!string.IsNullOrEmpty(_configuration.PaymentAccountNumber))
                    {
                        writer.WriteElementString("PaymentAccountNumber", _configuration.PaymentAccountNumber);
                    }
                    writer.WriteElementString("IsDutiable", isDutiable ? "Y" : "N");
                    writer.WriteElementString("NetworkTypeCode", "AL");

                    writer.WriteStartElement("QtdShp");
                    if (_configuration.ServicesIncluded.Any())
                    {
                        foreach (var serviceCode in _configuration.ServicesIncluded)
                        {
                            writer.WriteElementString("GlobalProductCode", serviceCode.ToString());
                        }
                    }
                    if (Shipment.Options.SaturdayDelivery)
                    {
                        writer.WriteStartElement("QtdShpExChrg");
                        writer.WriteElementString("SpecialServiceType", isDomestic ? "AG" : "AA");
                        writer.WriteEndElement(); // </QtdShpExChrg>
                    }
                    writer.WriteEndElement(); // </QtdShp>

                    var totalInsurance = Shipment.Packages.Sum(p => p.InsuredValue);
                    if (totalInsurance > 0)
                    {
                        writer.WriteElementString("InsuredValue", $"{totalInsurance:N}");
                        writer.WriteElementString("InsuredCurrency", "USD");
                    }

                    writer.WriteEndElement(); // </BkgDetails>

                    WriteAddress(writer, "To", Shipment.DestinationAddress);

                    if (isDutiable)
                    {
                        writer.WriteStartElement("Dutiable");
                        writer.WriteElementString("DeclaredCurrency", "USD");
                        writer.WriteElementString("DeclaredValue", $"{totalInsurance:N}");
                        writer.WriteEndElement(); // </Dutiable>
                    }

                    writer.WriteEndElement(); // </GetQuote>
                    writer.WriteEndElement(); // </p:DCTRequest>
                    writer.WriteEndDoreplacedent();
                    writer.Flush();
                    writer.Close();
                }
                return Encoding.UTF8.GetString(memoryStream.ToArray());
            }
        }

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

void WriteBeginEndElement(string elementName, string regex, XshdReference<XshdColor> colorReference)
		{
			if (regex != null) {
				writer.WriteStartElement(elementName, Namespace);
				WriteColorReference(colorReference);
				writer.WriteString(regex);
				writer.WriteEndElement();
			}
		}

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

object IXshdVisitor.VisitRule(XshdRule rule)
		{
			writer.WriteStartElement("Rule", Namespace);
			WriteColorReference(rule.ColorReference);

			writer.WriteString(rule.Regex);

			writer.WriteEndElement();
			return null;
		}

19 View Source File : SaveXshdVisitor.cs
License : MIT License
Project Creator : Abdesol

object IXshdVisitor.VisitKeywords(XshdKeywords keywords)
		{
			writer.WriteStartElement("Keywords", Namespace);
			WriteColorReference(keywords.ColorReference);
			foreach (string word in keywords.Words) {
				writer.WriteElementString("Word", Namespace, word);
			}
			writer.WriteEndElement();
			return null;
		}

19 View Source File : XmlWriterBase.cs
License : MIT License
Project Creator : AlexGyver

protected void WriteEndElement()
        {
            this.w.WriteEndElement();
        }

19 View Source File : XmlLayout.cs
License : Apache License 2.0
Project Creator : apache

protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
		{
			writer.WriteStartElement(m_elmEvent);
			writer.WriteAttributeString(ATTR_LOGGER, loggingEvent.LoggerName);

#if NET_2_0 || NETCF_2_0 || MONO_2_0 || NETSTANDARD
			writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp, XmlDateTimeSerializationMode.Local));
#else
			writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp));
#endif

			writer.WriteAttributeString(ATTR_LEVEL, loggingEvent.Level.DisplayName);
			writer.WriteAttributeString(ATTR_THREAD, loggingEvent.ThreadName);

			if (loggingEvent.Domain != null && loggingEvent.Domain.Length > 0)
			{
				writer.WriteAttributeString(ATTR_DOMAIN, loggingEvent.Domain);
			}
			if (loggingEvent.Idenreplacedy != null && loggingEvent.Idenreplacedy.Length > 0)
			{
				writer.WriteAttributeString(ATTR_IDENreplacedY, loggingEvent.Idenreplacedy);
			}
			if (loggingEvent.UserName != null && loggingEvent.UserName.Length > 0)
			{
				writer.WriteAttributeString(ATTR_USERNAME, loggingEvent.UserName);
			}
    
			// Append the message text
			writer.WriteStartElement(m_elmMessage);
			if (!this.Base64EncodeMessage)
			{
				Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage, this.InvalidCharReplacement);
			}
			else
			{
				byte[] messageBytes = Encoding.UTF8.GetBytes(loggingEvent.RenderedMessage);
				string base64Message = Convert.ToBase64String(messageBytes, 0, messageBytes.Length);
				Transform.WriteEscapedXmlString(writer, base64Message,this.InvalidCharReplacement);
			}
			writer.WriteEndElement();

			PropertiesDictionary properties = loggingEvent.GetProperties();

			// Append the properties text
			if (properties.Count > 0)
			{
				writer.WriteStartElement(m_elmProperties);
				foreach(System.Collections.DictionaryEntry entry in properties)
				{
					writer.WriteStartElement(m_elmData);
					writer.WriteAttributeString(ATTR_NAME, Transform.MaskXmlInvalidCharacters((string)entry.Key,this.InvalidCharReplacement));

					// Use an ObjectRenderer to convert the object to a string
					string valueStr =null;
					if (!this.Base64EncodeProperties)
					{
						valueStr = Transform.MaskXmlInvalidCharacters(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value),this.InvalidCharReplacement);
					}
					else
					{
						byte[] propertyValueBytes = Encoding.UTF8.GetBytes(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value));
						valueStr = Convert.ToBase64String(propertyValueBytes, 0, propertyValueBytes.Length);
					}
					writer.WriteAttributeString(ATTR_VALUE, valueStr);

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

			string exceptionStr = loggingEvent.GetExceptionString();
			if (exceptionStr != null && exceptionStr.Length > 0)
			{
				// Append the stack trace line
				writer.WriteStartElement(m_elmException);
				Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
				writer.WriteEndElement();
			}

			if (LocationInfo)
			{ 
				LocationInfo locationInfo = loggingEvent.LocationInformation;

				writer.WriteStartElement(m_elmLocation);
				writer.WriteAttributeString(ATTR_CLreplaced, locationInfo.ClreplacedName);
				writer.WriteAttributeString(ATTR_METHOD, locationInfo.MethodName);
				writer.WriteAttributeString(ATTR_FILE, locationInfo.FileName);
				writer.WriteAttributeString(ATTR_LINE, locationInfo.LineNumber);
				writer.WriteEndElement();
			}

			writer.WriteEndElement();
		}

See More Examples