Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationItemFactory"/> class.
        /// </summary>
        /// <param name="assemblies">The assemblies to scan for named items.</param>
        public ConfigurationItemFactory(params Assembly[] assemblies)
        {
            this.CreateInstance    = FactoryHelper.CreateInstance;
            this.targets           = new Factory <Target, TargetAttribute>(this);
            this.filters           = new Factory <Filter, FilterAttribute>(this);
            this.layoutRenderers   = new LayoutRendererFactory(this);
            this.layouts           = new Factory <Layout, LayoutAttribute>(this);
            this.conditionMethods  = new MethodFactory <ConditionMethodsAttribute, ConditionMethodAttribute>();
            this.ambientProperties = new Factory <LayoutRenderer, AmbientPropertyAttribute>(this);
            this.timeSources       = new Factory <TimeSource, TimeSourceAttribute>(this);
            this.allFactories      = new List <object>
            {
                this.targets,
                this.filters,
                this.layoutRenderers,
                this.layouts,
                this.conditionMethods,
                this.ambientProperties,
                this.timeSources,
            };

            foreach (var asm in assemblies)
            {
                this.RegisterItemsFromAssembly(asm);
            }
        }
Ejemplo n.º 2
0
        internal ConfigurationItemFactory(ServiceRepository serviceRepository, ConfigurationItemFactory globalDefaultFactory, params Assembly[] assemblies)
        {
            _serviceRepository = serviceRepository ?? throw new ArgumentNullException(nameof(serviceRepository));
            _targets           = new Factory <Target, TargetAttribute>(serviceRepository, globalDefaultFactory?._targets);
            _filters           = new Factory <Filter, FilterAttribute>(serviceRepository, globalDefaultFactory?._filters);
            _layoutRenderers   = new LayoutRendererFactory(serviceRepository, globalDefaultFactory?._layoutRenderers);
            _layouts           = new Factory <Layout, LayoutAttribute>(serviceRepository, globalDefaultFactory?._layouts);
            _conditionMethods  = new MethodFactory(globalDefaultFactory?._conditionMethods, classType => MethodFactory.ExtractClassMethods <ConditionMethodsAttribute, ConditionMethodAttribute>(classType));
            _ambientProperties = new Factory <LayoutRenderer, AmbientPropertyAttribute>(serviceRepository, globalDefaultFactory?._ambientProperties);
            _timeSources       = new Factory <TimeSource, TimeSourceAttribute>(serviceRepository, globalDefaultFactory?._timeSources);
            _allFactories      = new IFactory[]
            {
                _targets,
                _filters,
                _layoutRenderers,
                _layouts,
                _conditionMethods,
                _ambientProperties,
                _timeSources,
            };

            foreach (var asm in assemblies)
            {
                RegisterItemsFromAssembly(asm);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationItemFactory"/> class.
        /// </summary>
        /// <param name="assemblies">The assemblies to scan for named items.</param>
        public ConfigurationItemFactory(params Assembly[] assemblies)
        {
            CreateInstance     = FactoryHelper.CreateInstance;
            _targets           = new Factory <Target, TargetAttribute>(this);
            _filters           = new Factory <Filter, FilterAttribute>(this);
            _layoutRenderers   = new LayoutRendererFactory(this);
            _layouts           = new Factory <Layout, LayoutAttribute>(this);
            _conditionMethods  = new MethodFactory(classType => MethodFactory.ExtractClassMethods <ConditionMethodsAttribute, ConditionMethodAttribute>(classType));
            _ambientProperties = new Factory <LayoutRenderer, AmbientPropertyAttribute>(this);
            _timeSources       = new Factory <TimeSource, TimeSourceAttribute>(this);
            _allFactories      = new IFactory[]
            {
                _targets,
                _filters,
                _layoutRenderers,
                _layouts,
                _conditionMethods,
                _ambientProperties,
                _timeSources,
            };

            foreach (var asm in assemblies)
            {
                RegisterItemsFromAssembly(asm);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MethodFactory"/> class.
 /// </summary>
 public MethodFactory(MethodFactory globalDefaultFactory, Func <Type, IList <KeyValuePair <string, MethodInfo> > > methodExtractor)
 {
     _globalDefaultFactory = globalDefaultFactory;
     _methodExtractor      = methodExtractor;
 }