Esempio n. 1
0
            /// <summary>
            /// 输出Obj,如果是数组,也会加入数组
            /// </summary>
            private HowSimpleObject OutObj()
            {
                var res = new HowSimpleObject(hsoBuf);

                if (isAry)
                {
                    objs.Add(res);
                }
                hsoBuf = new Dictionary <string, HowSimpleItem>();
                //Console.WriteLine("[[out obj]]" + hsoBuf.ToString());
                return(res);
            }
Esempio n. 2
0
 private void FillObj(HowSimpleObject sobj)
 {
     foreach (var item in sobj.inner)
     {
         switch (item.Value.ItemType)
         {
             case HowSimpleItemType.Value:
                 DrawVal(item.Key, item.Value as HowSimpleValueItem);
                 break;
             case HowSimpleItemType.Dict:
                 DrawDict(item.Key, item.Value as HowSimpleDictionaryItem);
                 break;
             case HowSimpleItemType.Ary:
                 DrawAry(item.Key, item.Value as HowSimpleArrayItem);
                 break;
             default:
                 break;
         }
     }
 }
Esempio n. 3
0
 public Serializer(IPaper paper_, HowSimpleObject obj_)
 {
     paper = paper_;
     obj = obj_;
     isAry = false;
 }
Esempio n. 4
0
 public static void WriteObj(HowSimpleObject obj, IPaper paper)
 {
     var srl = new Serializer(paper, obj);
     srl.SerializeObj();
 }
Esempio n. 5
0
 public static void WriteObj(HowSimpleObject obj, StreamWriter sw)
 {
     var paper = new StreamWriterPaper(sw);
     WriteObj(obj, paper);
 }
Esempio n. 6
0
 public static void WriteObj(HowSimpleObject obj, StringBuilder sb)
 {
     var paper = new StringBuilderPaper(sb);
     WriteObj(obj, paper);
 }
Esempio n. 7
0
            bool S1()
            {
                ClearComment();
                var rdres = article.Cur();

                article.Next();

                if (rdres.HasValue)
                {
                    var cch = rdres.Value;
                    var cht = CharClassification(cch);
                    if (isAry)//读取数组的状态机
                    {
                        if (IsASP(cht))
                        {
                            return(S1());
                        }
                        else if (cch == '}')
                        {
                            OutObj();
                            return(S0());
                        }
                        else if (cht == ChType.CH)
                        {
                            eleBuf.Append(cch);
                            return(S2());
                        }
                        else if (cch == '"')
                        {
                            return(SV1());
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else//读取单独对象的状态机
                    {
                        if (IsASP(cht))
                        {
                            return(S1());
                        }
                        else if (cht == ChType.CH)
                        {
                            eleBuf.Append(cch);
                            return(S2());
                        }
                        else if (cch == '"')
                        {
                            return(SV1());
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    if (isAry)
                    {
                        return(false);
                    }
                    else
                    {
                        resultHSO = OutObj();
                        return(true);
                    }
                }
            }