示例#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");
 }
示例#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 = "";
     }
 }
示例#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();
 }
示例#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;
        }
示例#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();
        }
示例#6
0
 private static void ReadDerivate(XmlElement root, AttributePackage pack)
 {
     pack.Derivate = ReadItemsAsForeach(root, "Derivate", new string[] { "Title", "Link", "Comment" });
 }
示例#7
0
 private static void WriteHowto(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Howto, "Howto", new string[] { "Title", "Section", "Caption" });
 }
示例#8
0
 private static void WriteDerivate(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Derivate, "Derivate", new string[] { "Title", "Link", "Comment" });
 }
示例#9
0
 private static void WriteUpdate(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Update, "Update", new string[] { "Title", "Section", "Caption" });
 }
示例#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;
                    }
                }
            }
        }
示例#11
0
 private static void ReadHowto(XmlElement root, AttributePackage pack)
 {
     pack.Howto = ReadItemsAsForeach(root, "Howto", new string[] { "Title", "Section", "Caption" });
 }
示例#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);
 }
示例#13
0
 private static void WriteLicense(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.License, "License", new string[] { "Type" });
 }
示例#14
0
 private static void ReadLicense(XmlElement root, AttributePackage pack)
 {
     pack.License = ReadItemsAsForeach(root, "License", new string[] { "Type" });
 }
示例#15
0
 public ReadPack(XmlElement root, AttributePackage pack)
 {
     this.root = root;
     this.pack = pack;
 }
示例#16
0
 private static void ReadUpdate(XmlElement root, AttributePackage pack)
 {
     pack.Update = ReadItemsAsForeach(root, "Update", new string[] { "Title", "Section", "Caption" });
 }
示例#17
0
 private static void ReadRemark(XmlElement root, AttributePackage pack)
 {
     pack.Remark = ReadItemsAsForeach(root, "Remark", new string[] { "Title", "Caption" });
 }
示例#18
0
 private static void WriteRemark(XmlTextWriter w, AttributePackage pack)
 {
     WriteItems(w, pack.Remark, "Remark", new string[] { "Title", "Caption" });
 }
示例#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;
 }