/// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        public StandardResolver(IResolverConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            bindingsFactory = CreateBindings;
            instanceFactory = CreateInstance;

            Components = config.CreateComponentContainer();

            metadataFactory = Components.Get <IMetadataFactory>();
            processors      = Components.GetAll <IProcessor>().ToArray();
            injectors       = Components.GetAll <IInjector>().ToArray();
            handlers        = Components.GetAll <IMissingHandler>().ToArray();

            foreach (var group in config.CreateBindings(Components).GroupBy(b => b.Type))
            {
                table.Add(group.Key, group.ToArray());
            }

            var selfType = typeof(IResolver);

            table.Add(selfType, new IBinding[] { new Binding(selfType, new ConstantProvider <IResolver>(this), null, null, null, null) });
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="components"></param>
        public StandardProvider(Type type, IComponentContainer components)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (components == null)
            {
                throw new ArgumentNullException("components");
            }

            TargetType = type;
            injectors  = components.GetAll <IInjector>().ToArray();
            metadata   = components.Get <IMetadataFactory>().GetMetadata(TargetType);
        }