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);
        }
示例#2
0
文件: JSON.cs 项目: kgober/SEL810
        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();
            }
        }
示例#3
0
        public override int GetHashCode()
        {
            var HashCode = 674144506;

            HashCode = HashCode * -1521134295 + Type.GetHashCode();
            HashCode = HashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(AsString);

            HashCode = HashCode * -1521134295 + AsInteger.GetHashCode();
            HashCode = HashCode * -1521134295 + AsDouble.GetHashCode();
            if (AsByteArray != null)
            {
                HashCode = HashCode * -1521134295 + AsByteArray.ToString().GetHashCode();
            }
            return(HashCode);
        }
示例#4
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);
            }
        }
示例#5
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) + "\"");
            }
        }
示例#6
0
文件: JSON.cs 项目: kgober/SEL810
        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();
            }
        }
示例#7
0
文件: Rational.cs 项目: inrg/FFSharp
 /// <inheritdoc />
 public int CompareTo(double ADouble)
 {
     return(AsDouble.CompareTo(ADouble));
 }