/// <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(OpenIddictServerHandlerType type) { if (!Enum.IsDefined(typeof(OpenIddictServerHandlerType), type)) { throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(OpenIddictServerHandlerType)); } _type = type; return(this); }
/// <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(OpenIddictServerHandlerDescriptor 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); }