Example #1
0
		/// <summary>
		/// Starts the core services.
		/// This initializes the PropertyService and ResourceService.
		/// </summary>
		public void StartCoreServices(IPropertyService propertyService)
		{
			var container = ServiceSingleton.GetRequiredService<IServiceContainer>();
			var applicationStateInfoService = new ApplicationStateInfoService();
			addInTree = new AddInTreeImpl(applicationStateInfoService);
			
			container.AddService(typeof(IPropertyService), propertyService);
			container.AddService(typeof(IResourceService), new ResourceServiceImpl(
				Path.Combine(propertyService.DataDirectory, "resources"), propertyService));
			container.AddService(typeof(IAddInTree), addInTree);
			container.AddService(typeof(ApplicationStateInfoService), applicationStateInfoService);
			StringParser.RegisterStringTagProvider(new AppNameProvider { appName = applicationName });
		}
Example #2
0
        /// <summary>
        /// Starts the core services.
        /// This initializes the PropertyService and ResourceService.
        /// </summary>
        /// <returns>A list containing service types and the corresponding instances.</returns>
        public Tuple<IEnumerable<KeyValuePair<Type, Type>>, IEnumerable<KeyValuePair<Type, object>>> StartCoreServices()
        {
            if(config_directory == null)
                config_directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                               application_name);

            var property_service = new PropertyServiceImpl(
                DirectoryName.Create(config_directory),
                DirectoryName.Create(data_directory ?? Path.Combine(FileUtility.ApplicationRootPath, "data")),
                properties_name);
            var application_state_info_service = new ApplicationStateInfoService();
            addInTree = new AddInTreeImpl(application_state_info_service);

            var services = new List<KeyValuePair<Type, Type>>();
            var instances = new List<KeyValuePair<Type, object>>();
            instances.Add(new KeyValuePair<Type,object>(typeof(IPropertyService), property_service));
            //instances.Add(new KeyValuePair<Type,object>(typeof(IResourceService), new ResourceServiceImpl(
            //    Path.Combine(property_service.DataDirectory, "resources"), property_service)));
            instances.Add(new KeyValuePair<Type,object>(typeof(IAddInTree), addInTree));

            services.Add(new KeyValuePair<Type,Type>(typeof(ApplicationStateInfoService), typeof(ApplicationStateInfoService)));
            StringParser.RegisterStringTagProvider(new AppNameProvider{AppName = application_name});

            return Tuple.Create((IEnumerable<KeyValuePair<Type, Type>>)services, (IEnumerable<KeyValuePair<Type, object>>)instances);
        }