Example #1
0
        private static bool TryConvertAsPrimitiveType(TypeCode typeCode, IEdmValue edmValue, out object clrValue)
        {
            TypeCode typeCode1 = typeCode;

            switch (typeCode1)
            {
            case TypeCode.Boolean:
            {
                clrValue = EdmToClrConverter.AsClrBoolean(edmValue);
                return(true);
            }

            case TypeCode.Char:
            {
                clrValue = EdmToClrConverter.AsClrChar(edmValue);
                return(true);
            }

            case TypeCode.SByte:
            {
                clrValue = (sbyte)EdmToClrConverter.AsClrInt64(edmValue);
                return(true);
            }

            case TypeCode.Byte:
            {
                clrValue = EdmToClrConverter.AsClrByte(edmValue);
                return(true);
            }

            case TypeCode.Int16:
            {
                clrValue = EdmToClrConverter.AsClrInt16(edmValue);
                return(true);
            }

            case TypeCode.UInt16:
            {
                clrValue = (ushort)EdmToClrConverter.AsClrInt64(edmValue);
                return(true);
            }

            case TypeCode.Int32:
            {
                clrValue = EdmToClrConverter.AsClrInt32(edmValue);
                return(true);
            }

            case TypeCode.UInt32:
            {
                clrValue = (uint)EdmToClrConverter.AsClrInt64(edmValue);
                return(true);
            }

            case TypeCode.Int64:
            {
                clrValue = EdmToClrConverter.AsClrInt64(edmValue);
                return(true);
            }

            case TypeCode.UInt64:
            {
                clrValue = (ulong)EdmToClrConverter.AsClrInt64(edmValue);
                return(true);
            }

            case TypeCode.Single:
            {
                clrValue = EdmToClrConverter.AsClrSingle(edmValue);
                return(true);
            }

            case TypeCode.Double:
            {
                clrValue = EdmToClrConverter.AsClrDouble(edmValue);
                return(true);
            }

            case TypeCode.Decimal:
            {
                clrValue = EdmToClrConverter.AsClrDecimal(edmValue);
                return(true);
            }

            case TypeCode.DateTime:
            {
                clrValue = EdmToClrConverter.AsClrDateTime(edmValue);
                return(true);
            }

            case TypeCode.Object | TypeCode.DateTime:
            {
                clrValue = null;
                return(false);
            }

            case TypeCode.String:
            {
                clrValue = EdmToClrConverter.AsClrString(edmValue);
                return(true);
            }

            default:
            {
                clrValue = null;
                return(false);
            }
            }
        }
Example #2
0
 internal static float AsClrSingle(IEdmValue edmValue)
 {
     return((float)EdmToClrConverter.AsClrDouble(edmValue));
 }