Exemplo n.º 1
0
        private static bool TryGetCommonType(
            RowType rowType1,
            RowType rowType2,
            out EdmType commonRowType)
        {
            if (rowType1.Properties.Count != rowType2.Properties.Count || rowType1.InitializerMetadata != rowType2.InitializerMetadata)
            {
                commonRowType = (EdmType)null;
                return(false);
            }
            List <EdmProperty> edmPropertyList = new List <EdmProperty>();

            for (int index = 0; index < rowType1.Properties.Count; ++index)
            {
                TypeUsage commonType;
                if (!TypeSemantics.TryGetCommonType(rowType1.Properties[index].TypeUsage, rowType2.Properties[index].TypeUsage, out commonType))
                {
                    commonRowType = (EdmType)null;
                    return(false);
                }
                edmPropertyList.Add(new EdmProperty(rowType1.Properties[index].Name, commonType));
            }
            commonRowType = (EdmType) new RowType((IEnumerable <EdmProperty>)edmPropertyList, rowType1.InitializerMetadata);
            return(true);
        }
Exemplo n.º 2
0
 private static bool TryGetCommonType(
     EdmType edmType1,
     EdmType edmType2,
     out EdmType commonEdmType)
 {
     if (edmType2 == edmType1)
     {
         commonEdmType = edmType1;
         return(true);
     }
     if (Helper.IsPrimitiveType(edmType1) && Helper.IsPrimitiveType(edmType2))
     {
         return(TypeSemantics.TryGetCommonType((PrimitiveType)edmType1, (PrimitiveType)edmType2, out commonEdmType));
     }
     if (Helper.IsCollectionType((GlobalItem)edmType1) && Helper.IsCollectionType((GlobalItem)edmType2))
     {
         return(TypeSemantics.TryGetCommonType((CollectionType)edmType1, (CollectionType)edmType2, out commonEdmType));
     }
     if (Helper.IsEntityTypeBase(edmType1) && Helper.IsEntityTypeBase(edmType2))
     {
         return(TypeSemantics.TryGetCommonBaseType(edmType1, edmType2, out commonEdmType));
     }
     if (Helper.IsRefType((GlobalItem)edmType1) && Helper.IsRefType((GlobalItem)edmType2))
     {
         return(TypeSemantics.TryGetCommonType((RefType)edmType1, (RefType)edmType2, out commonEdmType));
     }
     if (Helper.IsRowType((GlobalItem)edmType1) && Helper.IsRowType((GlobalItem)edmType2))
     {
         return(TypeSemantics.TryGetCommonType((RowType)edmType1, (RowType)edmType2, out commonEdmType));
     }
     commonEdmType = (EdmType)null;
     return(false);
 }
Exemplo n.º 3
0
        internal static bool TryGetCommonType(
            TypeUsage type1,
            TypeUsage type2,
            out TypeUsage commonType)
        {
            commonType = (TypeUsage)null;
            if (type1.EdmEquals((MetadataItem)type2))
            {
                commonType = TypeSemantics.ForgetConstraints(type2);
                return(true);
            }
            if (Helper.IsPrimitiveType(type1.EdmType) && Helper.IsPrimitiveType(type2.EdmType))
            {
                return(TypeSemantics.TryGetCommonPrimitiveType(type1, type2, out commonType));
            }
            EdmType commonEdmType;

            if (TypeSemantics.TryGetCommonType(type1.EdmType, type2.EdmType, out commonEdmType))
            {
                commonType = TypeSemantics.ForgetConstraints(TypeUsage.Create(commonEdmType));
                return(true);
            }
            commonType = (TypeUsage)null;
            return(false);
        }
Exemplo n.º 4
0
        internal static TypeUsage GetCommonType(TypeUsage type1, TypeUsage type2)
        {
            TypeUsage commonType = (TypeUsage)null;

            if (TypeSemantics.TryGetCommonType(type1, type2, out commonType))
            {
                return(commonType);
            }
            return((TypeUsage)null);
        }
Exemplo n.º 5
0
 private static bool TryGetCommonType(
     RefType refType1,
     RefType reftype2,
     out EdmType commonType)
 {
     if (!TypeSemantics.TryGetCommonType((EdmType)refType1.ElementType, (EdmType)reftype2.ElementType, out commonType))
     {
         return(false);
     }
     commonType = (EdmType) new RefType((EntityType)commonType);
     return(true);
 }
Exemplo n.º 6
0
        private static bool TryGetCommonType(
            CollectionType collectionType1,
            CollectionType collectionType2,
            out EdmType commonType)
        {
            TypeUsage commonType1 = (TypeUsage)null;

            if (!TypeSemantics.TryGetCommonType(collectionType1.TypeUsage, collectionType2.TypeUsage, out commonType1))
            {
                commonType = (EdmType)null;
                return(false);
            }
            commonType = (EdmType) new CollectionType(commonType1);
            return(true);
        }