Exemple #1
0
        /// <summary>
        /// <para>根据<paramref name="isNativeType"/>和<paramref name="typeCode"/>来获得BssomValueType</para>
        /// <para>Obtain the BssomValueType name according to <paramref name="isNativeType"/> and <paramref name="typeCode"/></para>
        /// </summary>
        /// <returns>BssomValueType</returns>
        public static BssomValueType GetBssomValueType(bool isNativeType, byte typeCode)
        {
            if (isNativeType)
            {
                switch (typeCode)
                {
                case NativeBssomType.CharCode:
                    return(BssomValueType.Char);

                case NativeBssomType.DateTimeCode:
                    return(BssomValueType.DateTime);

                case NativeBssomType.DecimalCode:
                    return(BssomValueType.Decimal);

                case NativeBssomType.GuidCode:
                    return(BssomValueType.Guid);
                }
            }
            else
            {
                switch (typeCode)
                {
                case BssomType.NullCode:
                    return(BssomValueType.Null);

                case BssomType.Int8Code:
                case BssomType.Int16Code:
                case BssomType.Int32Code:
                case BssomType.Int64Code:
                case BssomType.UInt8Code:
                case BssomType.UInt16Code:
                case BssomType.UInt32Code:
                case BssomType.UInt64Code:
                    return(BssomValueType.Number);

                case BssomType.Float32Code:
                case BssomType.Float64Code:
                    return(BssomValueType.Float);

                case BssomType.BooleanCode:
                    return(BssomValueType.Boolean);

                case BssomType.TimestampCode:
                    return(BssomValueType.DateTime);

                case BssomType.StringCode:
                    return(BssomValueType.String);

                case BssomType.Map1:
                case BssomType.Map2:
                    return(BssomValueType.Map);

                case BssomType.Array1:
                case BssomType.Array2:
                    return(BssomValueType.Array);
                }
            }
            throw BssomSerializationArgumentException.InvalidTypeCode();
        }
Exemple #2
0
        /// <summary>
        /// <para>根据<paramref name="isNativeType"/>和<paramref name="typeCode"/>来获得Bssom类型名称</para>
        /// <para>Obtain the Bssom type name according to <paramref name="isNativeType"/> and <paramref name="typeCode"/></para>
        /// </summary>
        /// <returns>Bssom type name</returns>
        public static string GetTypeName(bool isNativeType, byte typeCode)
        {
            if (isNativeType)
            {
                switch (typeCode)
                {
                case NativeBssomType.CharCode:
                    return(nameof(NativeBssomType.CharCode));

                case NativeBssomType.DateTimeCode:
                    return(nameof(NativeBssomType.DateTimeCode));

                case NativeBssomType.DecimalCode:
                    return(nameof(NativeBssomType.DecimalCode));

                case NativeBssomType.GuidCode:
                    return(nameof(NativeBssomType.GuidCode));
                }
            }
            else
            {
                switch (typeCode)
                {
                case BssomType.NullCode: return(nameof(BssomType.NullCode));

                case BssomType.Int8Code: return(nameof(BssomType.Int8Code));

                case BssomType.Int16Code: return(nameof(BssomType.Int16Code));

                case BssomType.Int32Code: return(nameof(BssomType.Int32Code));

                case BssomType.Int64Code: return(nameof(BssomType.Int64Code));

                case BssomType.UInt8Code: return(nameof(BssomType.UInt8Code));

                case BssomType.UInt16Code: return(nameof(BssomType.UInt16Code));

                case BssomType.UInt32Code: return(nameof(BssomType.UInt32Code));

                case BssomType.UInt64Code: return(nameof(BssomType.UInt64Code));

                case BssomType.Float32Code: return(nameof(BssomType.Float32Code));

                case BssomType.Float64Code: return(nameof(BssomType.Float64Code));

                case BssomType.BooleanCode: return(nameof(BssomType.BooleanCode));

                case BssomType.TimestampCode: return(nameof(BssomType.TimestampCode));

                case BssomType.StringCode: return(nameof(BssomType.StringCode));

                case BssomType.Map1: return(nameof(BssomType.Map1));

                case BssomType.Map2: return(nameof(BssomType.Map2));

                case BssomType.Array1: return(nameof(BssomType.Array1));

                case BssomType.Array2: return(nameof(BssomType.Array2));
                }
            }
            throw BssomSerializationArgumentException.InvalidTypeCode();
        }