public FubuDiagnosticsRegistry() { this.IncludeDiagnostics(true); this.ApplyEndpointConventions(typeof(DiagnosticsEndpointMarker)); this.Spark(spark => spark .Policies .Add(new DiagnosticsEndpointSparkPolicy(typeof(DiagnosticsEndpointMarker))) .Add <PartialActionSparkPolicy>() .Add <NotificationActionSparkPolicy>()); Services(x => { // Typically you'd do this in your container but we're keeping this IoC-agnostic x.SetServiceIfNone <IHttpRequest, HttpRequest>(); x.SetServiceIfNone <IHttpConstraintResolver, HttpConstraintResolver>(); x.SetServiceIfNone <IRequestCacheModelBuilder, RequestCacheModelBuilder>(); x.SetServiceIfNone <INavigationMenuBuilder, NavigationMenuBuilder>(); x.SetServiceIfNone <IAuthorizationDescriptor, AuthorizationDescriptor>(); x.SetServiceIfNone(typeof(IGridService <,>), typeof(GridService <,>)); x.SetServiceIfNone(typeof(IGridRowBuilder <,>), typeof(GridRowBuilder <,>)); x.SetServiceIfNone(typeof(IGridColumnBuilder <>), typeof(GridColumnBuilder <>)); x.SetServiceIfNone <IGridRowProvider <BehaviorGraph, BehaviorChain>, BehaviorGraphRowProvider>(); x.SetServiceIfNone <IGridRowProvider <RequestCacheModel, RecordedRequestModel>, RequestCacheRowProvider>(); x.Scan(scan => { scan .Applies .ToThisAssembly() .ToAllPackageAssemblies(); scan .AddAllTypesOf <INavigationItemAction>() .AddAllTypesOf <INotificationPolicy>(); scan .ConnectImplementationsToTypesClosing(typeof(IPartialDecorator <>)) .ConnectImplementationsToTypesClosing(typeof(IGridColumnBuilder <>)) .ConnectImplementationsToTypesClosing(typeof(IGridColumn <>)) .ConnectImplementationsToTypesClosing(typeof(IGridFilter <>)); }); }); Policies .ConditionallyWrapBehaviorChainsWith <UnknownObjectBehavior>( call => call.InputType() == typeof(ChainRequest)); Actions .FindWith <PartialActionSource>() .FindWith <NotificationActionSource>(); Output .ToJson .WhenCallMatches(call => call.OutputType().Name.StartsWith("Json")); }
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>(); }