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); }
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); }
internal static ResourceType TryResolveResourceType(DataServiceProviderWrapper provider, string typeName) { return(ResourceType.PrimitiveResourceTypeMap.GetPrimitive(typeName) ?? provider.TryResolveResourceType(typeName)); }