Ejemplo n.º 1
0
        public void Run(Container container, Assembly[] assemblies, CrudOptions options)
        {
            BulkConfigurationManager.Clear();

            container.Options.AllowOverridingRegistrations = true;

            var bulkAgent = new BulkDataAgent();

            if ((_extensions & BulkExtensions.Create) == BulkExtensions.Create)
            {
                container.RegisterInstance <IBulkCreateDataAgent>(bulkAgent);
            }

            if ((_extensions & BulkExtensions.Update) == BulkExtensions.Update)
            {
                container.RegisterInstance <IBulkUpdateDataAgent>(bulkAgent);
            }

            if ((_extensions & BulkExtensions.Delete) == BulkExtensions.Delete)
            {
                container.RegisterInstance <IBulkDeleteDataAgent>(bulkAgent);
            }

            container.Options.AllowOverridingRegistrations = false;

            EntityFrameworkManager.ContextFactory = context => container.GetInstance <DbContext>();
        }
Ejemplo n.º 2
0
        public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options)
        {
            BulkConfigurationManager.Clear();

            using (container.AllowOverrides())
            {
                var bulkAgent = new BulkDataAgent();

                if ((_extensions & BulkExtensions.Create) == BulkExtensions.Create)
                {
                    container.RegisterInstance <IBulkCreateDataAgent>(bulkAgent);
                }

                if ((_extensions & BulkExtensions.Update) == BulkExtensions.Update)
                {
                    container.RegisterInstance <IBulkUpdateDataAgent>(bulkAgent);
                }

                if ((_extensions & BulkExtensions.Delete) == BulkExtensions.Delete)
                {
                    container.RegisterInstance <IBulkDeleteDataAgent>(bulkAgent);
                }
            }

            EntityFrameworkManager.ContextFactory =
                context => container.ProvideInstance <DbContext>();
        }