Beispiel #1
0
        /// <summary>
        /// Called by an application in order to initialize the application extension service.
        /// </summary>
        /// <param name="context">Provides information about the application state. </param>
        public void StartService(ApplicationServiceContext context)
        {
            var logLevel = LogSeverityLevel;

            if (context.ApplicationInitParams.ContainsKey(Constants.INIT_PARAM_LOGLEVEL))
            {
                logLevel =
                    (LogSeverity)
                    Enum.Parse(typeof(LogSeverity), context.ApplicationInitParams[Constants.INIT_PARAM_LOGLEVEL], true);
            }

            _mainCatalog = new AggregateCatalog(new DeploymentCatalog()); // empty one adds current deployment (xap)

            _container = new CompositionContainer(_mainCatalog);

            CompositionHost.Initialize(_container);
            CompositionInitializer.SatisfyImports(this);

            if (Logger == null)
            {
                ILogger defaultLogger = new DefaultLogger(logLevel);
                _container.ComposeExportedValue(defaultLogger);
            }
            else
            {
                Logger.SetSeverity(logLevel);
            }

            DeploymentService.Catalog   = _mainCatalog;
            DeploymentService.Container = _container;
            _mefDebugger = new MefDebugger(_container, Logger);
        }
Beispiel #2
0
        /// <summary>
        /// Called by an application in order to initialize the application extension service.
        /// </summary>
        /// <param name="context">Provides information about the application state. </param>
        public void StartService(ApplicationServiceContext context)
        {
            var logLevel = LogSeverityLevel;
            if (context != null)
            {
                foreach (var item in context.ApplicationInitParams)
                {
                    Application.Current.Resources.Add(item.Key, item.Value);
                }

                if (context.ApplicationInitParams.ContainsKey(Constants.INIT_PARAM_LOGLEVEL))
                {
                    logLevel =
                        (LogSeverity)
                        Enum.Parse(typeof(LogSeverity), context.ApplicationInitParams[Constants.INIT_PARAM_LOGLEVEL], true);
                }
                else if (context.ApplicationInitParams.ContainsKey(HttpUtility.UrlEncode(Constants.INIT_PARAM_LOGLEVEL)))
                {
                    logLevel =
                        (LogSeverity)
                        Enum.Parse(typeof(LogSeverity), HttpUtility.UrlDecode(context.ApplicationInitParams[HttpUtility.UrlEncode(Constants.INIT_PARAM_LOGLEVEL)]), true);
                }
            }

            _mainCatalog = new AggregateCatalog(new DeploymentCatalog()); // empty one adds current deployment (xap)

            _container = new CompositionContainer(_mainCatalog);

            CompositionHost.Initialize(_container);
            CompositionInitializer.SatisfyImports(this);

            if (Logger == null)
            {
                ILogger defaultLogger = new DefaultLogger(logLevel);
                _container.ComposeExportedValue(defaultLogger);
            }
            else
            {
                Logger.SetSeverity(logLevel);
            }

            DeploymentService.Catalog = _mainCatalog;
            DeploymentService.Container = _container;
            _mefDebugger = new MefDebugger(_container, Logger);
        }