public IntegrationJsonBindingRegistry(Recorder recorder, ISystemTime time)
            {
                Services.For <Recorder>().Use(recorder);

                Actions.IncludeType <IntegratedJsonBindingEndpoint>();
                Models.BindPropertiesWith <CurrentTimePropertyBinder>();

                Services.ReplaceService(time);
            }
        private void setupDefaultConventionsAndPolicies()
        {
            _bagRunner.Apply(_viewAttacherConvention);

            // Add Behaviors First
            ApplyConvention(_behaviorAggregator);

            // Needs to go before routing conventions
            ApplyConvention <PartialOnlyConvention>();

            addConvention(graph => _routeResolver.ApplyToAll(graph));


            _systemPolicies.Add(new AttachAuthorizationPolicy());

            ApplyConvention <DictionaryOutputConvention>();

            Output.ToHtml.WhenCallMatches(x => x.Method.HasAttribute <HtmlEndpointAttribute>());
            Output.ToHtml
            .WhenCallMatches(x => x.Method.Name.ToLower().EndsWith("html") && x.OutputType() == typeof(string));

            Output.ToJson.WhenTheOutputModelIs <JsonMessage>();


            Output.To <RenderHtmlDocumentNode>().WhenTheOutputModelIs <HtmlDocument>();
            Output.To <RenderHtmlTagNode>().WhenTheOutputModelIs <HtmlTag>();

            Output.ToBehavior <RenderStatusCodeBehavior>().WhenTheOutputModelIs <HttpStatusCode>();

            Policies.Add <AjaxContinuationPolicy>();
            Policies.Add <ContinuationHandlerConvention>();
            Policies.Add <AsyncContinueWithHandlerConvention>();
            Policies.Add <HeaderWritingPolicy>();
            Policies.Add <ResourcePathRoutePolicy>();

            _systemPolicies.Add(new StringOutputPolicy());
            _systemPolicies.Add(new MissingRouteInputPolicy());

            Models.BindPropertiesWith <CurrentRequestFullUrlPropertyBinder>();
            Models.BindPropertiesWith <CurrentRequestRelativeUrlPropertyBinder>();

            _conventions.Add(_bagRunner);
            Policies.Add <JsonMessageInputConvention>();
            _systemPolicies.Add(_connegAttachmentPolicy);

            ApplyConvention <ModifyChainAttributeConvention>();
        }
        public CoreRegistry()
        {
            Applies.ToThisAssembly();
            //IncludeDiagnostics(true);

            Actions.IncludeTypesNamed(x => x.EndsWith("Handler"));

            Routes
            .ConstrainToHttpMethod(x => x.Method.Name.EndsWith("Query"), "GET")
            .ConstrainToHttpMethod(x => x.Method.Name.EndsWith("Command"), "POST");

            Routes
            .IgnoreNamespaceText(typeof(CoreRegistry).Namespace)
            .IgnoreNamespaceText("Handlers")
            .IgnoreMethodsNamed("Query")
            .IgnoreMethodsNamed("Command")
            .IgnoreClassSuffix("Handler");

            Routes.HomeIs <HomeHandler>(x => x.Query(new HomeQueryModel()));
            Views.TryToAttachWithDefaultConventions()
            .RegisterActionLessViews(t => t.ViewModelType == typeof(Notification));

            this.UseSpark();

            Policies.ConditionallyWrapBehaviorChainsWith <HandlerAssetConvention>(x => x.HandlerType.Namespace.Contains("Products"));

            Policies.Add(new ProductNotFoundPolicy <EditHandler>(h => h.Query(null)));
            Policies.Add(new ProductNotFoundPolicy <DeleteHandler>(h => h.Query(null)));

            Output.ToJson.WhenCallMatches(x => x.Method.Name.Equals("Data"));

            Import <BasicLocalizationSupport>(x =>
            {
                x.LocalizationStorageIs <InMemoryLocalizationStorage>();
                x.LoadLocalizationWith <LocalizationActivator>();
                x.DefaultCulture = Thread.CurrentThread.CurrentUICulture;
            });


            var validationRulesHtmlConventionActivator = ObjectDef.ForType <ValidationHtmlConvention>();
            var validationRulesHtmlConvention          = new HtmlConventionRegistry();

            validationRulesHtmlConventionActivator.DependencyByValue(validationRulesHtmlConvention);

            Services(cfg =>
            {
                cfg.SetServiceIfNone <IProductService, InMemoryProductService>();
                cfg.SetServiceIfNone(Mapper.Engine);
                cfg.SetServiceIfNone(Mapper.Configuration);
                cfg.SetServiceIfNone <ILocaleCacheFactory, LocaleCacheFactory>();
                cfg.SetServiceIfNone <IValidationDescriptorProvider>(new ValidationDescriptorProvider());
                cfg.AddService <IHtmlValidationConvention, LocalizedNameConvention>();
                cfg.AddService <IHtmlValidationConvention, RequiredHtmlValidationConvention>();
                cfg.AddService <IHtmlValidationConvention, GreaterOrEqualToZeroHtmlValidationConvention>();
                cfg.AddService <IHtmlValidationConvention, MaximumLengthHtmlValidationConvention>();
                cfg.AddService <IFieldValidationSource, AddProductModelValidationSource>();
                cfg.AddService <IActivator, AutoMapperActivator>();
                cfg.AddService <IActivator, ValidationDescriptorProviderFiller>();
                cfg.AddService(typeof(IActivator), validationRulesHtmlConventionActivator);
            });

            HtmlConvention(htmlConventions);
            HtmlConvention(validationRulesHtmlConvention);

            this.Validation(validation =>
            {
                validation.Actions.Include(call => call.HasInput && call.Method.Name.Equals("Command"));
                validation.Failures
                .IfModelIs <EditProductCommandModel>().TransferBy <ValidationDescriptor>();
            });

            Models.BindPropertiesWith <OriginalModelBinder>();
        }