Esempio n. 1
0
        //----------------------------------------------------------------------------------------------------
        public string ToHtmlString()
        {
            string rtn = "";

            if (this.ElementType == ElementTypes.ElementsHolder && (this.Children == null || this.Children.Length < 0))
            {
                this.ElementType = ElementTypes.HtmlHolder;
            }

            string prefix = "";

            for (int i = 1; i < this.TreeLevel; i++)
            {
                prefix += "&nbsp;&nbsp;&nbsp;&nbsp;";
            }
            string suffix = "\n";

            if (1 != 0)
            {
                prefix = ""; suffix = "";
            }


            st attributesStr = st.New("");

            if (this.InputType.Length > 0)
            {
                attributesStr.AppendST(st.New(" type='{0}'").Format1(this.InputType));
            }
            if (this.ModelKey.Length > 0)
            {
                attributesStr.AppendST(st.New(" ModelKey='{0}'").Format1(this.ModelKey));
            }
            if (this.IdClass.Length > 0)
            {
                attributesStr.AppendST(st.New(" IdClass='{0}'").Format1(this.IdClass));
            }
            if (this.ClassesString.Length > 0)
            {
                attributesStr.AppendST(st.New(" class='{0}'").Format1(this.ClassesString));
            }
            if (this.Value.Length > 0)
            {
                attributesStr.AppendST(st.New(" value='{0}'").Format1(this.Value));
            }

            attributesStr = attributesStr.Trim();
            if (this.AttributesStr != "")
            {
                attributesStr.Append(" " + this.AttributesStr);
            }
            if (attributesStr.Length() > 0)
            {
                attributesStr.TheString = " " + attributesStr.TheString;
            }


            if (this.ElementType == ElementTypes.ElementsHolder)
            {
                rtn += st.New("{0}<{1}{2}>{3}").Format4(prefix, this.ElementName, attributesStr.TheString, suffix).TheString;
                for (int i = 0; i < this.Children.Length; i++)
                {
                    rtn += this.Children[i].ToHtmlString();
                }
                rtn += st.New("{0}</{1}>{2}").Format3(prefix, this.ElementName, suffix).TheString;
            }
            else if (this.ElementType == ElementTypes.HtmlHolder)
            {
                rtn += st.New("{0}<{1}{2}>{3}</{1}>{4}").Format5(prefix, this.ElementName, attributesStr.TheString, this.InnerHtml, suffix).TheString;
            }
            else if (this.ElementType == ElementTypes.EmptyElementTag)
            {
                rtn += st.New("{0}<{1}{2} />{3}").Format4(prefix, this.ElementName, attributesStr.TheString, suffix).TheString;
            }
            else if (this.ElementType == ElementTypes.HtmlLiteral)
            {
                rtn += st.New("{0}{1}{2}").Format3(prefix, this.InnerHtml, suffix).TheString;
            }

            return(rtn);
        }
Esempio n. 2
0
        //----------------------------------------------------------------------------------------------------
        public static string TestUnit()
        {
            string unitName = "ASPdb.FrameworkUI.st";
            string passFail = "Failed";
            string rtn      = "";
            st     s        = null;
            string suffix   = "";

            //---------- 01
            s = st.New("AAAaaa BBBbbb CCCccc" + suffix);
            s = s.Replace("BBbb", "--");
            if (s.TheString != "AAAaaa B--b CCCccc")
            {
                rtn += "01) Replace() \n";
            }

            //---------- 02
            s = st.New("aa {0} bb " + suffix);
            if (s.Format1("AA").TheString != "aa AA bb ")
            {
                rtn += "02) Format1() \n";
            }

            s = st.New("aa {0} bb {1} cc " + suffix);
            if (s.Format2("AA", "BB").TheString != "aa AA bb BB cc ")
            {
                rtn += "02) Format2() \n";
            }

            s = st.New("aa {0} bb {1} cc {2} dd " + suffix);
            if (s.Format3("AA", "BB", "CC").TheString != "aa AA bb BB cc CC dd ")
            {
                rtn += "02) Format3() \n";
            }

            s = st.New("aa {0} bb {1} cc {2} dd {3} ee " + suffix);
            if (s.Format4("AA", "BB", "CC", "DD").TheString != "aa AA bb BB cc CC dd DD ee ")
            {
                rtn += "02) Format4() \n";
            }

            s = st.New("aa {0} bb {1} cc {2} dd {3} ee {4} ff " + suffix);
            if (s.Format5("AA", "BB", "CC", "DD", "EE").TheString != "aa AA bb BB cc CC dd DD ee EE ff ")
            {
                rtn += "02) Format5() \n";
            }

            s = st.New("aa {0} bb {1} cc {2} dd {3} ee {4} ff {5} gg " + suffix);
            if (s.Format6("AA", "BB", "CC", "DD", "EE", "FF").TheString != "aa AA bb BB cc CC dd DD ee EE ff FF gg ")
            {
                rtn += "02) Format6() \n";
            }

            s = st.New("aa {0} bb {1} cc {2} dd {3} ee {4} ff {5} gg {6} hh " + suffix);
            if (s.Format7("AA", "BB", "CC", "DD", "EE", "FF", "GG").TheString != "aa AA bb BB cc CC dd DD ee EE ff FF gg GG hh ")
            {
                rtn += "02) Format7() \n";
            }

            s = st.New("aa {0} bb {1} cc {2} dd {3} ee {4} ff {5} gg {6} hh {7} ii " + suffix);
            if (s.Format8("AA", "BB", "CC", "DD", "EE", "FF", "GG", "HH").TheString != "aa AA bb BB cc CC dd DD ee EE ff FF gg GG hh HH ii ")
            {
                rtn += "02) Format8() \n";
            }

            s = st.New("aa {0} bb {1} cc {2} dd {3} ee {4} ff {5} gg {6} hh {7} ii {8} jj " + suffix);
            if (s.Format9("AA", "BB", "CC", "DD", "EE", "FF", "GG", "HH", "II").TheString != "aa AA bb BB cc CC dd DD ee EE ff FF gg GG hh HH ii II jj ")
            {
                rtn += "02) Format9() \n";
            }

            //---------- 03
            s = st.New("AAaa 1234567890 bbBB" + suffix);
            if (s.StartsWith("AAaa 12", false) != true)
            {
                rtn += "03.a) StartsWith() \n";
            }
            if (s.StartsWith("aaaa 12", false) != false)
            {
                rtn += "03.b) StartsWith() \n";
            }
            if (s.StartsWith("aaaa 12", true) != true)
            {
                rtn += "03.c) StartsWith() \n";
            }

            if (s.EndsWith("90 bbBB", false) != true)
            {
                rtn += "03.d) EndsWith() \n";
            }
            if (s.EndsWith("90 bbbb", false) != false)
            {
                rtn += "03.e) EndsWith() \n";
            }
            if (s.EndsWith("90 bbbb", true) != true)
            {
                rtn += "03.f) EndsWith() \n";
            }

            //---------- 04
            s = st.New("12345678901234567890" + suffix);
            if (s.TruncateLeft(0).TheString != "12345678901234567890")
            {
                rtn += "04.a) TruncateLeft() \n";
            }
            if (s.TruncateLeft(21).TheString != "")
            {
                rtn += "04.b) TruncateLeft() \n";
            }
            if (s.TruncateLeft(5).TheString != "678901234567890")
            {
                rtn += "04.c) TruncateLeft() \n";
            }

            if (s.TruncateRight(0).TheString != "12345678901234567890")
            {
                rtn += "04.d) TruncateRight() \n";
            }
            if (s.TruncateRight(21).TheString != "")
            {
                rtn += "04.e) TruncateRight() \n";
            }
            if (s.TruncateRight(5).TheString != "123456789012345")
            {
                rtn += "04.f) TruncateRight() \n";
            }

            //---------- 05
            s = st.New("a12345678901234567890z" + suffix);
            if (s.IfStartsWith_Truncate("A12345", true).TheString != "678901234567890z")
            {
                rtn += "05.a) IfStartsWith_Truncate() \n";
            }
            if (s.IfStartsWith_Truncate("A12345", false).TheString != "a12345678901234567890z")
            {
                rtn += "05.b) IfStartsWith_Truncate() \n";
            }
            if (s.IfStartsWith_Truncate("a12345", false).TheString != "678901234567890z")
            {
                rtn += "05.c) IfStartsWith_Truncate() \n";
            }

            if (s.IfEndsWith_Truncate("7890Z", true).TheString != "a1234567890123456")
            {
                rtn += "05.d) IfEndsWith_Truncate() \n";
            }
            if (s.IfEndsWith_Truncate("7890Z", false).TheString != "a12345678901234567890z")
            {
                rtn += "05.d) IfEndsWith_Truncate() \n";
            }
            if (s.IfEndsWith_Truncate("7890z", false).TheString != "a1234567890123456")
            {
                rtn += "05.d) IfEndsWith_Truncate() \n";
            }

            //---------- 06
            s = st.New("AAAxBBBxCCCXDDDXEEE" + suffix);
            var arr = s.Split("x", false);

            if (arr.Length != 3)
            {
                rtn += "06.a) Split() \n";
            }
            arr = s.Split("x", true);
            if (arr.Length != 5)
            {
                rtn += "06.b) Split() \n";
            }
            if (arr[0].TheString != "AAA")
            {
                rtn += "06.c) Split() \n";
            }
            if (arr[4].TheString != "EEE")
            {
                rtn += "06.d) Split() \n";
            }

            //---------- 07
            s = st.New("   Aa Aa   " + suffix);
            if (s.Trim().TheString != "Aa Aa")
            {
                rtn += "07.a) Trim() \n";
            }
            if (s.ToUpper().TheString != "   AA AA   ")
            {
                rtn += "07.b) ToUpper() \n";
            }
            if (s.ToLower().TheString != "   aa aa   ")
            {
                rtn += "07.c) ToLower() \n";
            }

            //---------- 08
            s = st.New("aaa aaa" + suffix);
            s.Append(" aaa");
            if (s.TheString != "aaa aaa aaa")
            {
                rtn += "08.a) Append() \n";
            }
            s.AppendST(st.New(" bbb"));
            if (s.TheString != "aaa aaa aaa bbb")
            {
                rtn += "08.b) AppendST() \n";
            }

            if (rtn == "")
            {
                passFail = "Passed";
            }
            return(st.New("{0} : {1} \n{2}").Format3(unitName, passFail, rtn).TheString);
        }