Ejemplo n.º 1
0
        public ItemLoaderFieldResolver(MethodMember method, object handler, IDataLoaderContextAccessor dataLoader)
        {
            method.AssertNotNull(nameof(method));
            handler.AssertNotNull(nameof(handler));
            dataLoader.AssertNotNull(nameof(dataLoader));

            if (!method.Return.Type.Is <T>())
            {
                throw new ArgumentException($"{nameof(ItemLoaderFieldResolver<T>)}: Expected method [{method.Name}] to have a return type of [{TypeOf<T>.Name}] instead of [{method.Return.Type.Name}].");
            }

            this._Method     = method;
            this._Handler    = handler;
            this._DataLoader = dataLoader;
        }
Ejemplo n.º 2
0
        public MethodFieldResolver(MethodMember method, object?handler)
        {
            method.AssertNotNull(nameof(method));
            if (!method.Static)
            {
                handler.AssertNotNull(nameof(handler));
            }

            if (method.Return.IsVoid)
            {
                throw new NotSupportedException($"{nameof(MethodFieldResolver)}: Graph endpoints cannot have a return type that is void, {nameof(Task)} or {nameof(ValueTask)}.");
            }

            this._Method  = method;
            this._Handler = handler;
        }
        public CollectionBatchLoaderFieldResolver(MethodMember method, object handler, IDataLoaderContextAccessor dataLoader, Func <PARENT, KEY> getParentKey, Func <CHILD, KEY> getChildKey)
        {
            method.AssertNotNull(nameof(method));
            handler.AssertNotNull(nameof(handler));
            getParentKey.AssertNotNull(nameof(getParentKey));
            getChildKey.AssertNotNull(nameof(getChildKey));

            if (!method.Return.Type.Implements <IEnumerable <CHILD> >())
            {
                throw new ArgumentException($"{nameof(CollectionBatchLoaderFieldResolver<PARENT, CHILD, KEY>)}: Expected method [{method.Name}] to have a return type of [{TypeOf<IEnumerable<CHILD>>.Name}] instead of [{method.Return.Type.Name}].");
            }

            this._Method       = method;
            this._Handler      = handler;
            this._DataLoader   = dataLoader;
            this._GetParentKey = getParentKey;
            this._GetChildKey  = getChildKey;
        }