Ejemplo n.º 1
0
		private ITaskConfiguration CreateTaskConfiguration(IContext context, TaskTypeCatalog taskTypes, XPathNavigator taskNode)
		{
			string taskName = taskNode.GetAttribute("taskName", string.Empty);

			if (taskTypes.TaskNameToConfigType.ContainsKey(taskName)) //has a config class
			{
				//make the task configuration class, using the xml we're looking at
				return context.Resolve<ITaskConfiguration>(taskName + "Config",// using this service name
												   new Parameter[] { new TypedParameter(typeof(string), taskNode.OuterXml) });
			}
			return null;
		}
Ejemplo n.º 2
0
        private ITaskConfiguration CreateTaskConfiguration(IComponentContext context, TaskTypeCatalog taskTypes, XPathNavigator taskNode)
        {
            string taskName = taskNode.GetAttribute("taskName", string.Empty);

            if (taskTypes.TaskNameToConfigType.ContainsKey(taskName))             //has a config class
            {
                //make the task configuration class, using the xml we're looking at
                return(context.ResolveNamed <ITaskConfiguration>(taskName + "Config",               // using this service name
                                                                 new Parameter[] { new TypedParameter(typeof(string), taskNode.OuterXml) }));
            }
            return(null);
        }
Ejemplo n.º 3
0
 public ConfigFileReader(string currentXmlConfiguration, string defaultXmlConfiguration, TaskTypeCatalog taskTypes)
 {
     _currentXmlConfiguration = currentXmlConfiguration;
     _defaultXmlConfiguration = defaultXmlConfiguration;
     _taskTypes = taskTypes;
 }
Ejemplo n.º 4
0
		public ConfigFileReader(string xmlConfiguration, TaskTypeCatalog taskTypes)
		{
			_xmlConfiguration = xmlConfiguration;
			_taskTypes = taskTypes;
		}
Ejemplo n.º 5
0
		private void PopulateDIContainer()
		{
			var builder = new ContainerBuilder();

			//builder.Register<UserSettingsRepository>(new UserSettingsRepository());
			builder.Register(new WordListCatalog()).SingletonScoped();

			builder.Register<IProgressNotificationProvider>(new DialogProgressNotificationProvider());

			builder.Register<LexEntryRepository>(
				c => c.Resolve<IProgressNotificationProvider>().Go<LexEntryRepository>("Loading Dictionary",
						progressState => new LexEntryRepository(_pathToLiftFile, progressState)));

			//builder.Register<ViewTemplate>(DefaultPrintingTemplate).Named("PrintingTemplate");

			var catalog = new TaskTypeCatalog();
			catalog.RegisterAllTypes(builder);

			builder.Register<TaskTypeCatalog>(catalog).SingletonScoped();

			//this is a bit weird, did it to get around a strange problem where it was left open,
			//never found out by whom.  But note, it does affect behavior.  It means that
			//the first time the reader is asked for, it will be reading the value as it was
			//back when we did this assignment.
			string configFileText = File.ReadAllText(PathToConfigFile);

			builder.Register<ConfigFileReader>(c => new ConfigFileReader(configFileText, catalog)).SingletonScoped();

			builder.Register<TaskCollection>().SingletonScoped();

			foreach (var viewTemplate in ConfigFileReader.CreateViewTemplates(configFileText))
			{
				//todo: this isn't going to work if we start using multiple tempates.
				//will have to go to a naming system.
				builder.Register(viewTemplate).SingletonScoped();
			}

		  //  builder.Register<ViewTemplate>(DefaultViewTemplate);

		  //  builder.Register(DefaultViewTemplate);
			// can't currently get at the instance
			//someday: builder.Register<StringCatalog>(new StringCatalog()).ExternallyOwned();

			_container = builder.Build();
		}