/// <summary>
 /// Bind type
 /// </summary>
 /// <param name="bindingTypes"></param>
 internal void Bind(TypesBinder bindingTypes)
 {
     if (bindingTypes.ImplementType != null)
     {
         _addBindingWrapper.Add(
             bindingTypes.Services,
             bindingTypes.SingleType,
             bindingTypes.ImplementType,
             bindingTypes.LifeTimeOptions,
             bindingTypes.IsPropertiesAutoWired);
     }
     else if (bindingTypes.IsImplementByInterface)
     {
         _implementByInterfaceHelper.Add(
             bindingTypes.Services,
             bindingTypes.SingleType,
             bindingTypes.LifeTimeOptions,
             bindingTypes.IsPropertiesAutoWired);
     }
     else
     {
         _addBindingWrapper.Add(
             bindingTypes.Services,
             bindingTypes.SingleType,
             null,
             bindingTypes.LifeTimeOptions,
             bindingTypes.IsPropertiesAutoWired);
     }
 }
        /// <summary>
        /// Bind range types
        /// </summary>
        /// <param name="bindingTypes"></param>
        /// <param name="types"></param>
        internal void Bind(TypesBinder bindingTypes, IEnumerable <Type> types)
        {
            types = (Type[])types;

            if (types == null || !types.Any())
            {
                return;
            }
            foreach (var type in types)
            {
                if (bindingTypes.IsImplementByInterface)
                {
                    _implementByInterfaceHelper.Add(
                        bindingTypes.Services,
                        type,
                        bindingTypes.LifeTimeOptions,
                        bindingTypes.IsPropertiesAutoWired);
                }
                else
                {
                    _addBindingWrapper.Add(
                        bindingTypes.Services,
                        type,
                        null,
                        bindingTypes.LifeTimeOptions,
                        bindingTypes.IsPropertiesAutoWired);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add service bind by implemented interface
        /// </summary>
        /// <param name="services">Service collection</param>
        /// <param name="type">Binding type</param>
        /// <param name="options">Life time binding option</param>
        /// <param name="propertyAutoWired">Use option auto wired property</param>
        internal void Add(IServiceCollection services,
                          Type type,
                          LifeTimeOptions options,
                          bool propertyAutoWired)
        {
            var implementedInterface =
                type.GetInterfaces()
                .FirstOrDefault();

            _addBindingWrapper.Add(services,
                                   implementedInterface,
                                   type,
                                   options,
                                   propertyAutoWired);
        }