Exemplo n.º 1
0
        public static DIConstruct AddWpfPlotDigitizerServices(this DIConstruct construction)
        {
            construction.Services.AddSingleton <PageManager>();
            construction.Services.AddSingleton <TutorialManager>();
            construction.Services.AddSingleton <MessageManager>();
            construction.Services.AddSingleton <ApplicationManager>();
            construction.Services.AddSingleton <ApplicationData>();

            construction.Services.AddSingleton <MainWindowVM>();
            construction.Services.AddSingleton <SplashPageVM>();
            construction.Services.AddSingleton <BrowsePageVM>();
            construction.Services.AddSingleton <AxisPageVM>();
            construction.Services.AddSingleton <AxLimPageVM>();
            construction.Services.AddSingleton <FilterPageVM>();
            construction.Services.AddSingleton <ErasePageVM>();
            construction.Services.AddSingleton <DataPageVM>();
            construction.Services.AddSingleton <SavePageVM>();

            construction.Services.AddSingleton <MainWindow>();
            construction.Services.AddSingleton <SplashPage>();
            construction.Services.AddSingleton <BrowsePage>();
            construction.Services.AddSingleton <AxisPage>();
            construction.Services.AddSingleton <AxLimPage>();
            construction.Services.AddSingleton <FilterPage>();
            construction.Services.AddSingleton <ErasePage>();
            construction.Services.AddSingleton <DataPage>();
            construction.Services.AddSingleton <SavePage>();

            return(construction);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Should be called once a Framework Construction is finished and we want to build it and
        /// start our application
        /// </summary>
        /// <param name="construction">The construction</param>
        /// <param name="logStarted">Specifies if the Dna Framework Started message should be logged</param>
        public static void Build(this FrameworkConstruction construction, bool logStarted = true)
        {
            // Build the service provider
            construction.Build();

            // Log the startup complete
            if (logStarted)
            {
                Logger.LogCriticalSource($"Dna Framework started in {FrameworkEnvironment.Configuration}...");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Injects all of the default services used by Dna.Framework for a quicker and cleaner setup
        /// </summary>
        /// <param name="construction">The construction</param>
        /// <returns></returns>
        public static FrameworkConstruction UseDefaultServices(this FrameworkConstruction construction)
        {
            // Add exception handler
            construction.AddDefaultExceptionHandler();

            // Add default logger
            construction.AddDefaultLogger();

            // Chain the construction
            return(construction);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Injects a file logger into the framework construction
        /// </summary>
        /// <param name="construction">The construction</param>
        /// <param name="logPath">The path of the file to log to</param>
        /// <returns></returns>
        public static FrameworkConstruction UseFileLogger(this FrameworkConstruction construction, string logPath = "log.txt")
        {
            // Make use of AddLogging extension
            construction.Services.AddLogging(options =>
            {
                // Add file logger
                options.AddFile(logPath);
            });

            // Chain the construction
            return(construction);
        }
        /// <summary>
        /// Injects a file logger into the framework construction
        /// </summary>
        /// <param name="construction">The construction</param>
        /// <param name="logPath">The path of the file to log to</param>
        /// <param name="logTop">Whether to display latest logs at the top of the file</param>
        /// <returns></returns>
        public static FrameworkConstruction AddFileLogger(this FrameworkConstruction construction, string logPath = "log.txt", bool logTop = true)
        {
            // Make use of AddLogging extension
            construction.Services.AddLogging(options =>
            {
                // Add file logger
                options.AddFile(logPath, new FileLoggerConfiguration {
                    LogAtTop = logTop
                });
            });

            // Chain the construction
            return(construction);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add a default logger so that we can get a non-generic ILogger
        /// that will have the category name of Dna.Framework
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddDefaultLogger(this FrameworkConstruction construction)
        {
            // add logging is default
            construction.Services.AddLogging(options =>
            {
                // setup loggers from configuration
                options.AddConfiguration(construction.Configuration.GetSection("Logging"));
                // add console logger
                options.AddConsole();
                // add debug logger
                options.AddDebug();
                // add file logger
                // options.AddFile("log.txt");
            });

            construction.Services.AddTransient(provider => provider.GetService <ILoggerFactory>().CreateLogger("Dna"));
            return(construction);
        }
        /// <summary>
        /// Injects the default logger into the framework construction
        /// </summary>
        /// <param name="construction">The construction</param>
        /// <returns></returns>
        public static FrameworkConstruction AddDefaultLogger(this FrameworkConstruction construction)
        {
            // Add logging as default
            construction.Services.AddLogging(options =>
            {
                // Setup loggers from configuration
                options.AddConfiguration(construction.Configuration.GetSection("Logging"));

                // Add console logger
                options.AddConsole();

                // Add debug logger
                options.AddDebug();
            });

            // Adds a default logger so that we can get a non-generic ILogger
            // that will have the category name of "Dna"
            construction.Services.AddTransient(provider => provider.GetService <ILoggerFactory>().CreateLogger("Dna"));

            // Chain the construction
            return(construction);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Inject all of the default Exception used by Dna.Framework for a quicker and cleaner setup
 /// </summary>
 /// <param name="construction"></param>
 /// <returns></returns>
 public static FrameworkConstruction AddDefaultExceptionHandler(this FrameworkConstruction construction)
 {
     construction.Services.AddSingleton <IExceptionHandler>(new BaseExceptionHandler());
     return(construction);
 }