Example #1
0
        /// <summary>
        /// XmlContentsを読み込みます。
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public override XmlContents LoadContents(XmlContentsReadInfo info)
        {
            XmlContents   contents = info.Package.CreateXmlContents("");
            XmlTextReader reader   = info.Reader;

            while (reader.Read())
            {
                if (reader.IsStartElement(contents.ContentsRootElement))
                {
                    string name = reader.GetAttribute(contents.ContentsRootNameAttribute);
                    contents.Name = name;
                    int count = int.Parse(reader.GetAttribute(contents.ContentsRootCountAttribute));
                    reader.Read();
                    for (int i = 0; i < count; i++)
                    {
                        XmlContentsItemReadInfo itemInfo = new XmlContentsItemReadInfo()
                        {
                            Reader       = reader,
                            ItemProvider = contents.ItemProvider,
                            Contents     = contents
                        };
                        XmlContentsItem item = this.LoadContentsItem(itemInfo);

                        contents.AddXmlContentsItem(name + '.' + item.Name, item);
                    }
                    break;
                }
            }
            return(contents);
        }
Example #2
0
        /// <summary>
        /// XmlContentsPackageを読み込みます。
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public override XmlContentsPackage LoadPackage(XmlContentsPackageReadInfo info)
        {
            //XmlContentsPackage package = info.Owner.CreateXmlContentsPackage(info.PackageName);
            //Version判定のために先読みしたPackageを使用する
            XmlContentsPackage package  = info.PreLoadedPackage;
            string             filename = info.FileName;
            XmlTextReader      reader   = new XmlTextReader(filename);

            reader.WhitespaceHandling = WhitespaceHandling.Significant;
            try {
                while (reader.Read())
                {
                    if (reader.IsStartElement(package.PackageRootElement))
                    {
                        int count = int.Parse(reader.GetAttribute(package.PackageRootCountAttribute));
                        for (int i = 0; i < count; i++)
                        {
                            XmlContentsReadInfo contentsInfo = new XmlContentsReadInfo()
                            {
                                Reader  = reader,
                                Package = package
                            };
                            XmlContents contents = this.LoadContents(contentsInfo);
                            package.AddXmlContents(contents);
                        }
                        break;
                    }
                }
            }
            catch (XmlException ex) {
                System.Diagnostics.Debug.WriteLine(ex.GetType().FullName + "\r\n" + ex.Message);
                throw;
            }
            finally {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(package);
        }
Example #3
0
 /// <summary>
 /// 派生クラスでオーバーライドされると、XmlContentsの読み込みを行うメソッドを定義します。
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public abstract XmlContents LoadContents(XmlContentsReadInfo info);