コード例 #1
0
        /// <summary>
        /// Initializes app configuration.
        /// </summary>
        private async Task InitializeBootstrap()
        {
            /*
             * GR Bootstrap Initializers Common Order Recommendations:
             *
             * ... - -1    Setup No-dependency Initializer Preparers.
             * 0           Global Configuration
             * 1           Main Specific Configuration
             * 2 - 10      Setup Config dependent Initializer Preparers
             * 11 - 20     Important Configuration
             * 21 - 100    Normal Priority Configuration
             * 101 - ...   Low Priority Initializers.
             */

            //Order Bootstrap Initializers.
            var bootstrapInitializers = BootstrapInitializers
                                        .Distinct()
                                        .OrderBy(init => init.Order)
                                        .ThenBy(init => init.InitializerName)
                                        .ToList();

            foreach (var bootstrapInitializer in bootstrapInitializers)
            {
                OnInitializerStatusChanged?.Invoke($"Running: {bootstrapInitializer.InitializerName}");
                await bootstrapInitializer.DoInitialize();
            }

            OnInitializerStatusChanged?.Invoke("Bootstrap Done!");
        }
コード例 #2
0
        /// <summary>
        /// Initializes app components.
        /// </summary>
        private async Task InitializeApplication()
        {
            var initializers = IoCManager.Resolver
                               .ResolveInstance <IEnumerable <IAppInitializer> >()
                               .Distinct()
                               .ToList()
                               .OrderBy(init => init.Order)
                               .ThenBy(init => init.InitializerName);

            foreach (var appInitializer in initializers)
            {
                var initializerName = appInitializer.InitializerName;
                OnInitializerStatusChanged?.Invoke($"Running: {initializerName}");
                await appInitializer.DoInitialize();
            }

            OnInitializerStatusChanged?.Invoke("All done!");
        }