public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {



            builder.RegisterType<MovieService>().As<IMovieService>().InstancePerLifetimeScope();


            builder.RegisterControllers(typeFinder.GetAssemblies().ToArray());

            string conn = "Data Source=.;Initial Catalog=Axxe;Trusted_Connection=False;";

            builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();

            var dataSettingsManager = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings();
            builder.Register(c => dataSettingsManager.LoadSettings()).As<DataSettings>();
            builder.Register<IDbContext>(c => new NopObjectContext(conn)).InstancePerLifetimeScope();

            builder.Register(x => new EfDataProviderManager(x.Resolve<DataSettings>())).As<BaseDataProviderManager>().InstancePerDependency();
            var efDataProviderManager = new EfDataProviderManager(dataSettingsManager.LoadSettings());
            var dataProvider = efDataProviderManager.LoadDataProvider();
            dataProvider.InitConnectionFactory();

        }
Example #2
0
        /// <summary>
        /// Creates a configuration section handler.
        /// </summary>
        /// <param name="parent">Parent object.</param>
        /// <param name="configContext">Configuration context object.</param>
        /// <param name="section">Section XML node.</param>
        /// <returns>The created section handler object.</returns>
        public object Create(object parent, object configContext, XmlNode section)
        {
            var config = new NopConfig();

            var startupNode = section.SelectSingleNode("Startup");
            if (startupNode != null && startupNode.Attributes != null)
            {
                var attribute = startupNode.Attributes["IgnoreStartupTasks"];
                if (attribute != null)
                    config.IgnoreStartupTasks = Convert.ToBoolean(attribute.Value);
            }

            var redisCachingNode = section.SelectSingleNode("RedisCaching");
            if (redisCachingNode != null && redisCachingNode.Attributes != null)
            {
                var enabledAttribute = redisCachingNode.Attributes["Enabled"];
                if (enabledAttribute != null)
                    config.RedisCachingEnabled = Convert.ToBoolean(enabledAttribute.Value);

                var connectionStringAttribute = redisCachingNode.Attributes["ConnectionString"];
                if (connectionStringAttribute != null)
                    config.RedisCachingConnectionString = connectionStringAttribute.Value;
            }

            var userAgentStringsNode = section.SelectSingleNode("UserAgentStrings");
            if (userAgentStringsNode != null && userAgentStringsNode.Attributes != null)
            {
                var attribute = userAgentStringsNode.Attributes["databasePath"];
                if (attribute != null)
                    config.UserAgentStringsPath = attribute.Value;
            }

            var supportPreviousNopcommerceVersionsNode = section.SelectSingleNode("SupportPreviousNopcommerceVersions");
            if (supportPreviousNopcommerceVersionsNode != null && supportPreviousNopcommerceVersionsNode.Attributes != null)
            {
                var attribute = supportPreviousNopcommerceVersionsNode.Attributes["Enabled"];
                if (attribute != null)
                    config.SupportPreviousNopcommerceVersions = Convert.ToBoolean(attribute.Value);
            }

            var webFarmsNode = section.SelectSingleNode("WebFarms");
            if (webFarmsNode != null && webFarmsNode.Attributes != null)
            {
                var multipleInstancesEnabledAttribute = webFarmsNode.Attributes["MultipleInstancesEnabled"];
                if (multipleInstancesEnabledAttribute != null)
                    config.MultipleInstancesEnabled = Convert.ToBoolean(multipleInstancesEnabledAttribute.Value);

                var runOnAzureWebsitesAttribute = webFarmsNode.Attributes["RunOnAzureWebsites"];
                if (runOnAzureWebsitesAttribute != null)
                    config.RunOnAzureWebsites = Convert.ToBoolean(runOnAzureWebsitesAttribute.Value);
            }

            var azureBlobStorageNode = section.SelectSingleNode("AzureBlobStorage");
            if (azureBlobStorageNode != null && azureBlobStorageNode.Attributes != null)
            {
                var azureConnectionStringAttribute = azureBlobStorageNode.Attributes["ConnectionString"];
                if (azureConnectionStringAttribute != null)
                    config.AzureBlobStorageConnectionString = azureConnectionStringAttribute.Value;

                var azureContainerNameAttribute = azureBlobStorageNode.Attributes["ContainerName"];
                if (azureContainerNameAttribute != null)
                    config.AzureBlobStorageContainerName = azureContainerNameAttribute.Value;

                var azureEndPointAttribute = azureBlobStorageNode.Attributes["EndPoint"];
                if (azureEndPointAttribute != null)
                    config.AzureBlobStorageEndPoint = azureEndPointAttribute.Value;

            }

            var installationNode = section.SelectSingleNode("Installation");
            if (installationNode != null && installationNode.Attributes != null)
            {
                var disableSampleDataDuringInstallationAttribute = installationNode.Attributes["DisableSampleDataDuringInstallation"];
                if (disableSampleDataDuringInstallationAttribute != null)
                    config.DisableSampleDataDuringInstallation = Convert.ToBoolean(disableSampleDataDuringInstallationAttribute.Value);

                var useFastInstallationServiceAttribute = installationNode.Attributes["UseFastInstallationService"];
                if (useFastInstallationServiceAttribute != null)
                    config.UseFastInstallationService = Convert.ToBoolean(useFastInstallationServiceAttribute.Value);

                var pluginsIgnoredDuringInstallationAttribute = installationNode.Attributes["PluginsIgnoredDuringInstallation"];
                if (pluginsIgnoredDuringInstallationAttribute != null)
                    config.PluginsIgnoredDuringInstallation = pluginsIgnoredDuringInstallationAttribute.Value;
            }

            return config;
        }