예제 #1
0
        /// <summary>
        /// IniFileSectionCollection オブジェクトへセクションを追加する。
        /// </summary>
        /// <param name="dest">IniFileSectionCollection オブジェクト。</param>
        /// <param name="sectionName">セクション名。</param>
        private static void AddSection(IniFileSectionCollection dest, string sectionName)
        {
            Debug.Assert(dest != null);

            IniFileSection section = null;

            try
            {
                section = new IniFileSection(sectionName);
            }
            catch (Exception ex)
            {
                throw new FormatException(@"Invalid section name.", ex);
            }

            try
            {
                dest.Add(section);
            }
            catch (Exception ex)
            {
                throw new FormatException(
                          "The section (\"" + sectionName + "\") is duplicated.",
                          ex);
            }
        }
예제 #2
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;
        }
예제 #3
0
        /// <summary>
        /// IniFileSectionCollection オブジェクトへセクションを追加する。
        /// </summary>
        /// <param name="dest">IniFileSectionCollection オブジェクト。</param>
        /// <param name="sectionName">セクション名。</param>
        private static void AddSection(IniFileSectionCollection dest, string sectionName)
        {
            Debug.Assert(dest != null);

            IniFileSection section = null;

            try
            {
                section = new IniFileSection(sectionName);
            }
            catch (Exception ex)
            {
                throw new FormatException(@"Invalid section name.", ex);
            }

            try
            {
                dest.Add(section);
            }
            catch (Exception ex)
            {
                throw new FormatException(
                    "The section (\"" + sectionName + "\") is duplicated.",
                    ex);
            }
        }