Beispiel #1
0
        public void Write(Stream stream)
        {
            EnsureState();

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("package");

            PackageItem.AddAttribute(root, "id", Id);
            PackageItem.AddAttribute(root, "name", Name);
            if (Condition != null)
            {
                PackageItem.AddAttribute(root, "condition", Condition.ToString());
            }
            PackageItem.AddAttribute(root, "version", Version.ToString());
            PackageItem.AddAttribute(root, "attribution", Attribution);
            if (Website != null)
            {
                PackageItem.AddAttribute(root, "website", Website.ToString());
            }
            if (UpdateUri != null)
            {
                PackageItem.AddAttribute(root, "updateUri", UpdateUri.ToString());
            }
            if (FeedbackUri != null)
            {
                PackageItem.AddAttribute(root, "feedbackUri", FeedbackUri.ToString());
            }

            doc.AppendChild(root);

            RootGroup.Write(root);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.ConformanceLevel = ConformanceLevel.Document;
            settings.Encoding         = Encoding.UTF8;
            settings.Indent           = true;
            settings.IndentChars      = "\t";

            XmlWriter wtr = XmlWriter.Create(stream, settings);

            doc.WriteTo(wtr);

            wtr.Flush();
        }