private void AddComponents(IConfiguration config)
		{
			String assemblyName = config.Attributes["name"];

			if (assemblyName == null || assemblyName.Length == 0)
			{
				String message = "The assemblyBatch node must have a 'name' attribute with the name of the assembly";

				throw new ConfigurationErrorsException(message);
			}

			ComponentScanner scanner = new ComponentScanner(assemblyName);

			ConfigureScanner(config, scanner);

			ComponentDefinition[] definitions = scanner.Process();

			foreach(ComponentDefinition definition in definitions)
			{
				if (definition.ServiceType == null)
				{
					Kernel.AddComponent( definition.Key, definition.ClassType );
				}
				else
				{
					Kernel.AddComponent( definition.Key, definition.ServiceType, definition.ClassType );
				}
			}
		}
Beispiel #2
0
        private void AddComponents(IConfiguration config)
        {
            String assemblyName = config.Attributes["name"];

            if (assemblyName == null || assemblyName.Length == 0)
            {
                throw new ConfigurationException("The assemblyBatch node must have a 'name' " +
                                                 " attribute with the name of the assembly");
            }

            ComponentScanner scanner = new ComponentScanner(assemblyName);

            ConfigureScanner(config, scanner);

            ComponentDefinition[] definitions = scanner.Process();

            foreach (ComponentDefinition definition in definitions)
            {
                if (definition.ServiceType == null)
                {
                    Kernel.AddComponent(definition.Key, definition.ClassType);
                }
                else
                {
                    Kernel.AddComponent(definition.Key, definition.ServiceType, definition.ClassType);
                }
            }
        }
Beispiel #3
0
        private void ConfigureScanner(IConfiguration config, ComponentScanner scanner)
        {
            if (config.Attributes["useAttributes"] != null)
            {
                scanner.UseAttributes = config.Attributes["useAttributes"].Equals("true");
            }

            foreach (IConfiguration innerConfig in config.Children)
            {
                if ("include".Equals(innerConfig.Name))
                {
                    String key       = innerConfig.Attributes["key"];
                    String service   = innerConfig.Attributes["service"];
                    String component = innerConfig.Attributes["component"];

                    scanner.AddInclude(key, service, component);
                }
                else if ("exclude".Equals(innerConfig.Name))
                {
                    String type = innerConfig.Attributes["type"];

                    scanner.AddExclude(type);
                }
                else
                {
                    throw new ConfigurationException("Invalid node inside assemblyBatch " +
                                                     "configuration. Expected 'include' or 'exclude'");
                }
            }
        }
		private void ConfigureScanner(IConfiguration config, ComponentScanner scanner)
		{
			if (config.Attributes["useAttributes"] != null)
			{
				scanner.UseAttributes = config.Attributes["useAttributes"].Equals("true");
			}
	
			foreach(IConfiguration innerConfig in config.Children)
			{
				if ("include".Equals(innerConfig.Name) )
				{
					String key = innerConfig.Attributes["key"];
					String service = innerConfig.Attributes["service"];
					String component = innerConfig.Attributes["component"];

					scanner.AddInclude( key, service, component );
				}
				else if ("exclude".Equals(innerConfig.Name) )
				{
					String type = innerConfig.Attributes["type"];

					scanner.AddExclude( type );
				}
				else
				{
					String message = "Invalid node inside assemblyBatch configuration. Expected 'include' or 'exclude'";

					throw new ConfigurationErrorsException(message);
				}
			}
		}