Beispiel #1
0
        /// <summary>
        /// セクションコレクションからレイヤーアイテムを作成する。
        /// </summary>
        /// <param name="sections">セクションコレクション。</param>
        /// <param name="baseSection">ベースセクション。</param>
        /// <returns>レイヤーアイテム。</returns>
        private static LayerItem FromSectionsToLayerItem(
            IniFileSectionCollection sections,
            IniFileSection baseSection)
        {
            Debug.Assert(sections != null);
            Debug.Assert(baseSection != null);

            var result = new LayerItem();

            // ベースセクションのプロパティ値設定
            ExoFileItemsConverter.ToProperties(baseSection.Items, ref result);

            // コンポーネント群追加
            var componentSections =
                Enumerable
                .Range(0, int.MaxValue)
                .Select(
                    i =>
                    sections.FirstOrDefault(
                        s => s.Name == baseSection.Name + @"." + i))
                .TakeWhile(s => s != null);

            foreach (var cs in componentSections)
            {
                result.Components.Add(ComponentMaker.FromExoFileItems(cs.Items));
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// レイヤーアイテムのベースセクション配列を取得する。
        /// </summary>
        /// <param name="sections">セクションコレクション。</param>
        /// <returns>ベースセクション配列。</returns>
        private static IniFileSection[] GetLayerItemBaseSections(
            IniFileSectionCollection sections)
        {
            Debug.Assert(sections != null);

            return
                (Enumerable
                 .Range(0, int.MaxValue)
                 .Select(i => sections.FirstOrDefault(s => s.Name == i.ToString()))
                 .TakeWhile(s => s != null)
                 .ToArray());
        }
Beispiel #3
0
        /// <summary>
        /// セクションコレクションからファイルセクションを取得、変換し、
        /// 拡張編集オブジェクトのプロパティ値を設定する。
        /// </summary>
        /// <param name="sections">セクションコレクション。</param>
        /// <param name="target">設定先の拡張編集オブジェクト。</param>
        private static void FromSectionsToFileProperties(
            IniFileSectionCollection sections,
            ExEditObject target)
        {
            Debug.Assert(sections != null);
            Debug.Assert(target != null);

            // ファイルセクション取得
            var section = sections.FirstOrDefault(s => s.Name == SectionNameOfFile);

            if (section == null)
            {
                throw new FormatException(
                          @"The [" + SectionNameOfFile + @"] section is not found.");
            }

            // プロパティ値設定
            ExoFileItemsConverter.ToProperties(section.Items, ref target);
        }
Beispiel #4
0
        /// <summary>
        /// セクションコレクションからレイヤーアイテムを作成する。
        /// </summary>
        /// <param name="sections">セクションコレクション。</param>
        /// <param name="baseSection">ベースセクション。</param>
        /// <returns>レイヤーアイテム。</returns>
        private static LayerItem FromSectionsToLayerItem(
            IniFileSectionCollection sections,
            IniFileSection baseSection)
        {
            Debug.Assert(sections != null);
            Debug.Assert(baseSection != null);

            var result = new LayerItem();

            // ベースセクションのプロパティ値設定
            ExoFileItemsConverter.ToProperties(baseSection.Items, ref result);

            // コンポーネント群追加
            var componentSections =
                Enumerable
                    .Range(0, int.MaxValue)
                    .Select(
                        i =>
                            sections.FirstOrDefault(
                                s => s.Name == baseSection.Name + @"." + i))
                    .TakeWhile(s => s != null);
            foreach (var cs in componentSections)
            {
                result.Components.Add(ComponentMaker.FromExoFileItems(cs.Items));
            }

            return result;
        }
Beispiel #5
0
        /// <summary>
        /// レイヤーアイテムのベースセクション配列を取得する。
        /// </summary>
        /// <param name="sections">セクションコレクション。</param>
        /// <returns>ベースセクション配列。</returns>
        private static IniFileSection[] GetLayerItemBaseSections(
            IniFileSectionCollection sections)
        {
            Debug.Assert(sections != null);

            return
                Enumerable
                    .Range(0, int.MaxValue)
                    .Select(i => sections.FirstOrDefault(s => s.Name == i.ToString()))
                    .TakeWhile(s => s != null)
                    .ToArray();
        }
Beispiel #6
0
        /// <summary>
        /// セクションコレクションからファイルセクションを取得、変換し、
        /// 拡張編集オブジェクトのプロパティ値を設定する。
        /// </summary>
        /// <param name="sections">セクションコレクション。</param>
        /// <param name="target">設定先の拡張編集オブジェクト。</param>
        private static void FromSectionsToFileProperties(
            IniFileSectionCollection sections,
            ExEditObject target)
        {
            Debug.Assert(sections != null);
            Debug.Assert(target != null);

            // ファイルセクション取得
            var section = sections.FirstOrDefault(s => s.Name == SectionNameOfFile);
            if (section == null)
            {
                throw new FormatException(
                    @"The [" + SectionNameOfFile + @"] section is not found.");
            }

            // プロパティ値設定
            ExoFileItemsConverter.ToProperties(section.Items, ref target);
        }