MediaConvertGUI.EnhancedXmlDocument.CreateTextSingleValueElement C# (CSharp) Method

CreateTextSingleValueElement() public method

public CreateTextSingleValueElement ( XmlNode parent, string name, string value ) : void
parent System.Xml.XmlNode
name string
value string
return void
        public void CreateTextSingleValueElement(XmlNode parent,string name, string value)
        {
            var node = CreateElement(name);
            node.InnerText = value;
            parent.AppendChild(node);
        }

Usage Example

Beispiel #1
0
        public static void Save(string filename)
        {
            var xmlDoc   = new EnhancedXmlDocument();
            var rootNode = xmlDoc.CreateElement("MediaConvertGUIConfiguration");

            xmlDoc.AppendChild(rootNode);

            xmlDoc.CreateTextSingleValueElement(rootNode, "MediaInfoPath", MediaInfoPath);
            xmlDoc.CreateTextSingleValueElement(rootNode, "FFMpegPath", FFMpegPath);

            var appNode = xmlDoc.CreateElement("Applications");

            rootNode.AppendChild(appNode);

            var appOpenWithNode = xmlDoc.CreateElement("OpenWith");

            appNode.AppendChild(appOpenWithNode);

            var appOpenWithCommentNode = xmlDoc.CreateComment(" <Application>vlc</Application> ");

            appOpenWithNode.AppendChild(appOpenWithCommentNode);

            foreach (var app in OpenWithApplications)
            {
                var node = xmlDoc.CreateElement("Application");
                node.InnerText = app;
                appOpenWithNode.AppendChild(node);
            }

            var codecsNode      = xmlDoc.CreateElement("AvailableCodecs");
            var videoCodecsNode = xmlDoc.CreateElement("Video");
            var audioCodecsNode = xmlDoc.CreateElement("Audio");

            rootNode.AppendChild(codecsNode);
            codecsNode.AppendChild(videoCodecsNode);
            codecsNode.AppendChild(audioCodecsNode);

            foreach (var codec in VideoCodecs)
            {
                codec.SaveToXmlnode(xmlDoc, videoCodecsNode);
            }

            foreach (var codec in AudioCodecs)
            {
                codec.SaveToXmlnode(xmlDoc, audioCodecsNode);
            }

            var containersNode = xmlDoc.CreateElement("AvailableContainers");

            rootNode.AppendChild(containersNode);

            foreach (var container in Containers)
            {
                container.SaveToXmlnode(xmlDoc, containersNode);
            }

            SaveDictionaryToXmlNode(DefaultVideoBitRates, xmlDoc, rootNode, "DefaultVideoBitrates", "Bitrate");
            SaveDictionaryToXmlNode(DefaultSamplingRates, xmlDoc, rootNode, "DefaultSamplingRates", "Rate");
            SaveDictionaryToXmlNode(DefaultAudioBitrates, xmlDoc, rootNode, "DefaultAudioBitrates", "Bitrate");

            xmlDoc.Save(filename);
        }