Пример #1
0
    private static bool BootstrapTileShop(string logFileName)
    {
        try
        {
            var bootstrapper = new BootstrapService(LoggerFactory.CreateLogger <BootstrapService>());

            var settingsFileName       = Path.Combine(AppContext.BaseDirectory, BootstrapService.DefaultConfigurationFileName);
            var codecPath              = Path.Combine(AppContext.BaseDirectory, BootstrapService.DefaultCodecPath);
            var codecSchemaFileName    = Path.Combine(AppContext.BaseDirectory, BootstrapService.DefaultCodecSchemaFileName);
            var palettePath            = Path.Combine(AppContext.BaseDirectory, BootstrapService.DefaultPalettePath);
            var pluginPath             = Path.Combine(AppContext.BaseDirectory, BootstrapService.DefaultPluginPath);
            var resourceSchemaFileName = Path.Combine(AppContext.BaseDirectory, BootstrapService.DefaultResourceSchemaFileName);

            var settings       = bootstrapper.ReadConfiguration(settingsFileName);
            var codecService   = bootstrapper.CreateCodecService(codecPath, codecSchemaFileName);
            var paletteService = bootstrapper.CreatePaletteService(palettePath, settings);
            //var pluginService = bootstrapper.CreatePluginService(pluginPath, codecService);

            var defaultResources  = paletteService.GlobalPalettes;
            var serializerFactory = new XmlProjectSerializerFactory(resourceSchemaFileName,
                                                                    codecService.CodecFactory, paletteService.ColorFactory, defaultResources);
            ProjectService = bootstrapper.CreateProjectService(serializerFactory, paletteService.ColorFactory);

            return(true);
        }
        catch (Exception ex)
        {
            Log.Fatal(ex, $"TileShopCLI environment failed to load:\n{ex.StackTrace}\n");
            return(false);
        }
    }
Пример #2
0
    private void ConfigureImageMagitek(ContainerBuilder builder)
    {
        var bootstrapper   = new BootstrapService(_loggerFactory.CreateLogger <BootstrapService>());
        var settings       = bootstrapper.ReadConfiguration(BootstrapService.DefaultConfigurationFileName);
        var paletteService = bootstrapper.CreatePaletteService(BootstrapService.DefaultPalettePath, settings);
        var codecService   = bootstrapper.CreateCodecService(BootstrapService.DefaultCodecPath, BootstrapService.DefaultCodecSchemaFileName);
        var pluginService  = bootstrapper.CreatePluginService(BootstrapService.DefaultPluginPath, codecService);
        var layoutService  = bootstrapper.CreateTileLayoutService(BootstrapService.DefaultLayoutsPath);

        var defaultResources  = paletteService.GlobalPalettes;
        var serializerFactory = new XmlProjectSerializerFactory(BootstrapService.DefaultResourceSchemaFileName,
                                                                codecService.CodecFactory, paletteService.ColorFactory, defaultResources);
        var projectService = bootstrapper.CreateProjectService(serializerFactory, paletteService.ColorFactory);

        builder.RegisterInstance(settings);
        builder.RegisterInstance(paletteService);
        builder.RegisterInstance(codecService);
        builder.RegisterInstance(pluginService);
        builder.RegisterInstance(layoutService);
        builder.RegisterInstance(projectService);
    }