예제 #1
0
        internal static ResourceType GetNonPrimitiveResourceType(DataServiceProviderWrapper provider, object obj)
        {
            IProjectedResult result = obj as IProjectedResult;
            ResourceType     type   = (result != null) ? provider.TryResolveResourceType(result.ResourceTypeName) : provider.GetResourceType(obj);

            if (type == null)
            {
                throw new DataServiceException(500, System.Data.Services.Strings.BadProvider_InvalidTypeSpecified(obj.GetType().FullName));
            }
            return(type);
        }
예제 #2
0
        internal static ResourceType ResolveTypeIdentifier(DataServiceProviderWrapper provider, string identifier, ResourceType previousSegmentResourceType, bool previousSegmentIsTypeSegment)
        {
            ResourceType subType = provider.TryResolveResourceType(identifier);

            if (subType != null)
            {
                if (previousSegmentIsTypeSegment)
                {
                    throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestUriProcessor_TypeIdentifierCannotBeSpecifiedAfterTypeIdentifier(identifier, previousSegmentResourceType.FullName));
                }
                if (!previousSegmentResourceType.IsAssignableFrom(subType))
                {
                    throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestUriProcessor_InvalidTypeIdentifier_MustBeASubType(identifier, previousSegmentResourceType.FullName));
                }
            }
            return(subType);
        }
예제 #3
0
 internal static ResourceType TryResolveResourceType(DataServiceProviderWrapper provider, string typeName)
 {
     return(ResourceType.PrimitiveResourceTypeMap.GetPrimitive(typeName) ?? provider.TryResolveResourceType(typeName));
 }