当前位置: 首页>>代码示例>>C#>>正文


C# PropertyList.RemoveEntry方法代码示例

本文整理汇总了C#中PropertyList.RemoveEntry方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyList.RemoveEntry方法的具体用法?C# PropertyList.RemoveEntry怎么用?C# PropertyList.RemoveEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropertyList的用法示例。


在下文中一共展示了PropertyList.RemoveEntry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        /// <summary>
        /// Load the config file and reads it's contents.
        /// </summary>
        public void Load()
        {
            if (!_fileInfo.Exists)
                _fileInfo.Create().Close();
            using (TextReader reader = _fileInfo.OpenText())
            {

                var list = new PropertyList(string.Empty);
                list.Loaded = true;

                Regex groupStartRegex = new Regex(REGEX_GROUP_START);
                Regex keyValueRegex = new Regex(REGEX_KEY_VALUE);
                Regex arrayValueRegex = new Regex(REGEX_ARRAY_VALUE);
                Regex blockCommentRegex = new Regex(REGEX_COMMENT);
                Regex commentRegex = new Regex(REGEX_COMMENT);
                Regex concatRegex = new Regex(REGEX_CONCAT);
                Regex groupEndRegex = new Regex(REGEX_GROUP_END);
                Regex newLineRegex = new Regex(REGEX_NEW_LINE);
                Regex invalidRegex = new Regex(REGEX_INVALID);

                string allText = reader.ReadToEnd();
                PropertyEntry previousValueEntry = null;

                while (!allText.IsNullEmptyOrWhite())
                {
                    PropertyEntry newEntry = null;
                    string result = null;
                    var groupStartGroups = groupStartRegex.Match(allText).Groups;
                    if (groupStartGroups["r"].Success)
                    {
                        result = groupStartGroups["r"].Value;
                        string key = groupStartGroups["k"].Value;
                        string comment = groupStartGroups["c"].Value;
                        var newList = new PropertyList(key, comment);
                        newList.Parent = list;
                        list = newList;
                        previousValueEntry = null;
                    }
                    var keyValueGroups = keyValueRegex.Match(allText).Groups;
                    if (result == null && keyValueGroups["r"].Success)
                    {
                        result = keyValueGroups["r"].Value;
                        string key = keyValueGroups["k"].Value;
                        string value = keyValueGroups["v"].Value;
                        string comment = keyValueGroups["c"].Value;
                        newEntry = new PropertyEntry(key, value, comment);
                        previousValueEntry = newEntry;
                    }
                    var arrayValueGroups = arrayValueRegex.Match(allText).Groups;
                    if (result == null && arrayValueGroups["r"].Success)
                    {
                        result = arrayValueGroups["r"].Value;
                        string value = arrayValueGroups["v"].Value;
                        string comment = arrayValueGroups["c"].Value;
                        newEntry = new ArrayEntry(value, comment);
                        previousValueEntry = newEntry;
                    }
                    var concatGroups = concatRegex.Match(allText).Groups;
                    if (result == null && concatGroups["r"].Success)
                    {
                        if (previousValueEntry != null)
                        {
                            result = concatGroups["r"].Value;
                            string value = concatGroups["v"].Value;
                            string comment = concatGroups["c"].Value;
                            if (previousValueEntry is ConcatenatedEntry)
                            {
                                (previousValueEntry as ConcatenatedEntry).AddConcat(value, comment);
                            }
                            else
                            {
                                list.RemoveEntry(previousValueEntry);
                                newEntry = new ConcatenatedEntry(
                                    previousValueEntry.Key,
                                    new string[]{ previousValueEntry.StringValue, value },
                                    new string[]{ previousValueEntry.Comment, comment });
                                newEntry.LineNumber = previousValueEntry.LineNumber;
                                previousValueEntry = newEntry;
                            }
                        }
                    }
                    var blockCommentGroups = blockCommentRegex.Match(allText).Groups;
                    if (result == null && blockCommentGroups["r"].Success)
                    {
                        result = blockCommentGroups["r"].Value;
                        string comment = blockCommentGroups["c"].Value;
                        newEntry = new BlockCommentEntry(comment);
                    }
                    var commentGroups = commentRegex.Match(allText).Groups;
                    if (result == null && commentGroups["r"].Success)
                    {
                        result = commentGroups["r"].Value;
                        string comment = commentGroups["c"].Value;
                        newEntry = new CommentEntry(comment);
                    }
                    var groupEndGroups = groupEndRegex.Match(allText).Groups;
                    if (result == null && groupEndGroups["r"].Success)
//.........这里部分代码省略.........
开发者ID:Tagette,项目名称:SimplifiedProperties,代码行数:101,代码来源:PropertyFile.cs


注:本文中的PropertyList.RemoveEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。