Beispiel #1
0
        //private static void Main(string[] args)
        //{
        //  // ArticleBLL

        //    ArticleBLL articleBll = Factory.BusinessFactory.CreateBll<ArticleBLL>();
        //   DataTable DT = articleBll.GetPaged(1, 1).Result;
        //   foreach (var s in DT.Rows)
        //   {
        //       foreach (var s1 in DT.Columns)
        //       {
        //           Console.WriteLine(((DataRow)s)[s1.ToString()]);
        //       }
        //   }
        //    Console.Read();
        //}

        //PageTemplateBLL templateBll = Factory.BusinessFactory.CreateBll<PageTemplateBLL>();
        //Dictionary<string, object> dictionary = new Dictionary<string, object>();
        //dictionary.Add("ID", templateId);
        //PageTemplate template = templateBll.Get(dictionary);

        public static void CreateTest()
        {
            //string filePath = AppDomain.CurrentDomain.BaseDirectory + "template\\index_template.htm";
            //TemplateManager tm = TemplateManager.FromFile(filePath, false);
            string          data = "<div><#uptag  tagtype=\"01\" clsid=\"001\" pagesize=\"2\" pagecount=\"3\" viewedit=\"1\" id=\"dataId007\"  var=\"d\" index=\"i\"><#/uptag>  ${art.Title} ${Url} <ul><li><#abc  m=\"1\"><#/abc></li></ul></div>";
            TemplateManager tm   = TemplateManager.FromString(data, false);
            UserTemplate    ut   = UserTemplate.FromString("", data);

            Console.WriteLine(ut.Elements.Count.ToString());
            foreach (var e in ut.Elements)
            {
                //Text
                var text = e as Text;
                if (text != null)
                {
                    Console.WriteLine("Text:{0},Col:{1},Line:{2}", text.Data, text.Col.ToString(), text.Line.ToString());
                }
                Console.WriteLine("\r");

                //Tag
                var tag = e as Tag;
                if (tag != null)
                {
                    Console.WriteLine("TagName:{0},Col:{1},Line:{2}", tag.Name, tag.Col.ToString(), tag.Line.ToString());
                    Console.WriteLine("tag attributes start ....");
                    foreach (var m in tag.Attributes)
                    {
                        Console.WriteLine(m.Name);

                        if (m.Expression is StringLiteral)
                        {
                            var sl = (StringLiteral)m.Expression;
                            Console.WriteLine("StringLiteral:{0}", sl.Content);
                        }
                        if (m.Expression is FieldAccess)
                        {
                            var fa = (FieldAccess)m.Expression;
                            Console.WriteLine("FieldAccess:{0}", fa.Field);
                        }
                    }
                    Console.WriteLine("tag attributes end ....");
                    Console.WriteLine("\n");
                }

                //Expression
                var ex = e as Expression;
                if (ex != null)
                {
                    Console.WriteLine("Expression Start...");
                    if (ex is StringLiteral)
                    {
                        var sl = (StringLiteral)ex;
                        Console.WriteLine("StringLiteral:{0}", sl.Content);
                    }
                    if (ex is FieldAccess)
                    {
                        var fa = (FieldAccess)ex;
                        if (fa.Exp is Name)
                        {
                            var name = (Name)fa.Exp;
                            Console.WriteLine("Field's Exp is {0}", name.Id);
                        }
                        Console.WriteLine("FieldAccess:{0}", fa.Field);
                    }
                    if (ex is Name)
                    {
                        var name = (Name)ex;
                        Console.WriteLine("Name's Id:{0}", name.Id);
                    }
                    Console.WriteLine("Expression End....");
                    Console.WriteLine("\r");
                }

                var tagclose = e as TagClose;
                if (tagclose != null)
                {
                    Console.WriteLine("TagClose Start...");
                    Console.WriteLine("TagClose:{0},Col:{1},Line:{1}", tagclose.Name, tagclose.Col.ToString(), tagclose.Line.ToString());
                    Console.WriteLine("TagClose End...");
                }
            }

            Console.ReadKey();
        }