Beispiel #1
0
 private static void ReadAllElements(XmlElement root, AttributePackage pack)
 {
     ReadPack rpack = new ReadPack(root, pack);
     SafeReadElement(rpack, ReadInformation, "Information");
     SafeReadElement(rpack, ReadCaption, "Caption");
     SafeReadElement(rpack, ReadHowto, "Howto");
     SafeReadElement(rpack, ReadDerivate, "Derivate");
     SafeReadElement(rpack, ReadRemark, "Remark");
     SafeReadElement(rpack, ReadLicense, "License");
     SafeReadElement(rpack, ReadUpdate, "Update");
 }
Beispiel #2
0
 private static void ReadCaption(XmlElement root, AttributePackage pack)
 {
     var nodes = root.GetElementsByTagName("Caption");
     if (nodes.Count > 0)
     {
         pack.Caption = nodes[0].InnerText;
     }
     else
     {
         pack.Caption = "";
     }
 }
Beispiel #3
0
 private static void WriteInformation(XmlTextWriter w, AttributePackage pack)
 {
     w.WriteStartElement("Information");
     {
         WriteElement(w, "Author", pack.Author);
         WriteElement(w, "Email", pack.Email);
         WriteElement(w, "Title", pack.Title);
         WriteElement(w, "CreatedAt", pack.CreatedAt);
         WriteElement(w, "Version", pack.Version);
         WriteElement(w, "Tags", pack.Tags);
         WriteElement(w, "OpenPass", pack.OpenPass);
     }
     w.WriteEndElement();
 }
Beispiel #4
0
        public static AttributePackage Open(Stream stream)
        {
            AttributePackage pack = new AttributePackage();

            XmlDocument doc = new XmlDocument();
            try
            {
                doc.Load(stream);
                var root = doc.DocumentElement;
                ReadAllElements(root, pack);
            }
            catch (XmlException e)
            {
                MessageBox.Show(e.Message, "読み込みエラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return pack;
        }
Beispiel #5
0
        public static void Save(AttributePackage pack, Stream stream)
        {
            XmlTextWriter w = new XmlTextWriter(stream, Encoding.UTF8);
            w.Formatting = Formatting.Indented;

            w.WriteStartDocument(true);
            {
                w.WriteStartElement("ReadmeEditor");
                {
                    WriteInformation(w, pack);
                    WriteElement(w, "Caption", pack.Caption);
                    WriteHowto(w, pack);
                    WriteDerivate(w, pack);
                    WriteRemark(w, pack);
                    WriteLicense(w, pack);
                    WriteUpdate(w, pack);
                }
                w.WriteEndElement();
            }
            w.WriteEndDocument();
            w.Close();
        }
Beispiel #6
0
 private static void ReadDerivate(XmlElement root, AttributePackage pack)
 {
     pack.Derivate = ReadItemsAsForeach(root, "Derivate", new string[] { "Title", "Link", "Comment" });
 }
Beispiel #7
0
 private static void WriteHowto(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Howto, "Howto", new string[] { "Title", "Section", "Caption" });
 }
Beispiel #8
0
 private static void WriteDerivate(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Derivate, "Derivate", new string[] { "Title", "Link", "Comment" });
 }
Beispiel #9
0
 private static void WriteUpdate(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Update, "Update", new string[] { "Title", "Section", "Caption" });
 }
Beispiel #10
0
        private static void ReadInformation(XmlElement root, AttributePackage pack)
        {
            var nodes = root.GetElementsByTagName("Information");
            if (nodes.Count > 0)
            {
                foreach (XmlElement node in nodes[0])
                {
                    switch (node.Name)
                    {
                        case "Title":
                            pack.Title = node.InnerText;
                            break;

                        case "Author":
                            pack.Author = node.InnerText;
                            break;

                        case "CreatedAt":
                            pack.CreatedAt = node.InnerText;
                            break;

                        case "Version":
                            pack.Version = node.InnerText;
                            break;

                        case "Email":
                            pack.Email = node.InnerText;
                            break;

                        case "Tags":
                            pack.Tags = node.InnerText;
                            break;
                    }
                }
            }
        }
Beispiel #11
0
 private static void ReadHowto(XmlElement root, AttributePackage pack)
 {
     pack.Howto = ReadItemsAsForeach(root, "Howto", new string[] { "Title", "Section", "Caption" });
 }
Beispiel #12
0
 private void UnpackingAttributes(AttributePackage pack)
 {
     // AttributePackageの中身をフォームへ流し込む
     author.Text = pack.Author;
     tags.Text = pack.Tags;
     developedName.Text = pack.Title;
     createdAt.Text = pack.CreatedAt;
     captionTextBox.Text = pack.Caption;
     version.Text = pack.Version;
     howtoCaption = Unpacker.UnpackListBoxOnSection(pack.Howto, howtoListBox);
     updateCaption = Unpacker.UnpackListBoxOnSection(pack.Update, updateListBox);
     remarkCaption = Unpacker.UnpackListBox(pack.Remark, remarkListBox);
     derivateCaption = Unpacker.UnpackListBox(pack.Derivate, derivateListBox);
     Unpacker.UnpackLicense(pack.License, licenseCheckedListBox);
 }
Beispiel #13
0
 private static void WriteLicense(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.License, "License", new string[] { "Type" });
 }
Beispiel #14
0
 private static void ReadLicense(XmlElement root, AttributePackage pack)
 {
     pack.License = ReadItemsAsForeach(root, "License", new string[] { "Type" });
 }
Beispiel #15
0
 public ReadPack(XmlElement root, AttributePackage pack)
 {
     this.root = root;
     this.pack = pack;
 }
Beispiel #16
0
 private static void ReadUpdate(XmlElement root, AttributePackage pack)
 {
     pack.Update = ReadItemsAsForeach(root, "Update", new string[] { "Title", "Section", "Caption" });
 }
Beispiel #17
0
 private static void ReadRemark(XmlElement root, AttributePackage pack)
 {
     pack.Remark = ReadItemsAsForeach(root, "Remark", new string[] { "Title", "Caption" });
 }
Beispiel #18
0
 private static void WriteRemark(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Remark, "Remark", new string[] { "Title", "Caption" });
 }
Beispiel #19
0
 private AttributePackage PackingAttributes()
 {
     // パッケージに書き込みを行う
     AttributePackage pack = new AttributePackage();
     pack.Author = author.Text;
     pack.OpenPass = openPass.Text;
     pack.Title = developedName.Text;
     pack.CreatedAt = createdAt.Text;
     pack.Email = mailAddress.Text;
     pack.Caption = captionTextBox.Text;
     pack.Version = version.Text;
     pack.Tags = tags.Text;
     pack.Update = updateCaption.ToArray();
     pack.Howto = howtoCaption.ToArray();
     pack.Derivate = derivateCaption.ToArray();
     pack.Remark = remarkCaption.ToArray();
     pack.License = CheckedListMethod.GetSelectedItems(licenseCheckedListBox, licenseCaption);
     return pack;
 }