예제 #1
0
        private static bool IsEquivalentTo(this IEdmPrimitiveTypeReference thisType, IEdmPrimitiveTypeReference otherType)
        {
            EdmPrimitiveTypeKind thisTypePrimitiveKind = thisType.PrimitiveKind();

            if (thisTypePrimitiveKind != otherType.PrimitiveKind())
            {
                return(false);
            }

            switch (thisTypePrimitiveKind)
            {
            case EdmPrimitiveTypeKind.Binary:
                return(((IEdmBinaryTypeReference)thisType).IsEquivalentTo((IEdmBinaryTypeReference)otherType));

            case EdmPrimitiveTypeKind.Decimal:
                return(((IEdmDecimalTypeReference)thisType).IsEquivalentTo((IEdmDecimalTypeReference)otherType));

            case EdmPrimitiveTypeKind.String:
                return(((IEdmStringTypeReference)thisType).IsEquivalentTo((IEdmStringTypeReference)otherType));

            case EdmPrimitiveTypeKind.Time:
            case EdmPrimitiveTypeKind.DateTime:
            case EdmPrimitiveTypeKind.DateTimeOffset:
                return(((IEdmTemporalTypeReference)thisType).IsEquivalentTo((IEdmTemporalTypeReference)otherType));

            default:
                if (thisTypePrimitiveKind.IsSpatial())
                {
                    return(((IEdmSpatialTypeReference)thisType).IsEquivalentTo((IEdmSpatialTypeReference)otherType));
                }
                else
                {
                    return(thisType.IsNullable == otherType.IsNullable &&
                           thisType.Definition.IsEquivalentTo(otherType.Definition));
                }
            }
        }
예제 #2
0
        private static bool IsEquivalentTo(this IEdmPrimitiveTypeReference thisType, IEdmPrimitiveTypeReference otherType)
        {
            EdmPrimitiveTypeKind edmPrimitiveTypeKind = thisType.PrimitiveKind();

            if (edmPrimitiveTypeKind == otherType.PrimitiveKind())
            {
                EdmPrimitiveTypeKind edmPrimitiveTypeKind1 = edmPrimitiveTypeKind;
                switch (edmPrimitiveTypeKind1)
                {
                case EdmPrimitiveTypeKind.Binary:
                {
                    return(thisType.IsEquivalentTo((IEdmBinaryTypeReference)otherType));
                }

                case EdmPrimitiveTypeKind.Boolean:
                case EdmPrimitiveTypeKind.Byte:
                {
                    if (edmPrimitiveTypeKind.IsSpatial())
                    {
                        break;
                    }
                    if (thisType.IsNullable != otherType.IsNullable)
                    {
                        return(false);
                    }
                    else
                    {
                        return(thisType.Definition.IsEquivalentTo(otherType.Definition));
                    }
                }

                case EdmPrimitiveTypeKind.DateTime:
                case EdmPrimitiveTypeKind.DateTimeOffset:
                {
                    return(thisType.IsEquivalentTo((IEdmTemporalTypeReference)otherType));
                }

                case EdmPrimitiveTypeKind.Decimal:
                {
                    return(thisType.IsEquivalentTo((IEdmDecimalTypeReference)otherType));
                }

                default:
                {
                    if (edmPrimitiveTypeKind1 == EdmPrimitiveTypeKind.String)
                    {
                        return(thisType.IsEquivalentTo((IEdmStringTypeReference)otherType));
                    }
                    else if (edmPrimitiveTypeKind1 == EdmPrimitiveTypeKind.Stream)
                    {
                        if (edmPrimitiveTypeKind.IsSpatial())
                        {
                            break;
                        }
                        if (thisType.IsNullable != otherType.IsNullable)
                        {
                            return(false);
                        }
                        else
                        {
                            return(thisType.Definition.IsEquivalentTo(otherType.Definition));
                        }
                    }
                    else if (edmPrimitiveTypeKind1 == EdmPrimitiveTypeKind.Time)
                    {
                        return(thisType.IsEquivalentTo((IEdmTemporalTypeReference)otherType));
                    }
                    if (edmPrimitiveTypeKind.IsSpatial())
                    {
                        break;
                    }
                    if (thisType.IsNullable != otherType.IsNullable)
                    {
                        return(false);
                    }
                    else
                    {
                        return(thisType.Definition.IsEquivalentTo(otherType.Definition));
                    }
                }
                }
                return(thisType.IsEquivalentTo((IEdmSpatialTypeReference)otherType));
            }
            else
            {
                return(false);
            }
        }