private string GetStringValue()
        {
            switch (_dataType)
            {
            case DataType.String:
                return(m_Data);

            case DataType.Long:
                return(AsLong.ToString());

            case DataType.ULong:
                return(AsULong.ToString());

            case DataType.Int:
                return(AsInt.ToString());

            case DataType.UInt:
                return(AsUInt.ToString());

            case DataType.Double:
                return(AsDouble.ToString());

            case DataType.Bool:
                return(AsBool ? "true" : "false");
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
        public override String ToString()
        {
            switch (mType)
            {
            case Type.Null:
                return(null);

            case Type.Boolean:
                return(AsBoolean.ToString());

            case Type.Number:
                return(AsDouble.ToString());

            case Type.String:
                return(AsString);

            case Type.Array:
            case Type.Object:
                StringWriter buf = new StringWriter();
                WriteTo(buf);
                return(buf.ToString());

            default:
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 3
0
        public override string ToString()
        {
            switch (Type)
            {
            case EBPrimitiveTypeEnum.Double:
                return(AsDouble.ToString());

            case EBPrimitiveTypeEnum.Integer:
                return(AsInteger.ToString());

            case EBPrimitiveTypeEnum.ByteArray:
                return(Convert.ToBase64String(AsByteArray));

            default:
                return(AsString);
            }
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            string val = m_Data != null ? m_Data : Value;

            switch (type)
            {
            case BasicType.BOOL:
                return(AsBool ? "true" : "false");

            case BasicType.INT:
                return(AsInt.ToString());

            case BasicType.DOUBLE:
                return(AsDouble.ToString());

            case BasicType.FLOAT:
                return(AsFloat.ToString());

            case BasicType.STRING:
            default:
                return("\"" + Escape(val) + "\"");
            }
        }
Exemplo n.º 5
0
        public void WriteTo(TextWriter output, Int32 indent, Boolean sortNames)
        {
            switch (mType)
            {
            case Type.Null:
                output.Write("null");
                break;

            case Type.Boolean:
                output.Write(AsBoolean ? "true" : "false");
                break;

            case Type.Number:
                output.Write(AsDouble.ToString());
                break;

            case Type.String:
                WriteTo(output, AsString);
                break;

            case Type.Array:
                output.Write('[');
                if ((Count > 1) && (indent != -1))
                {
                    output.WriteLine();
                    indent += 2;
                }
                for (Int32 i = 0; i < Count;)
                {
                    if (Count > 1)
                    {
                        for (Int32 j = 0; j < indent; j++)
                        {
                            output.Write(' ');
                        }
                    }
                    this[i].WriteTo(output, indent);
                    if (++i < Count)
                    {
                        output.Write(',');
                    }
                    if ((Count > 1) && (indent != -1))
                    {
                        output.WriteLine();
                    }
                }
                if ((Count > 1) && (indent != -1))
                {
                    indent -= 2;
                    for (Int32 j = 0; j < indent; j++)
                    {
                        output.Write(' ');
                    }
                }
                output.Write(']');
                break;

            case Type.Object:
                output.Write('{');
                if ((Count > 1) && (indent != -1))
                {
                    output.WriteLine();
                    indent += 2;
                }
                Int32 n = 0;
                Dictionary <String, Value> dict = mValue as Dictionary <String, Value>;
                List <String> keys = new List <String>(dict.Keys);
                if (sortNames)
                {
                    keys.Sort(StringComparer.Ordinal);
                }
                foreach (String key in keys)
                {
                    Value value = dict[key];
                    if (Count > 1)
                    {
                        for (Int32 j = 0; j < indent; j++)
                        {
                            output.Write(' ');
                        }
                    }
                    WriteTo(output, key);
                    output.Write(':');
                    if (indent != -1)
                    {
                        output.Write(' ');
                    }
                    value.WriteTo(output, indent);
                    if (++n < Count)
                    {
                        output.Write(',');
                    }
                    if ((Count > 1) && (indent != -1))
                    {
                        output.WriteLine();
                    }
                }
                if ((Count > 1) && (indent != -1))
                {
                    indent -= 2;
                    for (Int32 j = 0; j < indent; j++)
                    {
                        output.Write(' ');
                    }
                }
                output.Write('}');
                break;

            default:
                throw new InvalidOperationException();
            }
        }