Example #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(cfg =>
            {
                WebApiConfig.Register(cfg);
            });

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var windsor = new WindsorContainer();

            windsor.Register(Component.For <IServiceProvider>().Instance(new ServiceProviderWrapper(windsor)));

            var jasonConfig = new DefaultJasonServerConfiguration(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"))
            {
                Container  = new WindsorJasonContainerProxy(windsor),
                TypeFilter = t => !t.Is <MissingHandler>()
            };

            jasonConfig.AddEndpoint(new Jason.WebAPI.JasonWebAPIEndpoint(GlobalConfiguration.Configuration)
            {
                //TypeNameHandling = TypeNameHandling.Objects,
                IsCommandConvention = t =>
                {
                    return(t.Namespace != null && t.Namespace == "SampleTasks");
                }
            });

            jasonConfig.AddEndpoint(new Jason.Client.JasonInProcessEndpoint());
            jasonConfig.UsingAsFallbackCommandHandler <MissingHandler>();
            jasonConfig.Initialize();

            GlobalConfiguration.Configuration.DependencyResolver = new DelegateDependencyResolver()
            {
                OnGetService = t =>
                {
                    if (windsor.Kernel.HasComponent(t))
                    {
                        return(windsor.Resolve(t));
                    }

                    return(null);
                },
                OnGetServices = t =>
                {
                    if (windsor.Kernel.HasComponent(t))
                    {
                        return(windsor.ResolveAll(t).OfType <Object>());
                    }

                    return(new List <Object>());
                }
            };
        }
Example #2
0
        void JasonConfig(HttpConfiguration config)
        {
            var jasonConfig = new DefaultJasonServerConfiguration(this.probeDirectory)
            {
                Container = new WindsorJasonContainerProxy(this.windsor),
                //TypeFilter = t => !t.Is<ShopperFallbackCommandHandler>()
            };

            var endpoint = new JasonWebAPIEndpoint(config)
            {
                IsCommandConvention = t => t.Namespace != null && t.Namespace.EndsWith(".Messages.Commands"),
                OnJasonRequest      = e =>
                {
                    if (!e.IsCommandInterceptor && !e.IsJasonExecute)
                    {
                        return;
                    }

                    if (!e.RequestContainsCorrelationId)
                    {
                        e.CorrelationId = Guid.NewGuid().ToString();
                        e.AppendCorrelationIdToResponse = true;
                    }

                    var operationContextManager = this.windsor.Resolve <IOperationContextManager>();
                    var context = operationContextManager.GetCurrent();
                    context.ForOperation(e.CorrelationId);
                }
            };

            this.jasonWebAPIEndpointCustomizations.ForEach(c => c(endpoint));

            jasonConfig.AddEndpoint(endpoint)
            .UsingAsFallbackCommandValidator <ObjectDataAnnotationValidator>();

            this.jasonServerConfigurationCustomizations.ForEach(c => c(jasonConfig));

            jasonConfig.Initialize();
        }
Example #3
0
        protected void Application_Start( object sender, EventArgs e )
        {
            Container = this;

            this.windsor = new WindsorContainer();
            windsor.Register( Component.For<IServiceProvider>().Instance( Global.Container ) );

            var jasonConfig = new DefaultJasonServerConfiguration( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "bin" ) )
            {
                Container = new WindsorJasonContainerProxy( this.windsor )
            };

            jasonConfig.AddEndpoint( new Jason.Server.JasonWcfEndpoint()
            {
                CommandsSelector = t =>
                {
                    return t.IsAttributeDefined<DataContractAttribute>()
                        && ( t.Name.EndsWith( "Command" ) || t.Name.EndsWith( "CommandResponse" ) );
                }
            } );

            jasonConfig.Initialize();
        }
Example #4
0
        protected void Application_Start(object sender, EventArgs e)
        {
            Container = this;

            this.windsor = new WindsorContainer();
            windsor.Register(Component.For <IServiceProvider>().Instance(Global.Container));

            var jasonConfig = new DefaultJasonServerConfiguration(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"))
            {
                Container = new WindsorJasonContainerProxy(this.windsor)
            };

            jasonConfig.AddEndpoint(new Jason.Server.JasonWcfEndpoint()
            {
                CommandsSelector = t =>
                {
                    return(t.IsAttributeDefined <DataContractAttribute>() &&
                           (t.Name.EndsWith("Command") || t.Name.EndsWith("CommandResponse")));
                }
            });

            jasonConfig.Initialize();
        }
Example #5
0
		void JasonConfig( HttpConfiguration config )
		{
			var jasonConfig = new DefaultJasonServerConfiguration( this.probeDirectory )
			{
				Container = new WindsorJasonContainerProxy( this.windsor ),
				//TypeFilter = t => !t.Is<ShopperFallbackCommandHandler>()
			};

			var endpoint = new JasonWebAPIEndpoint( config )
			{
				IsCommandConvention = t => t.Namespace != null && t.Namespace.EndsWith( ".Messages.Commands" ),
				OnJasonRequest = e =>
				{
					if( !e.IsCommandInterceptor && !e.IsJasonExecute )
					{
						return;
					}

					if( !e.RequestContainsCorrelationId )
					{
						e.CorrelationId = Guid.NewGuid().ToString();
						e.AppendCorrelationIdToResponse = true;
					}

					var operationContextManager = this.windsor.Resolve<IOperationContextManager>();
					var context = operationContextManager.GetCurrent();
					context.ForOperation( e.CorrelationId );
				}
			};

			this.jasonWebAPIEndpointCustomizations.ForEach( c => c( endpoint ) );

			jasonConfig.AddEndpoint( endpoint )
				.UsingAsFallbackCommandValidator<ObjectDataAnnotationValidator>();

			this.jasonServerConfigurationCustomizations.ForEach( c => c( jasonConfig ) );

			jasonConfig.Initialize();
		}