Exemplo n.º 1
0
        protected IResponseDeserializer GetDeserializer()
        {
            var options           = GetService <IJsonApiOptions>();
            var formatter         = new ResourceNameFormatter(options);
            var resourcesContexts = GetService <IResourceGraph>().GetResourceContexts();
            var builder           = new ResourceGraphBuilder(options, NullLoggerFactory.Instance);

            foreach (var rc in resourcesContexts)
            {
                if (rc.ResourceType == typeof(TodoItem) || rc.ResourceType == typeof(TodoItemCollection))
                {
                    continue;
                }
                builder.AddResource(rc.ResourceType, rc.IdentityType, rc.ResourceName);
            }
            builder.AddResource <TodoItemClient>(formatter.FormatResourceName(typeof(TodoItem)));
            builder.AddResource <TodoItemCollectionClient, Guid>(formatter.FormatResourceName(typeof(TodoItemCollection)));
            return(new ResponseDeserializer(builder.Build(), new ResourceFactory(_factory.ServiceProvider)));
        }
        private string FormatResourceName(Type resourceType)
        {
            var formatter = new ResourceNameFormatter(_options);

            return(formatter.FormatResourceName(resourceType));
        }
 public DefaultRoutingConvention(IJsonApiOptions options)
 {
     _options   = options;
     _formatter = new ResourceNameFormatter(options);
 }
Exemplo n.º 4
0
 public JsonApiRoutingConvention(IJsonApiOptions options)
 {
     _options   = options ?? throw new ArgumentNullException(nameof(options));
     _formatter = new ResourceNameFormatter(options);
 }