Пример #1
0
        internal static void AssertEdmType(TypeUsage typeUsage)
        {
            var type = typeUsage.EdmType;

            if (TypeSemantics.IsCollectionType(typeUsage))
            {
                AssertEdmType(GetElementTypeUsage(typeUsage));
            }
            else if (TypeSemantics.IsStructuralType(typeUsage) &&
                     !Helper.IsComplexType(typeUsage.EdmType) &&
                     !Helper.IsEntityType(typeUsage.EdmType))
            {
                foreach (EdmMember m in GetDeclaredStructuralMembers(typeUsage))
                {
                    AssertEdmType(m.TypeUsage);
                }
            }
            else if (TypeSemantics.IsPrimitiveType(typeUsage))
            {
                var pType = type as PrimitiveType;
                if (null != pType)
                {
                    if (pType.DataSpace
                        != DataSpace.CSpace)
                    {
                        throw new NotSupportedException(
                                  String.Format(CultureInfo.InvariantCulture, "PrimitiveType must be CSpace '{0}'", typeUsage));
                    }
                }
            }
        }
        internal static void AssertEdmType(TypeUsage typeUsage)
        {
            EdmType edmType = typeUsage.EdmType;

            if (TypeSemantics.IsCollectionType(typeUsage))
            {
                return;
            }
            if (TypeSemantics.IsStructuralType(typeUsage) && !Helper.IsComplexType(typeUsage.EdmType) && !Helper.IsEntityType(typeUsage.EdmType))
            {
                foreach (EdmMember structuralMember in TypeHelpers.GetDeclaredStructuralMembers(typeUsage))
                {
                    ;
                }
            }
            else
            {
                if (!TypeSemantics.IsPrimitiveType(typeUsage))
                {
                    return;
                }
                PrimitiveType primitiveType = edmType as PrimitiveType;
                if (primitiveType != null && primitiveType.DataSpace != DataSpace.CSpace)
                {
                    throw new NotSupportedException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "PrimitiveType must be CSpace '{0}'", (object)typeUsage));
                }
            }
        }