예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        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));
        }