コード例 #1
0
ファイル: SprotoObject.cs プロジェクト: mengtest/mysproto
        // not support recursive SprotoObject
        public override string ToString()
        {
            string val;

            if (null == this.val)
            {
                val = null;
            }
            else
            {
                string typename = SprotoObject.TypeOf(this.val);
                if (typename == "integer" ||
                    typename == "boolean" ||
                    typename == "string" ||
                    typename == "binary" ||
                    typename == "double")
                {
                    val = this.val.ToString();
                }
                else if (typename == "integer_list")
                {
                    val = SprotoHelper.DumpList <Int64>(this.val as List <Int64>);
                }
                else if (typename == "boolean_list")
                {
                    val = SprotoHelper.DumpList <bool>(this.val as List <bool>);
                }
                else if (typename == "string_list")
                {
                    val = SprotoHelper.DumpList <string>(this.val as List <string>);
                }
                else if (typename == "binary_list")
                {
                    val = SprotoHelper.DumpList <byte[]>(this.val as List <byte[]>);
                }
                else if (typename == "double_list")
                {
                    val = SprotoHelper.DumpList <double>(this.val as List <double>);
                }
                else if (typename == "object_list")
                {
                    val = SprotoHelper.DumpList <SprotoObject>(this.val as List <SprotoObject>);
                }
                else if (typename == "integer_object_dict")
                {
                    val = SprotoHelper.DumpDict <Int64, SprotoObject>(this.val as Dictionary <Int64, SprotoObject>);
                }
                else if (typename == "string_object_dict")
                {
                    val = SprotoHelper.DumpDict <string, SprotoObject>(this.val as Dictionary <string, SprotoObject>);
                }
                else if (typename == "boolean_object_dict")
                {
                    val = SprotoHelper.DumpDict <bool, SprotoObject>(this.val as Dictionary <bool, SprotoObject>);
                }
                else
                {
                    val = "unknow";
                }
            }
            string fields = SprotoHelper.DumpDict <string, SprotoObject>(this.fields);

            return("{" + String.Format("type={0},val={1},fields={2}", this.type, val, fields) + "}");
        }