示例#1
0
        public override void Start()
        {
            const string T = "用于调试字符串,字符串。";

            Logger.Info("子字符串");

            Logger.Write(Str.Remove(T, 2, 1));
            Logger.Write(Str.RemoveEnd(T, 2));
            Logger.Write(Str.RemoveStart(T, 2));
            Logger.Write(Str.RemoveBefore(T, '调'));
            Logger.Write(Str.RemoveAfter(T, '调'));

            Logger.Write(Str.Substring(T, 1));
            Logger.Write(Str.TrimToLength(T, 3, "..."));

            string T3 = "aa-asd-aa";

            Logger.Info("长度不变的处理");

            Logger.Write(T3 = Str.Capitalize(T3));
            Logger.Write(Str.UnCapitalize(T3));
            Logger.Write(T3 = Str.ToCamel(T3));
            Logger.Write(T3 = Str.ToPascal(T3));
            Logger.Write(T3 = Str.Hyphenate(T3));
            Logger.Write(Str.ToLength(T3, 10));
            Logger.Write(Str.ToLength(T3, 8));

            Logger.Info("字符性质");

            Logger.Write(Str.CLength(T));
            Logger.Write(Str.Count(T, '用'));
            Logger.Write(Str.Count("aaabbbaaaa", "aa"));

            Logger.Info("编码");

            Logger.Write(int.Parse("12fe", System.Globalization.NumberStyles.HexNumber));


            Logger.Write(Str.HtmlEncode("<br>sdasd<div>sdasd</div>"));

            Logger.Write(Str.HtmlToString("<br>sdasd<div>sdasd</div>"));

            Logger.Write(Str.HtmlNoScript("<script>ddd</script><div onclick='alert()' style='height:expression(alert());font-size:2' sa='ggg'></div>"));

            Logger.Write(Str.UnicodeDecode(Str.UnicodeEncode("不飞asdaa?=s", "%u"), "%u"));
            Logger.Write(Str.UrlEncode("不飞asdaa?=s"));
            Logger.Write(Str.Unescape(Str.Escape("不飞asdaa?=s ")));


            ArrayString s = new ArrayString("ss,ss,dasd,asd", ',');

            s.Add("asfdsf");
            s.RemoveAt(0);
            Logger.Write(s.Count);

            Logger.Write(s.Length);

            Logger.Write(s.ToString());
        }
示例#2
0
        public override void Start()
        {
            Logger.Start("数组字符串");


            ArrayString a = new ArrayString("hello,Py,world", ',');

            a.Add("ok");
            a.RemoveAt(0);

            Logger.Write("hello,Py,world  + ok  ->   {0}", a.ToString());

            a[2] = "1";

            Logger.Write("设置a[2]后 , 字符串为     {0}", a.ToString());
        }
示例#3
0
文件: CoreDemo.cs 项目: tvrjcf/Demo
        /// <summary>
        /// 开始测试。
        /// </summary>
        public override void Start()
        {
            #region 准备

            Logger.Info("Core 是 库的重要部分, 提供了简化代码量的方法。");

            #endregion

            #region QC

            Logger.Info("QC 提供了常用转换函数");

            Logger.Write(QC.IP(QC.IP("127.158.0.0")));


            #endregion

            #region RegExp

            Logger.Info("正则表达式");

            Logger.Write(RegExp.Test("4", RegExp.Number));

            #endregion

            #region Check

            Logger.Info("Check  容纳了检查字符串的方法");

            Logger.Write(" Check.CheckRequestString(\"asdag\'g1=1\")  ->   {0}", Check.CheckRequestString("asdag'g1=1"));
            Logger.Write(" Check.IsIP(\"192.168.1.1\")  ->   {0}", Check.IsIP("192.168.1.1"));

            #endregion

            #region Str

            Logger.Info("字符串");

            DateTime dt = DateTime.Now.Add(new TimeSpan(4, 0, 0, -1));

            Logger.Write(Str.ToTimeString(dt));

            #endregion

            #region ArrayString

            Logger.Info("ArrayString 数组字符串");

            ArrayString s = new ArrayString("aaa,bbb,ccc", ',');

            Logger.Write(s[0]);

            s[1] = "bbbb";

            Logger.Write(s);

            s.Add("sss");

            Logger.Write(s);

            s.RemoveAt(1);

            Logger.Write(s);

            s.Clear();

            Logger.Write(s == "");

            s += "aaa,ddd,ccc";

            Logger.Write(s);

            s.Sort();

            Logger.Write(s);

            s -= "aaa";

            Logger.Write(s);

            s -= s;

            Logger.Write(s);

            Logger.Write(ArrayString.ReplaceValue("aaa,aaaaa,wqe,aaa,sfd,aaa", "aaa", "gg", ","));

            #endregion

            #region StringHelper

            Logger.Info("使用 StringHelper辅助字符串");

            StringHelper sh = new StringHelper();

            string input = @"用法 223, 三大殿,固定首发";

            sh.Pattern = @"用法{$N}, 三大殿,{$F}";


            sh.Match(input);


            foreach (string k in sh)
            {
                Logger.Write("{0}  ->    {1}", k, sh[k]);
            }

            #endregion
        }