Ejemplo n.º 1
0
 public void Add(object key, object value, bool parse)
 {
     if (!(key is string))
     {
         throw new Exception("添加进列表的KEY必须为字符串");
     }
     this.m_keychange = true;
     if (value is CLSVData)
     {
         this.m_ht_data.Add(key, value);
     }
     else if (parse && (value is string))
     {
         this.m_ht_data.Add(key, (string)value);
     }
     else if ((value is ArrayList) && !(value is CLSArrayList))
     {
         ArrayList    list  = (ArrayList)value;
         CLSArrayList list2 = new CLSArrayList();
         foreach (object obj2 in list)
         {
             list2.Add(obj2);
         }
         this.m_ht_data.Add(key, list2);
     }
     else
     {
         this.m_ht_data.Add(key, new CLSVData(this, value));
     }
 }
Ejemplo n.º 2
0
        private string GetJsonValueStr(CLSVData value)
        {
            StringBuilder builder = new StringBuilder();

            if (value.ValueIsNull)
            {
                builder.Append("null");
            }
            else if (CLSVData.Helper_CCDecimal(value.Value))
            {
                builder.Append(value.ValueDecimal);
            }
            else if (value.Value is bool)
            {
                builder.Append(this.GetJsonValueStr_Boolean(value.ValueBool));
            }
            else if (value.Value is string)
            {
                builder.Append(this.GetJsonValueStr_String(value.Value as string));
            }
            else if (value.Value is DateTime)
            {
                builder.Append(this.GetJsonValueStr_String(value.Value.ToString()));
            }
            else if (value.Value is CLSHashtable)
            {
                builder.Append(this.GetJsonValueStr_CLSHashtable(value.Value as CLSHashtable));
            }
            else if (value.Value is CLSArrayList)
            {
                builder.Append(this.GetJsonValueStr_Array(value.Value as CLSArrayList));
            }
            else if (value.Value is ArrayList)
            {
                CLSArrayList arr = new CLSArrayList();
                foreach (object obj2 in value.ValueArrayList)
                {
                    arr.Add(obj2);
                }
                builder.Append(this.GetJsonValueStr_Array(arr));
            }
            else if (value.Value is IEnumerable)
            {
                CLSArrayList list2 = new CLSArrayList();
                foreach (object obj3 in (IEnumerable)value.Value)
                {
                    list2.Add(obj3);
                }
                builder.Append(this.GetJsonValueStr_Array(list2));
            }
            else
            {
                builder.Append(this.GetJsonValueStr_Default(value.Value));
            }
            return(builder.ToString());
        }
Ejemplo n.º 3
0
        private string GetJsonValueStr_Array(CLSArrayList arr)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("[");
            foreach (CLSVData data in arr)
            {
                builder.Append(this.GetJsonValueStr(data));
                builder.Append(",");
            }
            if (arr.Count > 0)
            {
                builder.Remove(builder.Length - 1, 1);
            }
            builder.Append("]");
            return(builder.ToString());
        }
Ejemplo n.º 4
0
        private static void Func_ParseNode(CLSHashtable cht, XmlNodeList Nodes, object opt)
        {
            foreach (XmlNode node in Nodes)
            {
                string str = ((node.Attributes == null) || (node.Attributes["type"] == null)) ? "" : node.Attributes["type"].Value;
                string key = null;
                if (cht.KeyRule == 2)
                {
                    string str3 = ((node.Attributes == null) || (node.Attributes["N"] == null)) ? "" : node.Attributes["N"].Value;
                    if (((str3 == "") && Helper_WishName(node)) && !(opt is ArrayList))
                    {
                        continue;
                    }
                    if (Helper_WishName(node))
                    {
                        key = str3;
                    }
                }
                else
                {
                    if (cht.KeyRule != 1)
                    {
                        throw new Exception("Key Rule Error");
                    }
                    key = node.Name.StartsWith("K_") ? node.Name.Remove(0, 2) : node.Name;
                }
                if (str != "")
                {
                    switch (str)
                    {
                    case "al":
                    {
                        CLSArrayList list = new CLSArrayList();
                        Func_ParseNode(cht, node.ChildNodes, list);
                        if (opt is CLSHashtable)
                        {
                            ((CLSHashtable)opt).Add(key, list);
                        }
                        else if (opt is Hashtable)
                        {
                            ((Hashtable)opt).Add(key, list);
                        }
                        else if (opt is ArrayList)
                        {
                            ((ArrayList)opt).Add(list);
                        }
                        goto Label_02B9;
                    }

                    case "ht":
                    {
                        CLSHashtable hashtable = new CLSHashtable();
                        Func_ParseNode(cht, node.ChildNodes, hashtable);
                        if (opt is CLSHashtable)
                        {
                            ((CLSHashtable)opt).Add(key, hashtable);
                            goto Label_02B9;
                        }
                        if (opt is Hashtable)
                        {
                            ((Hashtable)opt).Add(key, hashtable);
                        }
                        else if (opt is ArrayList)
                        {
                            ((ArrayList)opt).Add(hashtable);
                        }
                        break;
                    }
                    }
                    Label_02B9 :;
                }
                else if (opt is ArrayList)
                {
                    ((ArrayList)opt).Add(node.InnerText);
                }
                else if (opt is CLSHashtable)
                {
                    ((CLSHashtable)opt).Add(key, node.InnerText, true);
                }
                else if (opt is Hashtable)
                {
                    ((Hashtable)opt).Add(key, node.InnerText);
                }
            }
        }
Ejemplo n.º 5
0
        private static void Func_NS_ParseNode(CLSHashtable cht, bool isroot, XmlNode node, CLSVData clsvopt)
        {
            string name = node.Name;

            if (Helper_NS_IsParent(node))
            {
                string str2 = name;
                if (!(str2 == "dict"))
                {
                    if (str2 == "array")
                    {
                        if (isroot)
                        {
                            cht["array"] = new CLSArrayList();
                            clsvopt      = cht["array"];
                        }
                        for (int i = 0; i < node.ChildNodes.Count; i++)
                        {
                            XmlNode node4 = node.ChildNodes[i];
                            if (Helper_NS_IsParent(node4))
                            {
                                CLSVData data3 = Helper_NS_GetParentObj(cht, node4);
                                clsvopt.ValueCLSArrayList.Add(data3.ValueRaw);
                                Func_NS_ParseNode(cht, false, node4, data3);
                            }
                            else
                            {
                                CLSVData data4 = Helper_NS_GetChildObj(cht, node4);
                                clsvopt.ValueCLSArrayList.Add(data4.ValueRaw);
                            }
                        }
                    }
                }
                else if ((node.ChildNodes.Count != 0) && ((node.ChildNodes.Count % 2) <= 0))
                {
                    for (int j = 0; j < node.ChildNodes.Count; j += 2)
                    {
                        XmlNode node2 = node.ChildNodes[j];
                        XmlNode node3 = node.ChildNodes[j + 1];
                        if (node2.Name == "key")
                        {
                            if (Helper_NS_IsParent(node3))
                            {
                                CLSVData data = Helper_NS_GetParentObj(cht, node3);
                                if (isroot)
                                {
                                    cht[node2.InnerText] = data;
                                }
                                else
                                {
                                    clsvopt[node2.InnerText] = data;
                                }
                                Func_NS_ParseNode(cht, false, node3, data);
                            }
                            else
                            {
                                CLSVData data2 = Helper_NS_GetChildObj(cht, node3);
                                if (isroot)
                                {
                                    cht[node2.InnerText] = data2;
                                }
                                else
                                {
                                    clsvopt[node2.InnerText] = data2;
                                }
                            }
                        }
                    }
                }
            }
        }