/// <summary>
        /// Injects the view models needed for Quan Word application
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddQuanWordViewModels(this FrameworkConstruction construction)
        {
            // Bind to a single instance of Application view model
            construction.Services.AddSingleton <ApplicationViewModel>();

            // Bind to a single instance of Settings view model
            construction.Services.AddSingleton <SettingsViewModel>();

            // Return the construction from chaining
            return(construction);
        }
        public static FrameworkConstruction UseClientDataStore(this FrameworkConstruction construction)
        {
            construction.Services.AddDbContext <ClientDataStoreDbContext>(options =>
            {
                //TODO use configuration json
                options.UseSqlite("Data Source=ChatApp.db");
            });

            construction.Services.AddScoped <IClientDataStore>(provider => new ClientDataStore(provider.GetService <ClientDataStoreDbContext>()));

            return(construction);
        }
Example #3
0
        public static FrameworkConstruction AddPosTicketViewModels(this FrameworkConstruction construction)
        {
            // Bind to a single instance of Application view model
            construction.Services.AddSingleton <ApplicationViewModel>();

            // Bind to a single instance of Settings view model
            construction.Services.AddSingleton <SetDepositViewModel>();

            construction.Services.AddSingleton <PosMainViewModel>();

            // Return the construction for chaining
            return(construction);
        }
Example #4
0
        private static FrameworkConstruction RegisterModule <T>(this FrameworkConstruction construction, T module)
            where T : IDependencyModule
        {
            if (module == null)
            {
                throw new Exception("Trying to register null module");
            }

            module.LoadConfiguration(construction.Configuration);
            module.ConfigureServices(construction.Services);

            return(construction);
        }
Example #5
0
        public static FrameworkConstruction UseClientDataStore(this FrameworkConstruction construction)
        {
            construction.Services.AddDbContext <ClientDataStoreDbContext>(options =>
            {
                string connectionString = construction.Configuration.GetConnectionString("ClientDataStoreConnection");
                options.UseSqlite(connectionString);
            });

            construction.Services.AddScoped <IClientDataStore>(
                provider => new ClientDataStore(provider.GetService <ClientDataStoreDbContext>()));

            return(construction);
        }
        /// <summary>
        /// Injects the Fasetto Word client application services needed
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddFasettoWordClientServices(this FrameworkConstruction construction)
        {
            // Add our task manager
            construction.Services.AddTransient <ITaskManager, TaskManager>();

            // Bind a file manager
            construction.Services.AddTransient <IFileManager, FileManager>();

            // Bind a UI Manager
            construction.Services.AddTransient <IUIManager, UIManager>();

            return(construction);
        }
Example #7
0
        /// <summary>
        /// Injects the Fasetto Word client application services needed
        /// for the Fasetto Word application
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction EnsureFileAssosiation(this FrameworkConstruction construction)
        {
#if DEBUG
#else
            FileAssociations.EnsureAssociationsSet();
#endif

            FileAssociations.EnsureAssociationsSet();


            // Return the construction for chaining
            return(construction);
        }
Example #8
0
        public static FrameworkConstruction AddModules(this FrameworkConstruction construction)
        {
            var assembly = typeof(AssemblyInfo).Assembly;

            foreach (var type in assembly.GetTypes()
                     .Where(t => t.GetInterfaces().Contains(typeof(IDependencyModule)) &&
                            t.HasParameterlessConstructor()))
            {
                construction.RegisterModule(type);
            }

            return(construction);
        }
        /// <summary>
        /// Injects the view models needed for Fasetto Word application
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddAppsViewModels(this FrameworkConstruction construction)
        {
            // Bind to a single instance of Application view model
            construction.Services.AddSingleton <ApplicationViewModel>();

            // Bind to a single instance of Settings view model
            construction.Services.AddSingleton <SettingsViewModel>();

            // Bind to a single instance of Equipment Management view model
            construction.Services.AddSingleton <EquipmentManagementViewModel>();

            // Return the construction for chaining
            return(construction);
        }
Example #10
0
        /// <summary>
        /// Injects the view models needed for Lorem Ipsum application
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddLoremIpsumViewModels(this FrameworkConstruction construction)
        {
            // Bind to a single instance of Application view model
            construction.Services.AddSingleton <ApplicationViewModel>();

            // Bind to a single instance of Settings view model
            construction.Services.AddSingleton <SettingsViewModel>();

            // Bind to a single instance of Localization view model
            construction.Services.AddSingleton <LocalizationViewModel>();

            // Return the construction for chaining
            return(construction);
        }
Example #11
0
        /// <summary>
        /// Injects the client application services needed
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddClientServices(this FrameworkConstruction construction)
        {
            // Add our task manager
            construction.Services.AddTransient <ITaskManager, BaseTaskManager>();

            // Bind a file manager
            construction.Services.AddTransient <IFileManager, BaseFileManager>();

            // Bind a UI Manager
            construction.Services.AddTransient <IUIManager, UIManager>();

            // Return the construction for chaining
            return(construction);
        }
Example #12
0
        public static FrameworkConstruction AddClientDataStore(this FrameworkConstruction construction)
        {
            // Inject our SQLite EF data store
            construction.Services.AddDbContext <ClientDataStoreDbContext>(options =>
            {
                options.UseSqlite(@"Data Source = C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\Synthesis.db");
                //construction.Configuration.GetConnectionString("ClientDataStoreConnection") == Data Source = synthesis.db!!!!!!!!!!!!!!!
            }, contextLifetime: ServiceLifetime.Transient);

            construction.Services.AddTransient <IClientDataStore>(
                provider => new BaseClientDataStore(provider.GetService <ClientDataStoreDbContext>()));

            return(construction);
        }
        public static FrameworkConstruction AddClientDataStore(this FrameworkConstruction construction)
        {
            // Inject our SQLite EF data store
            construction.Services.AddDbContext <ClientDataStoreDbContext>(options =>
                                                                          // Setup connection string
                                                                          options.UseSqlite(construction.Configuration.GetConnectionString("ClientDataStoreConnection")));

            // Add client data store for easy access/use of the backing data store
            // Make it scoped so we can inject the scoped database
            construction.Services.AddScoped <IClientDataStore>(
                provider => new ClientDataStore(provider.GetRequiredService <ClientDataStoreDbContext>()));

            // Return framework for chaining
            return(construction);
        }
Example #14
0
        /// <summary>
        /// Injects the view models needed for the application
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddViewModels(this FrameworkConstruction construction)
        {
            // Bind to a single instance of Application view model
            construction.Services.AddSingleton <ApplicationViewModel>();

            // Bind to a single instance of Settings view model
            construction.Services.AddSingleton <SettingsViewModel>();

            construction.Services.AddSingleton <NewEmployeeViewModel>();

            construction.Services.AddSingleton <EmployeeListViewModel>();

            // Return the construction for chaining
            return(construction);
        }
 /// <summary>
 /// Called when Dependency Injection is being setup
 /// </summary>
 /// <param name="construction">The framework construction</param>
 public override void ConfigureServices(FrameworkConstruction construction)
 {
     //
     //  Example
     // ---------
     //
     //   Add a service like this (include using Microsoft.Extensions.DependencyInjection):
     //
     //      construction.Services.AddSingleton(new SomeClass());
     //
     //   Retrieve the service anywhere in your application like this
     //
     //      Dna.Framework.Service<SomeClass>();
     //
 }
Example #16
0
        /// <summary>
        /// Adds the Localization manage to the DI
        /// </summary>
        /// <param name="construction">The construction</param>
        /// <returns></returns>
        public static FrameworkConstruction AddLocalizationManager(this FrameworkConstruction construction)
        {
            // Add the localization manager
            construction.Services.AddSingleton <ILocalizationManager>(new LocalizationManager
            {
                StringResourceDefinition = new ResourceDefinition
                {
                    Type     = ResourceDefinitionType.EmbeddedResource,
                    Location = "AngelSix.SolidDna.Localization.Strings.Strings-{0}.xml",
                    UseDefaultCultureIfNotFound = true,
                }
            });

            // Return for chaining
            return(construction);
        }
Example #17
0
        /// <summary>
        /// Extension Method for chaining
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction UseClientDataStore(this FrameworkConstruction construction)
        {
            //Inject data store
            construction.Services.AddDbContext <ClientDataStoreDbContext>(options => {
                //setup connection string
                string s = "Data Source=pwMan.cspd";
                options.UseSqlite(s);
            });

            // Inject IClientDataStore for access to the database (scoped)
            construction.Services.AddScoped <IClientDataStore>(
                provider => new ClientDataStore(provider.GetService <ClientDataStoreDbContext>())
                );

            return(construction);
        }
Example #18
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public static FrameworkConstruction AddClientDataStore(this FrameworkConstruction construction)
        {
            // Inject our SQLite EF data store
            construction.Services.AddDbContext <ClientDataStoreDbContext>(options =>
            {
                // Setup connection string
                options.UseSqlite("Data source = todo.db");
            });

            // Add client data store for easy access/use of the backing data store
            // Make it scoped so we can inject the scoped DbContext
            construction.Services.AddScoped <IClientDataStore>(
                provider => new ClientDataStore(provider.GetService <ClientDataStoreDbContext>()));

            // Return framework for chaining
            return(construction);
        }
Example #19
0
        public static FrameworkConstruction AddClientServices(this FrameworkConstruction construction)
        {
            // Add our task manager
            construction.Services.AddTransient <ITaskManager, BaseTaskManager>();

            // Add our CRON Scheduler
            construction.Services.AddSingleton <ICronScheduler, BaseCronScheduler>();

            // Add our Event Scheduler
            construction.Services.AddSingleton <IEventScheduler, BaseEventScheduler>();

            // Add our Valve Manager
            construction.Services.AddTransient <IValveManager, BaseValveManager>();

            // Return the construction for chaining
            return(construction);
        }
Example #20
0
        public static FrameworkConstruction AddClientDataStore(this FrameworkConstruction construction, string dbPath)
        {
            // Inject our SQLite EF data store
            construction.Services.AddDbContext <ClientDataStoreDbContext>(options =>
            {
                // Setup connection string
                options.UseSqlite($"Data Source={dbPath}");
            }, contextLifetime: ServiceLifetime.Transient);

            // Add client data store for easy access/use of the backing data store
            // Make it scoped so we can inject the scoped DbContext
            construction.Services.AddTransient <IClientDataStore>(
                provider => new BaseClientDataStore(provider.GetService <ClientDataStoreDbContext>()));

            // Return framework for chaining
            return(construction);
        }
Example #21
0
        /// <summary>
        /// Called when Dependency Injection is being setup
        /// </summary>
        /// <param name="construction">The framework construction</param>
        public override void ConfigureServices(FrameworkConstruction construction)
        {
            //
            //  Example
            // ---------
            //
            //   Add a service like this (include using Microsoft.Extensions.DependencyInjection):
            //
            //      construction.Services.AddSingleton(new SomeClass());
            //
            //   Retrieve the service anywhere in your application like this
            //
            //      Dna.Framework.Service<SomeClass>();
            //

            // Add file logger (will be in /bin/Debug/AddinTesting.log.txt)
            construction.AddFileLogger(Path.ChangeExtension(this.AssemblyFilePath(), "log.txt"));
        }
Example #22
0
        /// <summary>
        /// Injects the Fasetto Word client application services needed
        /// for the Fasetto Word application
        /// </summary>
        /// <param name="construction"></param>
        /// <returns></returns>
        public static FrameworkConstruction AddClientServices(this FrameworkConstruction construction)
        {
            // Add our task manager
            construction.Services.AddTransient <ITaskManager, BaseTaskManager>();

            // Bind a file manager
            construction.Services.AddTransient <IFileManager, BaseFileManager>();

            // Bind a Settings manager
            construction.Services.AddSingleton <ISettingsManager, SettingsManager>();

            //construction.Services.AddSingleton<ISpeechSynthesizer, SpeechSynthesizer>();

            // Bind a UI manager
            construction.Services.AddSingleton <IUIManager, UIManager>();

            // Return the construction for chaining
            return(construction);
        }
Example #23
0
        /// <summary>
        /// Setups an application with a custom behaviour
        /// </summary>
        /// <typeparam name="TApp">The type of behaviour</typeparam>
        /// <typeparam name="TStorage">The storage type</typeparam>
        public static FrameworkConstruction ConstructBehaviour <TApp, TStorage>(this FrameworkConstruction construction, Action <StructureBuilder> builder = null)
            where TApp : IAppBehaviour <TStorage>, new()
            where TStorage : IAppStorage
        {
            // Application startup
            var app = new TApp();            // Create instance of TApp

            app.Storage.CreateDirectories(); // Create storage directories
            app.CopyNeededFiles();           // Copy needed files

            Runtime runtime;

            if (builder != null)
            {
                // Invoke structure builder
                StructureBuilder sb = new StructureBuilder();
                builder.Invoke(sb);

                // Create runtime
                if (!Runtime.Verify())
                {
                    throw new InvalidOperationException("Runtime already initialized.");                    // Avoid duplicated runtime
                }
                runtime = new Runtime(sb.iParts.ToArray());
            }
            else
            {
                // Create without part runtime
                if (!Runtime.Verify())
                {
                    throw new InvalidOperationException("Runtime already initialized.");                    // Avoid duplicated runtime
                }
                runtime = new Runtime(null);
            }

            app.Runtime = runtime; // Set runtime

            // Inject services
            construction.Services.AddSingleton(typeof(IAppBehaviour <IAppStorage>), app);

            return(construction);
        }
        /// <summary>
        /// Injects the database for Testinator.Server application
        /// </summary>
        /// <param name="construction">Framework's construction</param>
        public static FrameworkConstruction AddDbContext(this FrameworkConstruction construction)
        {
            // Use Sqlite library
            construction.Services.AddEntityFrameworkSqlite();

            // Bind a db context to access in this application
            construction.Services.AddDbContext <TestinatorServerDbContext>();

            // Get the service provider
            var serviceProvider = construction.Services.BuildServiceProvider();

            using (var scope = serviceProvider.CreateScope())
            {
                // Get the db service
                var db = scope.ServiceProvider.GetRequiredService <TestinatorServerDbContext>();
                // Make sure its created properly and do pending migrations
                db.Database.Migrate();
            }

            // Return the construction for chaining
            return(construction);
        }
Example #25
0
        /// <summary>
        /// Setups an application with a custom behaviour
        /// </summary>
        /// <typeparam name="TApp">The type of behaviour</typeparam>
        public static FrameworkConstruction ConstructBehaviour <TApp>(this FrameworkConstruction construction, Action <StructureBuilder> builder = null)
            where TApp : IAppBehaviour, new()
        {
            var app = new TApp();  // Create instance of TApp

            app.CopyNeededFiles(); // Copy needed files

            // Add structure if builder is not null
            Runtime runtime = default;

            if (builder != null)
            {
                // Invoke structure builder
                StructureBuilder sb = new StructureBuilder();
                builder.Invoke(sb);

                // Create runtime
                if (!Runtime.Verify())
                {
                    throw new InvalidOperationException("Runtime already initialized.");                    // Avoid duplicated runtime
                }
                runtime = new Runtime(sb.iParts.ToArray());
            }

            // Create without part runtime
            if (!Runtime.Verify())
            {
                throw new InvalidOperationException("Runtime already initialized.");                    // Avoid duplicated runtime
            }
            runtime = new Runtime(null);

            app.Runtime = runtime; // Set runtime

            // Inject
            construction.Services.AddSingleton(typeof(BaseAppBehaviour), app);

            return(construction);
        }
Example #26
0
        /// <summary>
        /// Injects the view models needed for specifically Testinator.Client application
        /// </summary>
        /// <param name="construction">Framework's construction</param>
        public static FrameworkConstruction AddApplicationServices(this FrameworkConstruction construction)
        {
            // Bind to a single instance of specified models
            construction.Services.AddSingleton <ApplicationViewModel>();

            // Bind to a scoped instance of specified models
            construction.Services.AddSingleton <TestHost, TestHost>();
            construction.Services.AddSingleton <FileManagerBase, LogsWriter>();
            construction.Services.AddSingleton <ClientModel, ClientModel>();
            construction.Services.AddSingleton <ClientNetwork, ClientNetwork>();

            // Inject dependiencies into every page's view model
            construction.Services.AddTransient <LoginViewModel>();
            construction.Services.AddTransient <QuestionMultipleCheckboxesViewModel>();
            construction.Services.AddTransient <QuestionMultipleChoiceViewModel>();
            construction.Services.AddTransient <QuestionSingleTextBoxViewModel>();
            construction.Services.AddTransient <ResultQuestionsViewModel>();
            construction.Services.AddTransient <ResultOverviewViewModel>();
            construction.Services.AddTransient <WaitingForTestViewModel>();

            // Return the construction for chaining
            return(construction);
        }
        /// <summary>
        /// Injects the view models needed for specifically Testinator.Server application
        /// </summary>
        /// <param name="construction">Framework's construction</param>
        public static FrameworkConstruction AddApplicationServices(this FrameworkConstruction construction)
        {
            // Bind to a single instance of specified models
            construction.Services.AddSingleton <ApplicationViewModel>();
            construction.Services.AddSingleton <ApplicationSettingsViewModel>();

            // Bind to a scoped instance of specified models
            construction.Services.AddScoped <ServerNetwork, ServerNetwork>();
            construction.Services.AddScoped <TestHost, TestHost>();
            construction.Services.AddScoped <FileManagerBase, LogsWriter>();
            construction.Services.AddScoped <TestEditor, TestEditor>();
            construction.Services.AddScoped <UserMapper>();
            construction.Services.AddScoped <ISettingsRepository, SettingsRepository>();
            construction.Services.AddScoped <IUserRepository, UserRepository>();
            construction.Services.AddScoped <IUserAccountService, UserAccountService>();

            // Inject dependiencies into every page's view model
            construction.Services.AddTransient <BeginTestViewModel>();
            construction.Services.AddTransient <HomeViewModel>();
            construction.Services.AddTransient <LoginViewModel>();
            construction.Services.AddTransient <ScreenStreamViewModel>();
            construction.Services.AddTransient <AboutViewModel>();
            construction.Services.AddTransient <TestEditorAttachCriteriaViewModel>();
            construction.Services.AddTransient <TestEditorBasicInformationEditorViewModel>();
            construction.Services.AddTransient <TestEditorCriteriaEditorViewModel>();
            construction.Services.AddTransient <TestEditorFinalizingViewModel>();
            construction.Services.AddTransient <TestEditorInitialPageViewModel>();
            construction.Services.AddTransient <TestEditorQuestionsEditorViewModel>();
            construction.Services.AddTransient <TestEditorTestManagmentViewModel>();
            construction.Services.AddTransient <TestResultsDetailsViewModel>();
            construction.Services.AddTransient <TestResultsViewModel>();
            construction.Services.AddTransient <MultipleChoiceQuestionEditorViewModel>();

            // Return the construction for chaining
            return(construction);
        }
 public override void ConfigureServices(FrameworkConstruction construction)
 {
 }
 public override void ConfigureServices(FrameworkConstruction construction)
 {
     // Add file logger (will be in /bin/Debug/SolidDNA.ScriptRunner.com-register-log.txt)
     construction.AddFileLogger(Path.ChangeExtension(this.AssemblyFilePath(), "com-register-log.txt"));
 }
Example #30
0
 /// <summary>
 /// Add any dependency injection items into the DI provider that you would like to use in your application
 /// </summary>
 /// <param name="construction"></param>
 public abstract void ConfigureServices(FrameworkConstruction construction);