예제 #1
0
        /// <summary>
        /// Initializes the current application as a Windows Forms application.
        /// </summary>
        /// <param name="culture">The application's culture.</param>
        /// <param name="singleInstance">
        /// if set to <c>true</c> then the application will be a single-instance application.
        /// </param>
        /// <remarks>
        /// The culture passed to this method is affected to both the current culture and the current UI culture.
        /// </remarks>
        public static void InitializeWindowsFormsApplication(string culture, bool singleInstance)
        {
            AttachThreadException();

            System.Windows.Forms.Application.ApplicationExit += new EventHandler(OnWindowsFormsApplicationExit);

            // Set the application type.
            Application.SetApplicationType(ThisApplicationType.WindowsFormsApplication);

            // Single instance?
            Application.IsSingleInstance = singleInstance;

            SetApplicationCulture(culture);

            // We also add a UI service (to the parent container, so that it can be replaced).
            parentContainer.AddService <ISimpleUIService>(new SimpleUIService());
        }
예제 #2
0
        /// <summary>
        /// Adds the default services to the parent container.
        /// </summary>
        /// <remarks>
        /// All the services added here are added to the parent container.
        /// This way, if a client class adds a service using the <see cref="Services"/>
        /// property, and this service's type is already present, it will work, the newly
        /// added service will hide the existing one.
        /// </remarks>
        private static void AddDefaultServices()
        {
            LogManagerService logManager = new LogManagerService(new SimpleLogService());

            parentContainer.AddService <ILogService>(logManager);

            // We don't want the log manager to be masked by another implementation.
            childContainer.AddService <ILogManagerService>(logManager);

            // Remark: we pass the child container to the IExceptionHandlerService instance
            // constructor so that it uses the services that may be added by a client class,
            // and not always the default ones (especially for the logging service);
            parentContainer.AddService <IExceptionHandlerService>(
                new BaseExceptionHandlerService(childContainer));
        }