protected void InitDefaults()
    {
      // Check if the required service is already present, then no action is required
      bool pathManagerAvailable = ServiceRegistration.Get<Common.PathManager.IPathManager>(false) != null;
      if (pathManagerAvailable && _pathManagerWrapper != null && _loggerWrapper != null)
        return;

      if (_pathManagerWrapper != null && _loggerWrapper != null) 
        return;

      // If running outside of MP2 scope
      if (!pathManagerAvailable)
      {
        ServiceRegistration.Set<Common.Logging.ILogger>(new NoLogger());

        Common.Services.PathManager.PathManager pathManager = new Common.Services.PathManager.PathManager();
        pathManager.InitializeDefaults();

        ServiceRegistration.Set<Common.PathManager.IPathManager>(pathManager);

        Common.Logging.ILogger logger = new Log4NetLogger(pathManager.GetPath(@"<LOG>"));
        logger.Info("MP2IntegrationProvider: Launching in AppDomain {0}...", AppDomain.CurrentDomain.FriendlyName);
      }

      _pathManagerWrapper = new PathManagerWrapper();
      _loggerWrapper = new LoggerWrapper();
    }
    protected void InitDefaults()
    {
      // Check if the required service is already present, then no action is required
      bool pathManagerAvailable = ServiceRegistration.Get<Common.PathManager.IPathManager>(false) != null;
      if (pathManagerAvailable && _pathManagerWrapper != null && _loggerWrapper != null)
        return;

      if (_pathManagerWrapper != null && _loggerWrapper != null)
        return;

      // If running outside of MP2 scope
      if (!pathManagerAvailable)
      {
        ServiceRegistration.Set<Common.Logging.ILogger>(new NoLogger());

        Common.Services.PathManager.PathManager pathManager = new Common.Services.PathManager.PathManager();
        pathManager.InitializeDefaults();

        ServiceRegistration.Set<Common.PathManager.IPathManager>(pathManager);
        Common.Logging.ILogger logger = new Log4NetLogger(pathManager.GetPath(@"<LOG>"));
        ServiceRegistration.Set<Common.Logging.ILogger>(logger);
      }

      var isTve3 = IsTVE3();
      _pathManagerWrapper = new PathManagerWrapper(isTve3);
      _loggerWrapper = new LoggerWrapper();
    }
示例#3
0
    /// <summary>
    /// Creates vital core service instances and registers them in <see cref="ServiceRegistration"/>. The optional <paramref name="dataDirectory"/> argument can
    /// be used to startup the application using a custom directory for data storage.
    /// </summary>
    /// <param name="dataDirectory">Path to custom data directory</param>
    public static void RegisterVitalCoreServices(string dataDirectory = null)
    {
      // Insert a dummy while loading the path manager to break circular dependency of logger and path manager. This should not
      // be considered as a hack - simply the logger needs a path managed by the path manager and I don't want to remove log
      // output from the path manager only to prevent the dependency. Maybe we have a better solution in the future.
      ServiceRegistration.Set<ILogger>(new NoLogger());

      Services.PathManager.PathManager pathManager = new Services.PathManager.PathManager();
      pathManager.InitializeDefaults();
      if (!string.IsNullOrEmpty(dataDirectory))
        pathManager.SetPath("DATA", dataDirectory);

      ServiceRegistration.Set<IPathManager>(pathManager);

      ILogger logger = new Log4NetLogger(pathManager.GetPath(@"<LOG>"));

      logger.Info("ApplicationCore: Launching in AppDomain {0}...", AppDomain.CurrentDomain.FriendlyName);

      // Assembly and build information
      FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetCallingAssembly().Location);
      logger.Info("ApplicationCore: Comments:   {0}", fileVersionInfo.Comments);
      logger.Info("ApplicationCore: Copyright:  {0}", fileVersionInfo.LegalCopyright);
      logger.Info("ApplicationCore: Version:    {0}", fileVersionInfo.FileVersion);
      logger.Info("ApplicationCore: Source:     {0}", fileVersionInfo.ProductVersion);
      logger.Info("ApplicationCore: ----------------------------------------------------------");

      logger.Debug("ApplicationCore: Registering ILogger service");
      ServiceRegistration.Set<ILogger>(logger);

      logger.Debug("ApplicationCore: Registering ISettingsManager service");
      ServiceRegistration.Set<ISettingsManager>(new SettingsManager());
    }
示例#4
0
    /// <summary>
    /// Creates vital core service instances and registers them in <see cref="ServiceRegistration"/>. The optional <paramref name="dataDirectory"/> argument can
    /// be used to startup the application using a custom directory for data storage.
    /// </summary>
    /// <param name="dataDirectory">Path to custom data directory</param>
    public static void RegisterVitalCoreServices(string dataDirectory = null)
    {
      // Insert a dummy while loading the path manager to break circular dependency of logger and path manager. This should not
      // be considered as a hack - simply the logger needs a path managed by the path manager and I don't want to remove log
      // output from the path manager only to prevent the dependency. Maybe we have a better solution in the future.
      ServiceRegistration.Set<ILogger>(new NoLogger());

      Services.PathManager.PathManager pathManager = new Services.PathManager.PathManager();
      pathManager.InitializeDefaults();
      if (!string.IsNullOrEmpty(dataDirectory))
        pathManager.SetPath("DATA", dataDirectory);

      ServiceRegistration.Set<IPathManager>(pathManager);

      ILogger logger = new Log4NetLogger(pathManager.GetPath(@"<LOG>"));

      logger.Info("ApplicationCore: Launching in AppDomain {0}...", AppDomain.CurrentDomain.FriendlyName);

      logger.Debug("ApplicationCore: Registering ILogger service");
      ServiceRegistration.Set<ILogger>(logger);

      logger.Debug("ApplicationCore: Registering ISettingsManager service");
      ServiceRegistration.Set<ISettingsManager>(new SettingsManager());
    }
示例#5
0
    /// <summary>
    /// Creates core service instances and registers them in <see cref="ServiceRegistration"/>. The optional <paramref name="dataDirectory"/> argument can
    /// be used to startup the application using a custom directory for data storage.
    /// </summary>
    /// <param name="dataDirectory">Path to custom data directory</param>
    public static void RegisterCoreServices(string dataDirectory = null)
    {
      // Insert a dummy while loading the path manager to break circular dependency of logger and path manager. This should not
      // be considered as a hack - simply the logger needs a path managed by the path manager and I don't want to remove log
      // output from the path manager only to prevent the dependency. Maybe we have a better solution in the future.
      ServiceRegistration.Set<ILogger>(new NoLogger());

      Services.PathManager.PathManager pathManager = new Services.PathManager.PathManager();
      pathManager.InitializeDefaults();
      if (!string.IsNullOrEmpty(dataDirectory))
        pathManager.SetPath("DATA", dataDirectory);

      ServiceRegistration.Set<IPathManager>(pathManager);

      ILogger logger = new Log4NetLogger(pathManager.GetPath(@"<LOG>")); 
      logger.Info("ApplicationCore: Launching in AppDomain {0}...", AppDomain.CurrentDomain.FriendlyName);

      logger.Debug("ApplicationCore: Registering ILogger service");
      ServiceRegistration.Set<ILogger>(logger);

      logger.Debug("ApplicationCore: Registering IRegistry service");
      ServiceRegistration.Set<IRegistry>(new Services.Registry.Registry());

      logger.Debug("ApplicationCore: Registering IThreadPool service");
      ServiceRegistration.Set<IThreadPool>(new ThreadPool());

      logger.Debug("ApplicationCore: Registering IMessageBroker service");
      ServiceRegistration.Set<IMessageBroker>(new MessageBroker());

      logger.Debug("ApplicationCore: Registering IPluginManager service");
      ServiceRegistration.Set<IPluginManager>(new Services.PluginManager.PluginManager());

      logger.Debug("ApplicationCore: Registering ISettingsManager service");
      ServiceRegistration.Set<ISettingsManager>(new SettingsManager());

      logger.Debug("ApplicationCore: Registering ILocalization service");
      ServiceRegistration.Set<ILocalization>(new StringManager());

      logger.Debug("ApplicationCore: Registering ITaskScheduler service");
      ServiceRegistration.Set<ITaskScheduler>(new Services.TaskScheduler.TaskScheduler());

      logger.Debug("ApplicationCore: Registering IMediaAccessor service");
      ServiceRegistration.Set<IMediaAccessor>(new MediaAccessor());

      logger.Debug("ApplicationCore: Registering IImporterWorker service");
      ServiceRegistration.Set<IImporterWorker>(new ImporterWorker());

      logger.Debug("ApplicationCore: Registering IResourceServer service");
      ServiceRegistration.Set<IResourceServer>(new ResourceServer());

      logger.Debug("ApplicationCore: Registering IResourceMountingService");
      ServiceRegistration.Set<IResourceMountingService>(new ResourceMountingService());

      logger.Debug("ApplicationCore: Registering IRemoteResourceInformationService");
      ServiceRegistration.Set<IRemoteResourceInformationService>(new RemoteResourceInformationService());

      logger.Debug("ApplicationCore: Registering IThumbnailGenerator service");
      ServiceRegistration.Set<IThumbnailGenerator>(new ThumbnailGenerator());

      AdditionalPluginItemBuilders.Register();
    }