示例#1
0
        /// <summary>
        ///     <para>
        ///         Provides ability to initialize all attribute marked dependencies.
        ///     </para>
        /// </summary>
        /// <param name="serviceCollection">Service collection to add dependencies.</param>
        /// <param name="tags">Tags to filter attributes. See documentation for more details.</param>
        public static IServiceCollection AddAttributeRegistration(this IServiceCollection serviceCollection, params string[] tags)
        {
            AttributeRegistrar attributeRegistrar = new AttributeRegistrar();

            attributeRegistrar.RegisterTypes(serviceCollection, tags);
            return(serviceCollection);
        }
示例#2
0
        /// <summary>
        ///     <para>
        ///         Provides ability to initialize all attribute marked dependencies.
        ///     </para>
        /// </summary>
        /// <param name="serviceCollection">Service collection to add dependencies.</param>
        /// <param name="assembliesToSearch">Assemblies to search <see cref="RegisterAttribute"/> marked classes.</param>
        /// <param name="tags">Tags to filter attributes. See documentation for more details.</param>
        public static IServiceCollection AddAttributeRegistration(this IServiceCollection serviceCollection, IEnumerable <Type> typesToSearch, params string[] tags)
        {
            AttributeRegistrar attributeRegistrar = new AttributeRegistrar();

            attributeRegistrar.RegisterTypes(serviceCollection, typesToSearch, tags);
            return(serviceCollection);
        }
        public void WithOptimizedAssembliesScan()
        {
            IServiceCollection serviceCollection  = new ServiceCollection();
            AttributeRegistrar attributeRegistrar = new AttributeRegistrar(new DefaultAssemblyDiscoveryProvider());

            for (int i = 0; i < OperationsPerInvoke; i++)
            {
                attributeRegistrar.RegisterTypes(serviceCollection, null);
                serviceCollection.BuildServiceProvider();
            }
        }
        public void WithSpecifiedAssemblies()
        {
            IServiceCollection     serviceCollection  = new ServiceCollection();
            IEnumerable <Assembly> assemblies         = Enumerable.Repeat(this.GetType().GetTypeInfo().Assembly, 1);
            AttributeRegistrar     attributeRegistrar = new AttributeRegistrar();

            for (int i = 0; i < OperationsPerInvoke; i++)
            {
                attributeRegistrar.RegisterTypes(serviceCollection, assemblies, null);
                serviceCollection.BuildServiceProvider();
            }
        }