Exemple #1
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>();
        }
        private RequestProfile GetRequestProfileFor(Type tRequest)
        {
            if (!typeof(ICrudlessRequest).IsAssignableFrom(tRequest))
            {
                return(GetUniversalRequestProfileFor(tRequest));
            }

            var tProfile = typeof(IBulkRequest).IsAssignableFrom(tRequest)
                ? typeof(DefaultBulkRequestProfile <>).MakeGenericType(tRequest)
                : typeof(DefaultRequestProfile <>).MakeGenericType(tRequest);

            var profile = (RequestProfile)_container.ProvideInstance(tProfile);

            profile.Inherit(tRequest
                            .BuildTypeHierarchyDown()
                            .SelectMany(FindRequestProfilesFor)
                            .Select(x => (RequestProfile)_container.ProvideInstance(x)));

            return(profile);
        }
Exemple #3
0
        public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options)
        {
            container.RegisterInitializer <ICrudlessRequestHandler>(handler =>
            {
                if (handler.ErrorDispatcher.Handler == null)
                {
                    handler.ErrorDispatcher.Handler = container.ProvideInstance <IErrorHandler>();
                }
            });

            container.RegisterSingleton <IErrorHandler, ErrorHandler>();
        }