Example #1
0
        public static void LoadAssemblies(IConfiguration configuration, Action <Assembly> action)
        {
            ModulesOptions options = configuration.Get <ModulesOptions>();

            var platform = configuration.GetValue <string>("platformModuleName");
            var module   = options.Modules.Find(x => x.Name == platform);
            var engine   = configuration.GetValue <string>($"{platform}:BotEngine");

            Formatter[] settings = new Formatter[]
            {
                new Formatter(platform, Color.Yellow),
                new Formatter(module.Name, Color.Yellow),
                new Formatter(engine, Color.Yellow),
            };

            // load platform emulator dynamically
            Console.WriteLine();

            var platformDllPath = Path.Combine(options.ModuleBasePath, module.Path, $"{module.Type}.dll");

            if (File.Exists(platformDllPath))
            {
                Assembly library = AssemblyLoadContext.Default.LoadFromAssemblyPath(platformDllPath);
                action(library);
                Console.WriteLineFormatted("Loaded {0} platform emulator from {1} assembly which is using {2} engine.", Color.White, settings);
            }
            else
            {
                Console.WriteLine($"Can't load {module.Type} assembly.");
            }
            Console.WriteLine();
        }
Example #2
0
        public static void LoadAssemblies(IConfiguration configuration, Action <Assembly> action)
        {
            ModulesOptions options = configuration.Get <ModulesOptions>();

            // load platform emulator dynamically
            Console.WriteLine();

            options.Modules.ForEach(module => {
                if (String.IsNullOrEmpty(module.Path))
                {
                    module.Path = AppContext.BaseDirectory;
                }
                var dllPath = Path.Combine(module.Path, $"{module.Type}.dll");
                if (File.Exists(dllPath))
                {
                    Assembly library = AssemblyLoadContext.Default.LoadFromAssemblyPath(dllPath);
                    action(library);

                    Formatter[] settings = new Formatter[]
                    {
                        new Formatter(module.Name, Color.Yellow),
                        new Formatter(module.Type, Color.Yellow),
                        new Formatter(dllPath, Color.Yellow)
                    };
                    Console.WriteLineFormatted("Loaded {0} module, type: {1}, path: {2}", Color.White, settings);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteFormatted($"Can't load {module.Type} assembly from {dllPath}.", Color.Red);
                    Console.WriteLine();
                }
            });
        }
Example #3
0
 public LoginViewModel(IModuleManager moduleManager, IModuleCatalog catalog, IRegionManager regionManager, IWindowService windowService,
                       ModulesOptions options, VersionFolderPathResolver versionResolver, MazeRestClientWrapper restClientWrapper)
 {
     _moduleManager     = moduleManager;
     _catalog           = catalog;
     _regionManager     = regionManager;
     _windowService     = windowService;
     _options           = options;
     _versionResolver   = versionResolver;
     _restClientWrapper = restClientWrapper;
 }
Example #4
0
        public void RegisterTypes(IContainerRegistry containerRegistry)
        {
            Tx.LoadFromEmbeddedResource("Maze.Administration.ViewModels.Resources.translation.txd");

            containerRegistry.RegisterSingleton <IClientManager, ClientManager>();
            containerRegistry.RegisterSingleton <IXmlSerializerCache, XmlSerializerCache>();
            containerRegistry.GetContainer().AsImplementedInterfaces <MazeRestClientWrapper, ContainerControlledLifetimeManager>();

            var options = new ModulesOptions {
                LocalPath = "packages", TempPath = "temp"
            };

            containerRegistry.RegisterInstance(options);
            containerRegistry.RegisterInstance <VersionFolderPathResolver>(
                new VersionFolderPathResolverFlat(Environment.ExpandEnvironmentVariables(options.LocalPath)));
        }
Example #5
0
        public static ModulesOptions ConfigureIdentityModule(this ModulesOptions modulesOptions, IConfiguration config)
        {
            var           moduleName    = typeof(IdentityModuleOptionsExtensions).GetTypeInfo().Assembly.GetName().Name;
            ModuleOptions moduleOptions = null;

            if (!modulesOptions.ModuleOptions.TryGetValue(moduleName, out moduleOptions))
            {
                modulesOptions.ModuleOptions[moduleName] = new ModuleOptions();
            }
            modulesOptions.ModuleOptions[moduleName].ConfigureServices.Add(services =>
            {
                services.Configure <IdentityModuleOptions>(identityModuleOptions =>
                {
                    identityModuleOptions.ConnectionString = config.GetConnectionString("DefaultConnection");
                });
            });
            return(modulesOptions);
        }
Example #6
0
        public ModuleStartup(IConfiguration configuration)
        {
            this._configuration = configuration ??
                                  throw new ArgumentNullException(nameof(configuration));
            ModulesOptions options = configuration.Get <ModulesOptions>();

            this._modules = options.Modules.Select(s => {
                Type type = Type.GetType($"{s.Type}.MoudleInjector,{s.Type}");
                if (type == null)
                {
                    Console.WriteLine($"不能导入{s.Type}", Color.Red);
                    return(null);
                }
                else
                {
                    IModule module = (IModule)Activator.CreateInstance(type);
                    return(module);
                }
            });
        }
Example #7
0
        public LoginViewModel(IModuleManager moduleManager, IModuleCatalog catalog, IRegionManager regionManager, IWindowService windowService,
                              ModulesOptions options, VersionFolderPathResolver versionResolver, MazeRestClientWrapper restClientWrapper)
        {
            _moduleManager     = moduleManager;
            _catalog           = catalog;
            _regionManager     = regionManager;
            _windowService     = windowService;
            _options           = options;
            _versionResolver   = versionResolver;
            _restClientWrapper = restClientWrapper;

            var settingsFile = new FileInfo(SettingsFilename);

            if (settingsFile.Exists)
            {
                var settings = JsonConvert.DeserializeObject <ServerConnectionInfo>(File.ReadAllText(settingsFile.FullName));
                ServerUrl = settings.ServerUrl;
                Username  = settings.Username;
            }
        }
Example #8
0
 public PackageLockUpdater(IOptions <ModulesOptions> options, IFileSystem fileSystem)
 {
     _fileSystem = fileSystem;
     _options    = options.Value;
 }
Example #9
0
 public ConfigurationManager(IOptions <ModulesOptions> options, IFileSystem fileSystem)
 {
     _fileSystem = fileSystem;
     _options    = options.Value;
 }
Example #10
0
 public ModuleDownloader(IModulesDirectory modulesDirectory, IOptions <ModulesOptions> options)
 {
     _modulesDirectory = modulesDirectory;
     _options          = options.Value;
 }
Example #11
0
 public PackageInitialization(ModulesOptions options, IServiceCollection serviceCollection, IConfiguration configuration)
 {
     _options           = options;
     _serviceCollection = serviceCollection;
     _configuration     = configuration;
 }
Example #12
0
 public NuGetController(IOptions <ModulesOptions> options)
 {
     _options = options.Value;
 }