stylesheetparser.cs

来自「Freetextbox是优秀的在线编辑器」· CS 代码 · 共 37 行

CS
37
字号
namespace FreeTextBoxControls.Support
{
    using System;
    using System.Collections;
    using System.IO;
    using System.Text.RegularExpressions;
    using System.Web;

    public class StyleSheetParser
    {
        public static string[] ParseStyleSheet(string sheetLocation)
        {
            sheetLocation = (HttpContext.Current.Request.PhysicalApplicationPath + sheetLocation.Replace("/", @"\")).Replace(@"\\", @"\");
            if (File.Exists(sheetLocation))
            {
                ArrayList list1 = new ArrayList();
                StreamReader reader1 = File.OpenText(sheetLocation);
                string text1 = reader1.ReadToEnd();
                reader1.Close();
                string text2 = @"\.(?<className>[^}]+)\s*{[^}]*}";
                MatchCollection collection1 = new Regex(text2, RegexOptions.IgnoreCase).Matches(text1);
                if (collection1.Count > 0)
                {
                    for (int num1 = 0; num1 < collection1.Count; num1++)
                    {
                        list1.Add(collection1[num1].Groups["className"].Value);
                    }
                }
                return (string[]) list1.ToArray(typeof(string));
            }
            return new string[] { "file not found.", sheetLocation };
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?