public void select_interceptors() { var activator1 = new ActivatorInterceptor<ITarget>(x => x.Activate()); var activator2 = new ActivatorInterceptor<Target>(x => x.UseSession(null)); var activator3 = new ActivatorInterceptor<Target>(x => x.ThrowUp()); var activator4 = new ActivatorInterceptor<ITarget>(x => x.Debug()); var activator5 = new ActivatorInterceptor<IGateway>(x => x.DoSomething()); var policies = new Policies(); policies.Add(activator1.ToPolicy()); policies.Add(activator2.ToPolicy()); policies.Add(activator3.ToPolicy()); policies.Add(activator4.ToPolicy()); policies.Add(activator5.ToPolicy()); var instance1 = new SmartInstance<Target>(); policies.Apply(typeof(ITarget), instance1); instance1.Interceptors .ShouldHaveTheSameElementsAs(activator1, activator2, activator3, activator4); var instance2 = new SmartInstance<ATarget>(); policies.Apply(typeof(ITarget), instance2); instance2.Interceptors .ShouldHaveTheSameElementsAs(activator1, activator4); var instance3 = new SmartInstance<StubbedGateway>(); policies.Apply(typeof(ITarget), instance3); instance3.Interceptors .ShouldHaveTheSameElementsAs(activator5); }
public JasperServiceRegistry(JasperRegistry parent) { For <IMetrics>().Use <NulloMetrics>(); For <IHostedService>().Use <MetricsCollector>(); Policies.Add(new HandlerAndRoutePolicy(parent.HttpRoutes.Routes, parent.Messaging.Graph)); this.AddLogging(); For <IMessageLogger>().Use <MessageLogger>().Singleton(); For <ITransportLogger>().Use <TransportLogger>().Singleton(); For <IMessageSerializer>().Use <EnvelopeReaderWriter>(); For <IMessageDeserializer>().Use <EnvelopeReaderWriter>(); this.AddSingleton(parent.CodeGeneration); For <IHostedService>().Use <BackPressureAgent>(); For <IHostedService>().Use <DurabilityAgent>(); For <IHostedService>().DecorateAllWith <LoggingHostedServiceDecorator>(); conneg(parent); messaging(parent); aspnetcore(parent); }
private void setupDefaultConventionsAndPolicies() { // Add Behaviors First addConvention(graph => _behaviorMatcher.BuildBehaviors(_types, graph)); addConvention(graph => _actionSourceMatcher.BuildBehaviors(_types, graph)); addConvention(graph => _routeResolver.ApplyToAll(graph)); _conventions.Add(new WrapWithAttributeConvention()); _systemPolicies.Add(new AttachAuthorizationPolicy()); Output.ToHtml.WhenCallMatches(x => x.Method.HasAttribute <HtmlEndpointAttribute>()); Output.ToJson.WhenCallMatches(x => x.Method.HasAttribute <JsonEndpointAttribute>()); Output.ToJson.WhenTheOutputModelIs <JsonMessage>(); Output.To <RenderHtmlDocumentNode>().WhenTheOutputModelIs <HtmlDocument>(); Output.To <RenderHtmlTagNode>().WhenTheOutputModelIs <HtmlTag>(); Output.ToBehavior <RenderStatusCodeBehavior>().WhenTheOutputModelIs <HttpStatusCode>(); Policies.Add <WebFormsEndpointPolicy>(); Policies.Add <ContinuationHandlerConvention>(); _systemPolicies.Add(new StringOutputPolicy()); _conventions.Add(_viewAttacher); Policies.Add <JsonMessageInputConvention>(); Policies.Add <UrlRegistryCategoryConvention>(); Policies.Add <UrlForNewConvention>(); ApplyConvention <AuthorizationAttributeConvention>(); }
public FubuMusicStoreRegistry() { IncludeDiagnostics(true); Actions.IncludeTypesNamed(x => x.EndsWith("Action")); Routes .IgnoreNamespaceText("FubuMusicStore.Actions") .IgnoreControllerNamesEntirely() .IgnoreClassSuffix("Action") .IgnoreMethodsNamed("Execute") .IgnoreMethodSuffix("Post") .IgnoreMethodSuffix("Get") .IgnoreMethodSuffix("Delete") .IgnoreMethodSuffix("Put") .ConstrainToHttpMethod(action => action.Method.Name.Equals("Post"), "POST") .ConstrainToHttpMethod(action => action.Method.Name.Equals("Put"), "PUT") .ConstrainToHttpMethod(action => action.Method.Name.Equals("Get"), "GET") .ConstrainToHttpMethod(action => action.Method.Name.Equals("Delete"), "DELETE"); //.ForInputTypesOf<IRequestById>(x => x.RouteInputFor(request => request.Id)); Routes.HomeIs <HomeAction>(x => x.Get(null)); Policies.Add <CrudEndpointsConvention>() .WrapBehaviorChainsWith <load_the_current_principal>().Ordering(x => x.MustBeBeforeAuthorization()); Views.TryToAttachWithDefaultConventions(); this.ApplySmartGridConventions(x => { x.ToThisAssembly(); }); }
public HelloSparkRegistry() { IncludeDiagnostics(true); Applies .ToThisAssembly() .ToAllPackageAssemblies(); Actions .IncludeClassesSuffixedWithController(); Routes .HomeIs <AirController>(c => c.TakeABreath()) .IgnoreControllerNamespaceEntirely() .IgnoreMethodSuffix("Command") .IgnoreMethodSuffix("Query") .ConstrainToHttpMethod(action => action.Method.Name.EndsWith("Command"), "POST") .ConstrainToHttpMethod(action => action.Method.Name.StartsWith("Query"), "GET"); Policies.Add <AntiForgeryPolicy>(); this.UseSpark(); Views.TryToAttachWithDefaultConventions(); HtmlConvention <SampleHtmlConventions>(); Services(s => s.ReplaceService <IUrlTemplatePattern, JQueryUrlTemplate>()); }
public SwaggerPackageRegistry() { Policies.Add <SwaggerConvention>(); Services(s => s.AddService <IActionGrouper, APIRouteGrouper>()); Services(s => s.AddService <IActionFinder, APIRouteFinder>()); }
public HelloSparkRegistry() { IncludeDiagnostics(true); Applies .ToThisAssembly(); Actions .IncludeClassesSuffixedWithController(); ApplyHandlerConventions(); Routes .HomeIs <AirRequest>() .IgnoreControllerNamespaceEntirely() .IgnoreMethodSuffix("Command") .IgnoreMethodSuffix("Query") .ConstrainToHttpMethod(action => action.Method.Name.EndsWith("Command"), "POST") .ConstrainToHttpMethod(action => action.Method.Name.StartsWith("Query"), "GET"); Policies.Add <AntiForgeryPolicy>(); this.UseSpark(); Views .TryToAttachWithDefaultConventions() .TryToAttachViewsInPackages(); HtmlConvention <SampleHtmlConventions>(); Services(s => s.ReplaceService <IUrlTemplatePattern, JQueryUrlTemplate>()); this.Extensions() .For <AirViewModel>("extension-placeholder", x => "<p>Rendered from content extension.</p>"); }
public HelloWorldFubuRegistry() { IncludeDiagnostics(true); Actions .IncludeClassesSuffixedWithController(); Routes .HomeIs <HomeInputModel>() .IgnoreControllerNamespaceEntirely() .IgnoreMethodSuffix("Command") .IgnoreMethodSuffix("Query") .ConstrainToHttpMethod(action => action.Method.Name.EndsWith("Command"), "POST") .ConstrainToHttpMethod(action => action.Method.Name.StartsWith("Query"), "GET"); ApplyConvention <OutputModelSettingBehaviorConfiguration>(); Policies.Add <AntiForgeryPolicy>(); Views.TryToAttachWithDefaultConventions(); HtmlConvention <SampleHtmlConventions>(); this.RegisterPartials(x => x.For <Product>().Use <ProductPartial>()); this.RegisterPartials(x => x.For <ProductPart>().Use <PartPartial>()); Services(s => s.ReplaceService <IUrlTemplatePattern, JQueryUrlTemplate>()); }
public ExecutionPoliciesRegistry() { For <ExecutionPolicy>().Use <CompaniesHouseExecutionPolicy>().Named(CompaniesHouseExecutionPolicy.Name); For <ExecutionPolicy>().Use <HmrcExecutionPolicy>().Named(HmrcExecutionPolicy.Name).SelectConstructor(() => new HmrcExecutionPolicy(null)); For <ExecutionPolicy>().Use <IdamsExecutionPolicy>().Named(IdamsExecutionPolicy.Name); Policies.Add(new ExecutionPolicyPolicy()); }
public void do_not_duplicate_interceptor_policies() { var theActivator = new ActivatorInterceptor<ITarget>(x => x.Activate()); var policy1 = new InterceptorPolicy<ITarget>(theActivator); var policy2 = new InterceptorPolicy<ITarget>(theActivator); policy1.ShouldBe(policy2); var policies = new Policies(); policies.Add(policy1); policies.Add(policy2); policies.Add(policy1); policies.Add(policy2); policies.Interception().Single().ShouldBeTheSameAs(policy1); }
public ScratchpadFubuRegistry() { IncludeDiagnostics(true); Applies .ToThisAssembly(); Actions .FindWith <JsonActionSource>(); this.ApplyEndpointConventions(); this.UseSpark(); Policies .Add(new ValidationConvention(call => call.HasInput && call.InputType().Name.Contains("Input"))); Routes .HomeIs <DashboardEndpoint>(e => e.Get(new DashboardRequest())); Views .TryToAttachWithDefaultConventions(); HtmlConvention <ScratchpadHtmlConventions>(); Output .ToJson .WhenCallMatches(call => call.HasOutput && call.OutputType().Name.Contains("Json")); }
public AdvBehaviorGuideRegistry() { IncludeDiagnostics(true); Applies.ToThisAssembly(); Actions .IncludeTypesNamed(x => x.EndsWith("Controller")); Routes .IgnoreControllerNamespaceEntirely(); Views .TryToAttach(x => { x.by_ViewModel_and_Namespace_and_MethodName(); x.by_ViewModel_and_Namespace(); x.by_ViewModel(); }); Policies .EnrichCallsWith <DemoBehaviorForSelectActions>( call => call.Method.Name == "Home" ) .EnrichCallsWith <DemoBehaviorForSelectActions>( call => call.Returns <HomeViewModel>() ); Policies .Add <DemoBehaviorPolicy>(); Routes.HomeIs <HomeInputModel>(); }
/// <summary> /// Specifies the type of exception that this policy can handle with additional filters on this exception type. /// </summary> /// <typeparam name="TException">The type of the exception.</typeparam> /// <param name="policies"></param> /// <param name="exceptionPredicate">The exception predicate to filter the type of exception this policy can handle.</param> /// <returns>The PolicyBuilder instance.</returns> public ExceptionPolicy OnException(Func <Exception, bool> exceptionPredicate) { var handler = new ExceptionPolicy(this, exceptionPredicate); Policies.Add(handler); return(handler); }
public void AddPolicy(string policy) { _namedPolicies[policy] = policy; if (!Policies.Contains(policy)) { Policies.Add(policy); } }
/// <summary> /// Additional operations to be performed when cloning an instance of <see cref="Device"/> to an instance of <see cref="PSDevice" />. /// </summary> /// <param name="device">The device being cloned.</param> private void CloneAdditionalOperations(Device device) { DeviceId = device.Id; foreach (KeyValuePair <PolicyCategory, string> item in device.Policies) { Policies.Add(new KeyValuePair <PolicyCategory, string>(item.Key, item.Value)); } }
public ConfigureFubuMVC() { Routes.HomeIs <HomeRequest>(); Policies.Add <ApiConvention>(); Import <SwaggerApiDocumentationExtension>(); Import <HandlerConvention>(x => x.MarkerType <HandlerMarker>()); }
public AspNetApplicationFubuRegistry() { Actions.IncludeClassesSuffixedWithController(); Actions.IncludeClassesSuffixedWithEndpoint(); Policies.Add(x => { x.Where.AnyActionMatches(call => call.HandlerType == typeof(CompressedContentController)); x.ContentCompression.Apply(); }); }
private void GetPasswordPolicies() { Policies.Add(GetDomainPolicy()); var fineGrainedPolicies = GetFineGrainedPolicies(); fineGrainedPolicies.ForEach(x => x.AppliesToUsers = GetPasswordPolicyUsers(x)); Policies.AddRange(fineGrainedPolicies); }
public InfrastructorRegistery() { Scan(s => { s.TheCallingAssembly(); s.WithDefaultConventions(); }); Policies.Add <LogConvention>(); }
public MessageSubscriberRegistry() { Policies.Add(new MessageSubscriberPolicy <EmployerApprenticeshipsServiceConfiguration>(Constants.ServiceName)); Scan(s => { s.AssembliesFromApplicationBaseDirectory(a => a.GetName().Name.StartsWith(Constants.ServiceNamespace)); s.AddAllTypesOf <IMessageProcessor>(); }); }
public VisualizationFubuRegistry() { Actions.FindBy(classes => { classes.Applies.ToThisAssembly(); classes.IncludeClassesSuffixedWithEndpoint(); }); Policies.Add <VisualizationsMenu>(); }
/// <summary> /// Add a named policy. You should use the policy specific functions, but if you need to create a policy /// this library does not support you can do it here. /// </summary> /// <param name="name"></param> /// <returns></returns> public PolicyItem GetOrCreatePolicy(String name) { PolicyItem policy; if (!Policies.TryGetValue(name, out policy)) { policy = new PolicyItem(); Policies.Add(name, policy); } return(policy); }
public void AddPolicies(List <string> policies) { foreach (string policy in policies) { _namedPolicies[policy] = policy; if (!Policies.Contains(policy)) { Policies.Add(policy); } } }
public ServiceContextRegistry() { For <IDataContextAsync>().Use <DataServiceContext>(); For(typeof(IRepositoryAsync <>)).Use(typeof(Repository <>)); For(typeof(IRepository <>)).Use(typeof(Repository <>)); For <IUnitOfWorkAsync>().Use <UnitOfWork>(); For(typeof(IEntityService <>)).Use(typeof(EntityService <>)); // Base-Services For(typeof(IBaseServiceProvider <>)).Use(typeof(BaseServiceProvider <>)); For <ICurrentUser>().Use <CurrentUser>(); Policies.Add <DefaultLifetime>(); }
public MyProjectFubuRegistry() { Policies.WrapBehaviorChainsWith <InnerMostBehavior>() .WrapBehaviorChainsWith <MiddleBehavior>() .WrapBehaviorChainsWith <OuterBehavior>(); Policies.EnrichCallsWith <DemoBehaviorForSelectActions>( call => call.Method.Name == "Home"); Policies.EnrichCallsWith <DemoBehaviorForSelectActions>( call => call.Returns <HomeViewModel>()); Policies.Add <DemoBehaviorPolicy>(); }
public DefaultRegistry() { Scan(_ => { _.WithDefaultConventions(); }); // singleton required to persist dirsync cookie For <SynchronizeJob>().Singleton(); // policies Policies.FillAllPropertiesOfType <ActiveDirectoryService>(); Policies.FillAllPropertiesOfType <BackendService>(); Policies.Add <LoggingForClassPolicy>(); }
public StandardTypeResolutionPolicy() { var cache = new CachedResolutionPolicy(InterceptionPolicy.AsInterceptionRule()); Policies.Add(new ArgumentBindingPolicy()); Policies.Add(cache); Policies.Add(new MemorizeResult(cache, new GetIocServiceTypes())); Policies.Add(new GenericResolutionPolicy(cache)); Policies.Add(new MemorizeResult(cache, new EnumerateMultipleBindingsPolicy(this))); Policies.Add(new MemorizeResult(cache, new FunctionsIntoFactories())); Policies.Add(new MemorizeResult(cache, new TuplesToScopeResolutionPolicy())); Policies.Add(new MemorizeResult(cache, new SelfBindByDefault())); Policies.Add(new MemorizeResult(cache, new ConventionResolutionPolicy())); Policies.Add(new DefaultValuePolicy()); }
public CustomFubuRegistry() { // I want to name my action classes with the // "Controller" suffix Actions.IncludeClassesSuffixedWithController(); // Registering a custom policy Policies.Add <MyCustomPolicy>(); // You *can* also declare IoC service // registrations in your FubuRegistry Services(x => { x.AddService <IActivator, MyCustomActivator>(); }); }
public BlogRegistry() { Import <HandlerConvention>(); Actions.FindBy(s => s.ForBottles(a => s.Applies.ToAssembly(a)) .IncludeMethods(m => m.Name == "Execute")); #if !DEBUG this.Assets().CombineAllUniqueAssetRequests(); #endif Policies.Add <ValidationPolicy>(); Services(registry => registry.AddService <IJsonWriter, NewtonSoftJsonWriter>()); }
public DefaultRegistry() { Scan(_ => { _.WithDefaultConventions(); }); For <WSCommunication>().Singleton(); Policies.FillAllPropertiesOfType <WSCommunication>(); Policies.FillAllPropertiesOfType <ADStub>(); Policies.FillAllPropertiesOfType <ReconnectJob>(); Policies.Add <LoggingForClassPolicy>(); }
public ActivitiesWorkerRegistry() { var config = ConfigurationHelper.GetConfiguration <ActivitiesWorkerConfiguration>(ServiceName, Version); For <IActivityMapper>().Use <ActivityMapper>(); For <IActivitySaver>().Use <ActivitySaver>().Singleton(); For <IMessageContextProvider>().Use <MessageContextProvider>().Singleton(); For <IMessageServiceBusConfiguration>().Use(config); Policies.Add(new MessageSubscriberPolicy(ServiceName, config, Log)); Scan(s => { s.AssemblyContainingType <ActivitiesWorkerRegistry>(); s.AddAllTypesOf <IMessageProcessor2>(); }); }
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>(); }