예제 #1
0
        /// <summary>
        /// Sets the type associated to the handler.
        /// </summary>
        /// <param name="type">The handler type.</param>
        /// <returns>The builder instance, so that calls can be easily chained.</returns>
        public Builder <TContext> SetType(OpenIddictClientHandlerType type)
        {
            if (!Enum.IsDefined(typeof(OpenIddictClientHandlerType), type))
            {
                throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(OpenIddictClientHandlerType));
            }

            _type = type;

            return(this);
        }
예제 #2
0
        /// <summary>
        /// Imports the properties set on the specified descriptor.
        /// </summary>
        /// <param name="descriptor">The existing descriptor properties are copied from.</param>
        /// <remarks>All the properties previously set on this instance are automatically replaced.</remarks>
        /// <returns>The builder instance, so that calls can be easily chained.</returns>
        public Builder <TContext> Import(OpenIddictClientHandlerDescriptor descriptor)
        {
            if (descriptor is null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.ContextType != typeof(TContext))
            {
                throw new InvalidOperationException(SR.GetResourceString(SR.ID0284));
            }

            _descriptor = descriptor.ServiceDescriptor;
            _filters.Clear();
            _filters.AddRange(descriptor.FilterTypes);
            _order = descriptor.Order;
            _type  = descriptor.Type;

            return(this);
        }