Esempio n. 1
0
        /// <summary>
        /// Create instance of handler
        /// </summary>
        /// <param name="activator">The activator.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">$"Type {_t.FullName} doesn't implement {nameof(HandlerAttribute)}</exception>
        public (object instance, MethodInfo method)? Build(Type target, ICustomActivator activator)
        {
            if (!ContainsTarget(target))
            {
                throw new NotImplementedException($"Type {_t.FullName} doesn't implement handler for {target.FullName}");
            }

            var method   = _targets[target];
            var instance = activator.GetInstance(_t);

            if (instance is null || method is null)
            {
                return(null);
            }

            return(instance, method);
        }
Esempio n. 2
0
 public Container(ICustomActivator activator)
 {
     _activator       = activator;
     _typesDictionary = new Dictionary <Type, Type>();
 }