public CommandEventHandler(IContextBuilder <TContext> contextBuilder) { ContextBuilder = contextBuilder; StateMachine = new StateMachineBuilder() .CreateStateMachine <TournamentState, TournamentCommand, TContext>( sm => sm.DefineState(TournamentState.None) .WithTrigger(TournamentCommand.CreateTournament, TournamentState.TournamentCreated), sm => sm.DefineState(TournamentState.TournamentCreated) .WithTrigger(TournamentCommand.AddPlayer, TournamentState.TournamentStarted), sm => sm.DefineState(TournamentState.TournamentStarted) .WithTrigger(TournamentCommand.AddPlayer, TournamentState.TournamentStarted) .WithTrigger(TournamentCommand.RemovePlayer, TournamentState.TournamentStarted) .WithTrigger(TournamentCommand.RecordMatchResults, TournamentState.RoundStarted), sm => sm.DefineState(TournamentState.RoundStarted) .WithTrigger(TournamentCommand.RecordMatchResults, TournamentState.RoundStarted) .WithTrigger(TournamentCommand.EndRound, (bool allRoundsCompleted) => !allRoundsCompleted, TournamentState.RoundEnded) .WithTrigger(TournamentCommand.EndRound, (bool allRoundsCompleted) => allRoundsCompleted, TournamentState.TournamentEnded), sm => sm.DefineState(TournamentState.RoundEnded) .WithTrigger(TournamentCommand.RemovePlayer, TournamentState.RoundEnded) .WithTrigger(TournamentCommand.RecordMatchResults, TournamentState.RoundStarted) ); }
public ContextManager(IContextBuilder contextBuilder, IRepositoryManager repositoryManager, ITagger tagger, IBagOfWords bagOfWords) { this.contextBuilder = contextBuilder; this.repositoryManager = repositoryManager; this.tagger = tagger; this.bagOfWords = bagOfWords; }
public RabbitMqHandler(IRabbitMqClient rabbitMqClient, IContextBuilder contextBuilder, ISpanContextBuilder spanContextBuilder, IRequestProcessor requestProcessor, IPayloadBuilder payloadBuilder, IPayloadValidator payloadValidator) { _rabbitMqClient = rabbitMqClient; _contextBuilder = contextBuilder; _spanContextBuilder = spanContextBuilder; _requestProcessor = requestProcessor; _payloadBuilder = payloadBuilder; _payloadValidator = payloadValidator; }
public RabbitMqHandler(IRabbitMqClient rabbitMqClient, IContextBuilder contextBuilder, RabbitMqOptions options, IRequestProcessor requestProcessor, IPayloadBuilder payloadBuilder, IPayloadValidator payloadValidator, ILogger <RabbitMqHandler> logger) { _rabbitMqClient = rabbitMqClient; _options = options; _contextBuilder = contextBuilder; _requestProcessor = requestProcessor; _payloadBuilder = payloadBuilder; _payloadValidator = payloadValidator; _logger = logger; }
public RabbitMqHandler(IRabbitMqClient rabbitMqClient, IContextBuilder contextBuilder, ISpanContextBuilder spanContextBuilder, IRequestProcessor requestProcessor, IPayloadBuilder payloadBuilder, IPayloadValidator payloadValidator, RabbitMqOptions options, IServiceProvider serviceProvider) { _rabbitMqClient = rabbitMqClient; _contextBuilder = contextBuilder; _spanContextBuilder = spanContextBuilder; _requestProcessor = requestProcessor; _payloadBuilder = payloadBuilder; _payloadValidator = payloadValidator; _options = options; _requestHooks = serviceProvider.GetServices <IRequestHook>(); _responseHooks = serviceProvider.GetServices <IResponseHook>(); }
private static void PopulateComment(IContextBuilder cb, RfqComment comment) { if (comment.RequestId != null) { cb.AddValue("requestId", comment.RequestId); } cb.AddValue("requestParty", comment.RequestParty); cb.AddValue("counterParty", comment.CounterParty); if (comment.ProductName != null) { cb.AddValue("productName", comment.ProductName); } cb.AddValue("comment", comment.Comment); }
public static IContextBuilder <HttpServer> WithContainer(this IContextBuilder <HttpServer> builder, HttpConfiguration configuration) { IServiceProvider appContainer = builder.GetApplicationContainer(); configuration.DependencyResolver = new OwinDependencyResolverWebApiAdapter(appContainer); if (builder.Context == null) { builder.Context = new OwinDependencyScopeHttpServerAdapter(configuration); return(builder); } var oldContext = builder.Context; builder.Context = new OwinDependencyScopeHttpServerAdapter(configuration) { InnerHandler = oldContext }; return(builder); }
public static IAuthorizationContext ToAuthorizationContext(this Uri uri) { IContextBuilder <IAuthorizationContext> builder = GetBuilder(); return(builder.FromUri(uri)); }
public static IAuthorizationContext ToAuthorizationContext(this HttpRequestBase request) { IContextBuilder <IAuthorizationContext> builder = GetBuilder(); return(builder.FromHttpRequest(request)); }
public HttpRequestHook(IContextBuilder contextBuilder) { _contextBuilder = contextBuilder; }
/// <summary> /// Sets the Context that gives the Statement more meaning. /// <para>Examples: a team the Actor is working with, altitude at which a scenario was attempted in a flight simulator.</para> /// </summary> /// <param name="contextBuilder">A context builder.</param> /// <returns>The statement builder, to continue the fluent configuration.</returns> public IStatementBuilder WithContext(IContextBuilder contextBuilder) => WithContext(contextBuilder.Build());
public ContextSpecBuilder(IContextBuilder contextBuilder, IScenarioBuilder scenarioBuilder) { _contextBuilder = contextBuilder; _scenarioBuilder = scenarioBuilder; }
/// <summary> /// Initializes a new instance of the <see cref="ContextualFileResolver"/> class. /// </summary> /// <param name="builder">The builder.</param> /// <exception cref="System.ArgumentNullException">builder</exception> public ContextualFileResolver(IContextBuilder builder) { _contextBuilder = builder ?? throw new System.ArgumentNullException(nameof(builder)); }
public CorrelationContextHttpHook(IContextBuilder contextBuilder) { _contextBuilder = contextBuilder; }
public AllInOneDto Load(IBlock block, IContextBuilder contextBuilder, int appId, List <ItemIdentifier> items) { // Security check var wraplog = Log.Call($"load many a#{appId}, items⋮{items.Count}"); // do early permission check - but at this time it may be that we don't have the types yet // because they may be group/id combinations, without type information which we'll look up afterwards var appIdentity = State.Identity(null, appId); //var block = GetBlock(); items = new ContentGroupList(block, Log).ConvertListIndexToId(items, appIdentity); // now look up the types, and repeat security check with type-names // todo: 2020-03-20 new feat 11.01, may not check inner type permissions ATM var permCheck = new MultiPermissionsTypes().Init(block.Context, GetApp(appId, block), items, Log); if (!permCheck.EnsureAll(GrantSets.WriteSomething, out var error)) { throw HttpException.PermissionDenied(error); } // load items - similar var result = new AllInOneDto(); var entityApi = new EntityApi(appId, permCheck.EnsureAny(GrantSets.ReadDraft), Log); var typeRead = entityApi.AppRead.ContentTypes; var list = entityApi.GetEntitiesForEditing(items); var jsonSerializer = new JsonSerializer(); result.Items = list.Select(e => new BundleWithHeader <JsonEntity> { Header = e.Header, Entity = GetSerializeAndMdAssignJsonEntity(appId, e, jsonSerializer, typeRead) }).ToList(); // set published if some data already exists if (list.Any()) { result.IsPublished = list.First().Entity?.IsPublished ?? true; // Entity could be null (new), then true // only set draft-should-branch if this draft already has a published item if (!result.IsPublished) { result.DraftShouldBranch = list.First().Entity?.GetPublished() != null; } } // since we're retrieving data - make sure we're allowed to // this is to ensure that if public forms only have create permissions, they can't access existing data // important, this code is shared/duplicated in the EntitiesController.GetManyForEditing if (list.Any(set => set.Entity != null)) { if (!permCheck.EnsureAll(GrantSets.ReadSomething, out error)) { throw HttpException.PermissionDenied(error); } } // load content-types var types = UsedTypes(list, typeRead); result.ContentTypes = types .Select(ct => JsonSerializer.ToJson(ct, true)) .ToList(); // todo: ensure that sub-properties of the content-types are included var entList = types.SelectMany( // in all Content-Type attributes like title, body etc. t => t.Attributes.SelectMany( // check all metadata of these attributes - get possible sub-entities attached a => a.Metadata.SelectMany(m => m.Children()) ) ); result.ContentTypeItems = entList.Select(e => jsonSerializer.ToJson(e, 0, Log)).ToList(); // Fix not-supported input-type names; map to correct name result.ContentTypes .ForEach(jt => jt.Attributes .ForEach(at => at.InputType = InputTypes.MapInputTypeV10(at.InputType))); // load input-field configurations result.InputTypes = GetNecessaryInputTypes(result.ContentTypes, typeRead); // also include UI features result.Features = FeaturesHelpers.FeatureListWithPermissionCheck(permCheck).ToList(); // Attach context result.Context = contextBuilder.InitApp(appIdentity.ZoneId, permCheck.App) .Get(Ctx.AppBasic | Ctx.Language | Ctx.Site | Ctx.System); // done - return wraplog($"ready, sending items:{result.Items.Count}, " + $"types:{result.ContentTypes.Count}, " + $"inputs:{result.InputTypes.Count}, " + $"feats:{result.Features.Count}"); return(result); }
public static IContextBuilder <T> Use <T>(this IContextBuilder <T> builder, Func <IAppBuilder, T, IAppBuilder> setup) { return(setup(builder, builder.Context) as IContextBuilder <T>); }
public ContextRunner(IContextBuilder builder) { this.builder = builder; Contexts = new List<Context>(); }
public ContextRunner(IContextBuilder builder) { this.builder = builder; Contexts = new List <Context>(); }
public static ITokenContext ToTokenContext(this HttpRequestBase request) { IContextBuilder <ITokenContext> builder = GetContextBuilder(); return(builder.FromHttpRequest(request)); }