public override void CreateFiles(string filepath, string nameSpace, System.Collections.ObjectModel.ObservableCollection<dynamic> resources)
 {
     XmlScript xmlScript = new XmlScript();
     XmlElement rootElement = XmlScript.XmlRoot(xmlScript, "resource-list");
     XmlScript.XmlAttribute(rootElement, "namespace", nameSpace);
     foreach (dynamic resource in resources)
     {
         XmlElement resourceElement = XmlScript.XmlElement(xmlScript, rootElement, "resource");
         PropertyInfo[] properties = Resource.Properties;
         foreach (PropertyInfo property in properties)
         {
             string data = property.GetValue(resource);
             string name = property.Name;
             XmlScript.XmlElementWithText(xmlScript, resourceElement, name, data);
         }
         rootElement.AppendChild(resourceElement);
     }
     xmlScript.Save(filepath);
 }
Ejemplo n.º 2
0
        private XmlScript ConvertToXml(StringBuilder stringBuilder)
        {
            //Create Root XML
            XmlScript xmlScript = new XmlScript();
            XmlElement rootElement = XmlScript.XmlRoot(xmlScript, RESOURCES);

            //Add StringBuilder Lines to XML
            XmlDocumentFragment fragment = xmlScript.CreateDocumentFragment();
            fragment.InnerXml = stringBuilder.ToString();
            rootElement.AppendChild(fragment);

            return xmlScript;
        }
Ejemplo n.º 3
0
        private XmlScript ConvertToXml(StringBuilder stringBuilder)
        {
            //Create Root XML
            XmlScript xmlScript = new XmlScript();
            Uri uri = new Uri("/WinResource.xml", UriKind.RelativeOrAbsolute);
            using (Stream stream = System.Windows.Application.GetResourceStream(uri).Stream)
            {
                xmlScript.Load(stream);
            }

            //Add StringBuilder Lines to XML
            XmlDocumentFragment fragment = xmlScript.CreateDocumentFragment();
            fragment.InnerXml = stringBuilder.ToString();
            xmlScript.DocumentElement.AppendChild(fragment);

            return xmlScript;
        }