stylesheetparser.cs
来自「FreeTextBox HTML在线编辑器源代码 (C#源代码)阅读一下对掌握」· CS 代码 · 共 45 行
CS
45 行
using System;
using System.Collections;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using FreeTextBoxControls.Common;
namespace FreeTextBoxControls
{
/// <summary>
/// Reads stylesheets for FreeTextBox
/// </summary>
public class StyleSheetParser
{
/// <summary>
/// Finds the stylesheet and reads in correctly formatted styles
/// </summary>
public static string[] ParseStyleSheet(string sheetLocation)
{
sheetLocation = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + sheetLocation.Replace("/","\\");
if (File.Exists(sheetLocation))
{
ArrayList stylesList = new ArrayList();
StreamReader reader = File.OpenText(sheetLocation);
string text = reader.ReadToEnd();
reader.Close();
string rp = @"\.(?<className>[^}]+)\s*{[^}]*}";
Regex regex = new Regex(rp, RegexOptions.IgnoreCase);
MatchCollection mc = regex.Matches(text);
if (mc.Count > 0)
{
for (int i = 0; i < mc.Count; i++)
{
stylesList.Add(mc[i].Groups["className"].Value);
}
}
return (string[]) stylesList.ToArray(typeof(string));
}
else
{
return new string[] {"找不到文件",sheetLocation};
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?