// A IResourceProvider implementation is responsible for applying the resource-metadata
        // to resources returned when the request has an Accept value (i.e. application/hal+json)
        // indicating that the returned resource should be augmented.
        private static IResourceProvider CreateProvider(IResourceMap resourceMap)
        {
            if (resourceMap.ProviderType == null)
            {
                throw new InvalidOperationException(
                          $"The resource map of type: {resourceMap.GetType()} did not set the provider type.");
            }

            return((IResourceProvider)resourceMap.ProviderType.CreateInstance());
        }
Beispiel #2
0
        protected IResourceMeta GetResourceMeta(Type resourceType)
        {
            IResourceMeta resourceMeta = _resourceMap.ResourceMeta
                                         .FirstOrDefault(m => m.ResourceType == resourceType);

            if (resourceMeta == null)
            {
                throw new InvalidOperationException(
                          $"Resource Metadata has not yet been added for resource type: {resourceType.AssemblyQualifiedName} " +
                          $"to the mapping of type: {_resourceMap.GetType().AssemblyQualifiedName}.");
            }
            return(resourceMeta);
        }