Example #1
0
        public void Configuration(IAppBuilder app)
        {
            GlobalConfiguration.Configure(x => WebApiConfig.Register(x, a => { }));
            RouteConfig.RegisterRoutes(RouteTable.Routes, x => { });


            StructureMapAspNet.Configure(Assembly.GetExecutingAssembly()).ForWebApi();
            var config = new NirvanaCommandProcessorEndpointConfiguration();

            NirvanaSetup.Configure()
            .UsingControllerName(config.ControllerAssemblyName, config.RootNamespace)
            .WithAssembliesFromFolder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"))
            .SetAdditionalAssemblyNameReferences(config.AssemblyNameReferences)
            .SetRootTypeAssembly(typeof(Services.Shared.InfrastructureRoot).Assembly)
            .SetAttributeMatchingFunction(config.AttributeMatchingFunction)
            .SetDependencyResolver(config.GetService, config.GetAllServices)
            .ForCommands(MediationStrategy.InProcess, MediationStrategy.ForwardToQueue, MediationStrategy.None)
            .ForInternalEvents(MediationStrategy.InProcess, MediationStrategy.ForwardToQueue, MediationStrategy.None)
            .ForUiNotifications(MediationStrategy.ForwardToWeb, MediationStrategy.ForwardToWeb, MediationStrategy.None)
            .ForQueries(MediationStrategy.InProcess, MediationStrategy.InProcess)
            .BuildConfiguration()
            ;

            app.UseCors(CorsOptions.AllowAll);


            var thirdPartyReferences = new Assembly[0];

            new CqrsApiGenerator().LoadAssembly(thirdPartyReferences);

            var dynamicApiSelector = new DynamicApiSelector(GlobalConfiguration.Configuration, config.InlineControllerTypes);

            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerSelector), dynamicApiSelector);
        }
Example #2
0
        public void Configuration(IAppBuilder app)
        {
            StructureMapAspNet.Configure(Assembly.GetExecutingAssembly()).ForWebApi();
            var config = new NirvanaCommandProcessorEndpointConfiguration();

            NirvanaSetup.Configure()
            .UsingControllerName(config.ControllerAssemblyName, config.RootNamespace)
            .WithAssembliesFromFolder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"))
            .SetAdditionalAssemblyNameReferences(config.AssemblyNameReferences)
            .SetRootTypeAssembly(typeof(Services.Shared.InfrastructureRoot).Assembly)
            .SetAttributeMatchingFunction(config.AttributeMatchingFunction)
            .SetDependencyResolver(config.GetService, config.GetAllServices)
            .ForUiNotifications(MediationStrategy.InProcess, MediationStrategy.ForwardToQueue, MediationStrategy.None)
            .BuildConfiguration()
            ;

            app.UseCors(CorsOptions.AllowAll);


            var connectionConfiguration = new HubConfiguration
            {
                EnableDetailedErrors = true,
            };

            app.MapSignalR("/signalr", connectionConfiguration);
            GlobalConfiguration.Configure(x => WebApiConfig.Register(x, a => { }));
            RouteConfig.RegisterRoutes(RouteTable.Routes, x => { });

//            Failed to compile code generation project :
//CS0432: Alias 'Infrastructure' not found
//CS0103: The name 'Constants' does not exist in the current context
//CS0103 : The name 'HttpStatusCode' does not exist in the current context
//CS0012 : The type 'HttpStatusCode' is defined in an assembly that is not referenced.You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


            var allAssemblies = new List <Assembly>();

            foreach (var file in Directory.GetFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"), "*.dll"))
            {
                allAssemblies.Add(Assembly.LoadFile(file));
            }


            new CqrsApiGenerator().LoadAssembly(allAssemblies.ToArray());

            var httpConfig = new HttpConfiguration();

            httpConfig.MapHttpAttributeRoutes();


            httpConfig.Routes.MapHttpRoute(
                "DefaultApi",
                "api/{controller}/{id}",
                new { id = RouteParameter.Optional }
                );

            var dynamicApiSelector = new DynamicApiSelector(GlobalConfiguration.Configuration, new Type[0]);

            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerSelector), dynamicApiSelector);
        }
Example #3
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(x => WebApiConfig.Register(x, a => { }));
            RouteConfig.RegisterRoutes(RouteTable.Routes, x => { });


            var config = new TestNirvanaConfig();

            NirvanaSetup.Configure()
            .UsingControllerName(config.ControllerAssemblyName, "TechFu.Nirvana.WebApi.Sample")
            .WithAssembliesFromFolder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"))
            .SetAdditionalAssemblyNameReferences(config.AssemblyNameReferences)
            .SetRootTypeAssembly(GetType().Assembly)
            .SetAttributeMatchingFunction(config.AttributeMatchingFunction)
            .SetDependencyResolver(config.GetService, config.GetAllServices)
            .ForCommands(MediationStrategy.InProcess, MediationStrategy.InProcess, MediationStrategy.InProcess)
            .ForInternalEvents(MediationStrategy.InProcess, MediationStrategy.InProcess, MediationStrategy.InProcess)
            .ForUiNotifications(MediationStrategy.InProcess, MediationStrategy.InProcess,
                                MediationStrategy.InProcess)
            .ForQueries(MediationStrategy.InProcess, MediationStrategy.InProcess)
            .BuildConfiguration()
            ;

            var thirdPartyReferences = new Assembly[0];

            new CqrsApiGenerator().LoadAssembly(thirdPartyReferences);


            var dynamicApiSelector = new DynamicApiSelector(GlobalConfiguration.Configuration,
                                                            config.InlineControllerTypes);

            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerSelector), dynamicApiSelector);
        }
Example #4
0
        public QueueService()
        {
            StructureMapAspNet.Configure(Assembly.GetExecutingAssembly());
            var config = new CommandProcessorNirvanaConfig();

            NirvanaSetup.Configure()
            .SetAdditionalAssemblyNameReferences(config.AssemblyNameReferences)
            .SetRootTypeAssembly(typeof(Services.Shared.InfrastructureRoot).Assembly)
            .SetAttributeMatchingFunction(config.AttributeMatchingFunction)
            .SetDependencyResolver(config.GetService, config.GetAllServices)
            .ForCommands(MediationStrategy.ForwardToWeb, MediationStrategy.ForwardToQueue, MediationStrategy.ForwardToQueue)
            .ForInternalEvents(MediationStrategy.ForwardToWeb, MediationStrategy.ForwardToQueue, MediationStrategy.ForwardToQueue)
            .ForUiNotifications(MediationStrategy.ForwardToWeb, MediationStrategy.ForwardToQueue, MediationStrategy.ForwardToQueue)
            .BuildConfiguration()
            ;

            _queueController = InternalDependencyResolver.GetInstance <IQueueController>();
        }