Exemplo n.º 1
0
        public void AddServer_RegistersDefaultHandler(OpenIddictServerHandlerDescriptor descriptor)
        {
            // Arrange
            var services = new ServiceCollection();
            var builder  = new OpenIddictBuilder(services);

            // Act
            builder.AddServer();

            // Assert
            Assert.Contains(services, service => service.Lifetime == descriptor.ServiceDescriptor.Lifetime &&
                            service.ServiceType == descriptor.ServiceDescriptor.ServiceType &&
                            service.ImplementationType == descriptor.ServiceDescriptor.ImplementationType);
        }
Exemplo n.º 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(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);
        }