Exemplo n.º 1
0
        public RelationSavingEngine(
            IServiceProvider serviceProvider,
            InformationRessource informationRessource,
            PropertyInfo propertyRelation,
            RelationshipJsonApiAttribute relationshipJApiAttribute,
            object idRessourceParent)
        {
            this._serviceProvider      = serviceProvider;
            this._informationRessource = informationRessource;
            this._relationProperty     = propertyRelation;
            this._idRessourceParent    = idRessourceParent;

            (PropertyInfo foreignKeyProperty, ForeignKeyJsonApiAttribute foreignKeyAttribute) =
                AttributeRelationsHandling.FindForeignKeyPropertyAndAttribute(this._informationRessource.TypeRessource, this._relationProperty.Name);

            if (foreignKeyProperty == null && foreignKeyAttribute == null)
            {
                throw new JsonApiArchitectureException($"ForeignKeyJsonApi manquant pour {this._relationProperty.Name} dans {this._informationRessource.TypeRessource.Name}, ajouter[ForeignKeyJsonApi (RelationName = nameof({this._relationProperty.Name}))]");
            }

            this._foreignKeyProperty = foreignKeyProperty;
            this._typeRelation       = relationshipJApiAttribute is HasManyJsonApiAttribute ? TypeRelation.Many : TypeRelation.One;

            this.SaveRelations();
        }
Exemplo n.º 2
0
        public RelationsPropertyEngine(
            IServiceProvider serviceProvider,
            IQueryService queryService,
            InformationRessource informationRessource,
            PropertyInfo propertyRelation,
            RelationshipJsonApiAttribute relationshipJApiAttribute,
            string _relationPath,
            int depth)
        {
            this._serviceProvider      = serviceProvider;
            this._queryService         = queryService;
            this._informationRessource = informationRessource;
            this._relationProperty     = propertyRelation;
            this._relationAttribute    = relationshipJApiAttribute;
            this._depth        = depth;
            this._relationPath = _relationPath;

            (PropertyInfo foreignKeyProperty, ForeignKeyJsonApiAttribute foreignKeyAttribute) =
                AttributeRelationsHandling.FindForeignKeyPropertyAndAttribute(this._informationRessource.TypeRessource, this._relationProperty.Name);

            if (foreignKeyProperty == null && foreignKeyAttribute == null)
            {
                throw new JsonApiArchitectureException($"ForeignKeyJsonApi manquant pour {this._relationProperty.Name} dans {this._informationRessource.TypeRessource.Name}, ajouter[ForeignKeyJsonApi (RelationName = nameof({this._relationProperty.Name}))]");
            }

            this._identifiantRelationProperty = AttributeHandling.GetIdProperty(typeof(T));

            if (this._identifiantRelationProperty == null)
            {
                throw new JsonApiArchitectureException($"Ajouter [IdJsonApi] sur {typeof(T).Name}");
            }

            this._foreignKeyProperty  = foreignKeyProperty;
            this._foreignKeyAttribute = foreignKeyAttribute;
            this._typeRelation        = this._relationAttribute is HasManyJsonApiAttribute ? TypeRelation.Many : TypeRelation.One;

            this.GetRelations();
        }
Exemplo n.º 3
0
 public RelationsEngine(IServiceProvider serviceProvider, IQueryService queryService, object ressource)
 {
     this._informationRessource = new InformationRessource(ressource);
     this._serviceProvider      = serviceProvider;
     this._queryService         = queryService;
 }