/// <summary> /// Initializes the module. /// </summary> public static void Initialize() { lock (initLock) { if (isInitialized) { return; } var builder = new ContainerBuilder(); builder.RegisterAssemblyModules(typeof(AutofacModule).GetTypeInfo().Assembly); // AutoMapper var amConf = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperProfile()); }); builder.Register((ctx, parms) => amConf.CreateMapper()); // Autofac Container container = builder.Build(); isInitialized = true; // Load coin templates var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location); var defaultDefinitions = Path.Combine(basePath, "coins.json"); var coinDefs = new[] { defaultDefinitions }; coinTemplates = CoinTemplateLoader.Load(container, coinDefs); } }
private static Dictionary <string, CoinTemplate> LoadCoinTemplates() { var basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var defaultTemplates = Path.Combine(basePath, "coins.json"); // make sure default templates are loaded first clusterConfig.CoinTemplates = new[] { defaultTemplates } .Concat(clusterConfig.CoinTemplates != null ? clusterConfig.CoinTemplates.Where(x => x != defaultTemplates) : new string[0]) .ToArray(); return(CoinTemplateLoader.Load(container, clusterConfig.CoinTemplates)); }