Ejemplo n.º 1
0
        public DefaultBinderFactory(IApplicationContext context, IOptionsMonitor <BindingServiceOptions> optionsMonitor, IBinderConfigurations binderConfigurations, IEnumerable <IBinderFactoryListener> listeners = null)
        {
            if (binderConfigurations == null)
            {
                throw new ArgumentNullException(nameof(binderConfigurations));
            }

            _listeners            = listeners?.ToList();
            _context              = context;
            _optionsMonitor       = optionsMonitor;
            _binderConfigurations = binderConfigurations;
        }
Ejemplo n.º 2
0
        public DefaultBinderFactory(IServiceProvider services, IOptionsMonitor <BindingServiceOptions> optionsMonitor, IBinderConfigurations binderConfigurations, IEnumerable <IBinderFactoryListener> listeners = null)
        {
            if (binderConfigurations == null)
            {
                throw new ArgumentNullException(nameof(binderConfigurations));
            }

            _services             = services;
            _optionsMonitor       = optionsMonitor;
            _binderConfigurations = binderConfigurations;
            _listeners            = listeners?.ToList();
        }
Ejemplo n.º 3
0
        internal static void ConfigureBinderServices(this IServiceCollection services, IBinderConfigurations binderConfigurations, IConfiguration configuration)
        {
            foreach (var binderConfiguration in binderConfigurations.Configurations)
            {
                var type = FindConfigureType(binderConfiguration.Value);
                if (type != null)
                {
                    var constr = FindConstructor(type);
                    var method = FindConfigureServicesMethod(type);
                    if (constr != null && method != null)
                    {
                        try
                        {
                            var instance = constr.Invoke(new object[] { configuration });
                            if (instance != null)
                            {
                                method.Invoke(instance, new object[] { services });
                            }

                            binderConfiguration.Value.ResolvedAssembly = type.Assembly.Location;
                        }
                        catch (Exception)
                        {
                            // Log
                        }
                    }
                    else
                    {
                        // Log
                    }
                }
                else
                {
                    // Log
                }
            }
        }
Ejemplo n.º 4
0
 internal static void AddBinderServices(this IServiceCollection services, IBinderConfigurations binderConfigurations, IConfiguration configuration)
 {
     services.TryAddSingleton <IBinderFactory, DefaultBinderFactory>();
     services.ConfigureBinderServices(binderConfigurations, configuration);
 }