// eventually, this is the planned public constructor // to avoid breaking changes, we will be leaving the original constructor in place // until the context graph validation process is completed // you can track progress on this issue here: https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/170 internal ContextGraph(List <ContextEntity> entities, bool usesDbContext, List <ValidationResult> validationResults) { Entities = entities; UsesDbContext = usesDbContext; ValidationResults = validationResults; Instance = this; }
public DocumentBuilder(IJsonApiContext jsonApiContext, IRequestMeta requestMeta = null, IDocumentBuilderOptionsProvider documentBuilderOptionsProvider = null) { _jsonApiContext = jsonApiContext; _contextGraph = jsonApiContext.ContextGraph; _requestMeta = requestMeta; _documentBuilderOptions = documentBuilderOptionsProvider?.GetDocumentBuilderOptions() ?? new DocumentBuilderOptions();; }
public ContextGraph(List <ContextEntity> entities, bool usesDbContext) { Entities = entities; UsesDbContext = usesDbContext; ValidationResults = new List <ValidationResult>(); Instance = this; }
public RemoveOpProcessor( IDeleteService <T, int> service, IJsonApiDeSerializer deSerializer, IDocumentBuilder documentBuilder, IContextGraph contextGraph ) : base(service, deSerializer, documentBuilder, contextGraph) { }
public JsonApiContext( IContextGraph contextGraph, IHttpContextAccessor httpContextAccessor, JsonApiOptions options) { ContextGraph = contextGraph; _httpContextAccessor = httpContextAccessor; Options = options; }
/// <inheritdoc /> public GetOpProcessor( IGetAllService <T, int> getAll, IGetByIdService <T, int> getById, IGetRelationshipService <T, int> getRelationship, IJsonApiDeSerializer deSerializer, IDocumentBuilder documentBuilder, IContextGraph contextGraph, IJsonApiContext jsonApiContext ) : base(getAll, getById, getRelationship, deSerializer, documentBuilder, contextGraph, jsonApiContext) { }
public void BuildContextGraph <TContext>(Action <IContextGraphBuilder> builder) where TContext : DbContext { var contextGraphBuilder = new ContextGraphBuilder(); contextGraphBuilder.AddDbContext <TContext>(); builder?.Invoke(contextGraphBuilder); ContextGraph = contextGraphBuilder.Build(); }
public void BuildContextGraph(Action <IContextGraphBuilder> builder) { if (builder == null) { throw new ArgumentException("Cannot build non-EF context graph without an IContextGraphBuilder action", nameof(builder)); } var contextGraphBuilder = new ContextGraphBuilder(); builder(contextGraphBuilder); ContextGraph = contextGraphBuilder.Build(); }
public JsonApiContext( IContextGraph contextGraph, IHttpContextAccessor httpContextAccessor, JsonApiOptions options, IMetaBuilder metaBuilder, IGenericProcessorFactory genericProcessorFactory) { ContextGraph = contextGraph; _httpContextAccessor = httpContextAccessor; Options = options; MetaBuilder = metaBuilder; GenericProcessorFactory = genericProcessorFactory; RelationshipsToUpdate = new Dictionary <RelationshipAttribute, object>(); }
public JsonApiContext( IDbContextResolver contextResolver, IContextGraph contextGraph, IHttpContextAccessor httpContextAccessor, JsonApiOptions options, IMetaBuilder metaBuilder, IGenericProcessorFactory genericProcessorFactory) { _contextResolver = contextResolver; ContextGraph = contextGraph; _httpContextAccessor = httpContextAccessor; Options = options; MetaBuilder = metaBuilder; GenericProcessorFactory = genericProcessorFactory; }
public JsonApiContext( IContextGraph contextGraph, IHttpContextAccessor httpContextAccessor, JsonApiOptions options, IMetaBuilder metaBuilder, IGenericProcessorFactory genericProcessorFactory, IQueryParser queryParser, IControllerContext controllerContext) { ContextGraph = contextGraph; _httpContextAccessor = httpContextAccessor; Options = options; MetaBuilder = metaBuilder; GenericProcessorFactory = genericProcessorFactory; _queryParser = queryParser; _controllerContext = controllerContext; }
public static ErrorCollection ConvertToErrorCollection <T>(this ModelStateDictionary modelState, IContextGraph contextGraph) { ErrorCollection collection = new ErrorCollection(); foreach (var entry in modelState) { if (entry.Value.Errors.Any() == false) { continue; } var attrName = contextGraph.GetPublicAttributeName <T>(entry.Key); foreach (var modelError in entry.Value.Errors) { if (modelError.Exception is JsonApiException jex) { collection.Errors.AddRange(jex.GetError().Errors); } else { collection.Errors.Add(new Error( status: 422, title: entry.Key, detail: modelError.ErrorMessage, meta: modelError.Exception != null ? ErrorMeta.FromException(modelError.Exception) : null, source: attrName == null ? null : new { pointer = $"/data/attributes/{attrName}" })); } } } return(collection); }
public DocumentBuilder(IJsonApiContext jsonApiContext, IRequestMeta requestMeta) { _jsonApiContext = jsonApiContext; _contextGraph = jsonApiContext.ContextGraph; _requestMeta = requestMeta; }
public DocumentBuilder(IJsonApiContext jsonApiContext) { _jsonApiContext = jsonApiContext; _contextGraph = jsonApiContext.ContextGraph; }
public ResourceDefinition() { _graph = ContextGraph.Instance; _contextEntity = ContextGraph.Instance.GetContextEntity(typeof(T)); _instanceAttrsAreSpecified = InstanceOutputAttrsAreSpecified(); }
public ResourceDefinition_Scenario_Tests() { _graph = new ContextGraphBuilder() .AddResource <Model>("models") .Build(); }