protected virtual void LoadConfigurations()
        {
            var configNode = GetConfigurationNode();

            Assert.IsNotNull(configNode, "Root Unicorn config node not found. Missing Unicorn.config?");

            var defaultsNode = configNode["defaults"];

            Assert.IsNotNull(defaultsNode, "Unicorn <defaults> node not found. It should be under <unicorn> config section.");

            var configurationNodes = configNode.SelectNodes("./configurations/configuration");

            // no configs let's get outta here
            if (configurationNodes == null || configurationNodes.Count == 0)
            {
                _configurations = new IConfiguration[0];
                return;
            }

            var parser = new XmlContainerParser(configNode["configurations"], configNode["defaults"], new XmlInheritanceEngine());

            var definitions = parser.GetContainers();

            var configurations = GetContainers(definitions).ToArray();

            foreach (var configuration in configurations)
            {
                // Assert that expected dependencies exist - and in the case of data stores are specifically singletons (WEIRD things happen otherwise)
                configuration.AssertSingleton(typeof(ISourceDataStore));
                configuration.AssertSingleton(typeof(ITargetDataStore));
                configuration.Assert(typeof(IEvaluator));
                configuration.Assert(typeof(IPredicate));
                configuration.Assert(typeof(ILogger));
                configuration.Assert(typeof(ISerializationLoaderLogger));
                configuration.Assert(typeof(IConsistencyChecker));
                configuration.Assert(typeof(IDeserializeFailureRetryer));

                // register the configuration with itself. how meta!
                configuration.Register(typeof(IConfiguration), () => new ReadOnlyConfiguration((IConfiguration)configuration), true);
            }

            _configurations = configurations
                              .Cast <IConfiguration>()
                              .Select(config => (IConfiguration) new ReadOnlyConfiguration(config))
                              .ToArray();
        }
Ejemplo n.º 2
0
        public void Run()
        {
            XmlNode configNode = LoadFromPath(GetDataPath("ProtectedInnerData\\AdminLevel1\\data-3e.xml"));

            //var configNode =
            var parser = new XmlContainerParser(configNode["configurations"], configNode["compositionRoot"], new XmlInheritanceEngine());
            IList <ContainerDefinition> definitions = parser.GetContainers();

            IContainer[] containers = GetContainers(definitions).ToArray();

            Dbg(
                containers
                .Select(cont => cont.Name)
                );

            var a = containers.Select(cont => cont.Resolve(typeof(IRunnable))).First();

            Console.Write("");
        }
Ejemplo n.º 3
0
        protected override void LoadConfigurations()
        {
            LoadConfigurationNodes();

            LoadVirtualModuleConfigurations();

            var configurationNodes = ConfigNode.SelectNodes("./configuration");

            // no configs let's get outta here
            if (configurationNodes == null || configurationNodes.Count == 0)
            {
                InternalConfigurations = new IConfiguration[0];
                return;
            }

            var parser = new XmlContainerParser(ConfigNode, ValidatorConfig, new XmlInheritanceEngine());

            var definitions = parser.GetContainers();

            var configurations = GetContainers(definitions).ToArray();

            foreach (var configuration in configurations)
            {
                configuration.AssertSingleton(typeof(ISourceDataStore));
                configuration.Assert(typeof(IPredicate));
                // register the configuration with itself. how meta!
                configuration.Register(typeof(IConfiguration),
                                       () => new ReadOnlyConfiguration((IConfiguration)configuration), true);
                configuration.Register(typeof(IConfigurationProvider), () => this, true);
                configuration.Register(typeof(IHelixModuleProvider), () => _helixModuleProvider, true);
                configuration.Register(typeof(IDataSourceLocation), () => _dataSourceLocation, true);
            }

            InternalConfigurations = configurations
                                     .Cast <IConfiguration>()
                                     .Select(config => (IConfiguration) new ReadOnlyConfiguration(config))
                                     .ToArray();
        }
Ejemplo n.º 4
0
        protected virtual void LoadConfigurations()
        {
            var parser = new XmlContainerParser(_configsElement, _baseConfigElement, new XmlInheritanceEngine());

            var definitions = parser.GetContainers();

            var configurations = GetContainers(definitions).ToArray();

            foreach (var configuration in configurations)
            {
                // Assert that expected dependencies exist - and in the case of data stores are specifically singletons (WEIRD things happen otherwise)
                configuration.AssertSingleton(typeof(IFieldFilter));
                configuration.AssertSingleton(typeof(ITemplatePredicate));
                configuration.AssertSingleton(typeof(ITypeNameGenerator));
                configuration.AssertSingleton(typeof(ITemplateReader));
                configuration.Assert(typeof(ICodeGenerator));

                // register the container with itself. how meta!
                configuration.Register(typeof(IContainer), () => configuration, true);
            }

            _configurations = configurations.ToArray();
        }