Пример #1
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();
            }
        }
Пример #2
0
        public override string ToString()
        {
            string value;

            switch (TypeCode)
            {
            case DataCenterTypeCode.None:
                value = "N/A";
                break;

            case DataCenterTypeCode.Int32:
                value = AsInt32.ToString();
                break;

            case DataCenterTypeCode.Single:
                value = AsSingle.ToString();
                break;

            case DataCenterTypeCode.String:
                value = $"\"{AsString}\"";
                break;

            case DataCenterTypeCode.Boolean:
                value = AsBoolean.ToString();
                break;

            default:
                throw Assert.Unreachable();
            }

            return($"[Name: {Name}, Type: {TypeCode}, Value: {value}]");
        }
Пример #3
0
        public override int GetHashCode()
        {
            var hash = -1521134295;

            hash = hash * -1521134295 + TypeCode.GetHashCode();

            int vhash;

            switch (TypeCode)
            {
            case DataCenterTypeCode.None:
                vhash = 0;
                break;

            case DataCenterTypeCode.Int32:
                vhash = AsInt32.GetHashCode();
                break;

            case DataCenterTypeCode.Single:
                vhash = AsSingle.GetHashCode();
                break;

            case DataCenterTypeCode.String:
                vhash = AsString.GetHashCode();
                break;

            case DataCenterTypeCode.Boolean:
                vhash = AsBoolean.GetHashCode();
                break;

            default:
                throw Assert.Unreachable();
            }

            hash = hash * -1521134295 + vhash;

            return(hash);
        }
Пример #4
0
        public override string ToString()
        {
            switch (TypeCode)
            {
            case DataCenterTypeCode.None:
                return("null");

            case DataCenterTypeCode.Int32:
                return(AsInt32.ToString());

            case DataCenterTypeCode.Single:
                return(AsSingle.ToString());

            case DataCenterTypeCode.String:
                return(AsString);

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

            default:
                throw Assert.Unreachable();
            }
        }