public List <RegionArea> GetRegionAreas()
        {
            RegionAreas = new List <RegionArea>();

            if (!string.IsNullOrEmpty(Text))
            {
                bool searchingRegionStart = true;

                StringLineReader reader = new StringLineReader(Text);
                string           line;
                RegionArea       regionArea = null;
                int index = 0;

                while ((line = reader.ReadLine()) != null)
                {
                    line = line.Trim();

                    if (searchingRegionStart)
                    {
                        if (line.StartsWith("#region", StringComparison.InvariantCulture))
                        {
                            searchingRegionStart = false;
                            regionArea           = new RegionArea(this, index);
                            if (line.Length > 8)
                            {
                                regionArea.RegionName = line.Substring(8);
                            }
                        }
                    }
                    else
                    {
                        if (line.StartsWith("#endregion", StringComparison.InvariantCulture))
                        {
                            searchingRegionStart      = true;
                            regionArea.RegionEndIndex = reader.Position - 1;
                            RegionAreas.Add(regionArea);
                        }
                    }

                    index = reader.Position;
                }
            }

            return(RegionAreas);
        }
示例#2
0
        public List<RegionArea> GetRegionAreas()
        {
            RegionAreas = new List<RegionArea>();

            if (!string.IsNullOrEmpty(Text))
            {
                bool searchingRegionStart = true;

                StringLineReader reader = new StringLineReader(Text);
                string line;
                RegionArea regionArea = null;
                int index = 0;

                while ((line = reader.ReadLine()) != null)
                {
                    line = line.Trim();

                    if (searchingRegionStart)
                    {
                        if (line.StartsWith("#region", StringComparison.InvariantCulture))
                        {
                            searchingRegionStart = false;
                            regionArea = new RegionArea(this, index);
                            if (line.Length > 8) regionArea.RegionName = line.Substring(8);
                        }
                    }
                    else
                    {
                        if (line.StartsWith("#endregion", StringComparison.InvariantCulture))
                        {
                            searchingRegionStart = true;
                            regionArea.RegionEndIndex = reader.Position - 1;
                            RegionAreas.Add(regionArea);
                        }
                    }

                    index = reader.Position;
                }
            }

            return RegionAreas;
        }