public OutgoingLogicalMessageContext(string messageId, Dictionary<string, string> headers, OutgoingLogicalMessage message, IReadOnlyCollection<RoutingStrategy> routingStrategies, IBehaviorContext parentContext) : base(messageId, headers, parentContext) { Message = message; RoutingStrategies = routingStrategies; Set(message); }
public ForwardingContext(OutgoingMessage messageToForward, string address, IBehaviorContext parentContext) : base(parentContext) { Guard.AgainstNull(nameof(messageToForward), messageToForward); Guard.AgainstNullAndEmpty(nameof(address), address); Message = messageToForward; Address = address; }
public IncomingLogicalMessageContext(LogicalMessage logicalMessage, string messageId, string replyToAddress, Dictionary<string, string> headers, IBehaviorContext parentContext) : base(messageId, replyToAddress, headers, parentContext) { Message = logicalMessage; Headers = headers; Set(logicalMessage); }
public RoutingContext(OutgoingMessage messageToDispatch, RoutingStrategy routingStrategy, IBehaviorContext parentContext) : this(messageToDispatch, new[] { routingStrategy }, parentContext) { }
public AuditContext(OutgoingMessage message, string auditAddress, IBehaviorContext parent) : base(parent) { Guard.AgainstNull(nameof(message), message); Guard.AgainstNullAndEmpty(nameof(auditAddress), auditAddress); Message = message; AuditAddress = auditAddress; }
/// <summary> /// Creates a new transport receive context. /// </summary> /// <param name="receivedMessage">The received message.</param> /// <param name="transportTransaction">The transport transaction.</param> /// <param name="cancellationTokenSource"> /// Allows the pipeline to flag that it has been aborted and the receive operation should be rolled back. /// It also allows the transport to communicate to the pipeline to abort if possible. /// </param> /// <param name="parentContext">The parent context.</param> public TransportReceiveContext(IncomingMessage receivedMessage, TransportTransaction transportTransaction, CancellationTokenSource cancellationTokenSource, IBehaviorContext parentContext) : base(parentContext) { this.cancellationTokenSource = cancellationTokenSource; Message = receivedMessage; Set(Message); Set(transportTransaction); }
public InvokeHandlerContext(MessageHandler handler, string messageId, string replyToAddress, Dictionary<string, string> headers, MessageMetadata messageMetadata, object messageBeingHandled, SynchronizedStorageSession storageSession, IBehaviorContext parentContext) : base(messageId, replyToAddress, headers, parentContext) { MessageHandler = handler; Headers = headers; MessageBeingHandled = messageBeingHandled; MessageMetadata = messageMetadata; Set(storageSession); }
public OutgoingReplyContext(OutgoingLogicalMessage message, ReplyOptions options, IBehaviorContext parentContext) : base(options.MessageId, new Dictionary<string, string>(options.OutgoingHeaders), parentContext) { Message = message; Guard.AgainstNull(nameof(parentContext), parentContext); Guard.AgainstNull(nameof(message), message); Guard.AgainstNull(nameof(options), options); parentContext.Extensions.Merge(options.Context); }
public SubscribeContext(IBehaviorContext parentContext, Type eventType, SubscribeOptions options) : base(parentContext) { Guard.AgainstNull(nameof(parentContext), parentContext); Guard.AgainstNull(nameof(eventType), eventType); Guard.AgainstNull(nameof(options), options); parentContext.Extensions.Merge(options.Context); EventType = eventType; }
public Task CancelDeferredMessages(string messageKey, IBehaviorContext context) { var controlMessage = ControlMessageFactory.Create(MessageIntentEnum.Send); controlMessage.Headers[Headers.SagaId] = messageKey; controlMessage.Headers[TimeoutManagerHeaders.ClearTimeouts] = bool.TrueString; var dispatchContext = new RoutingContext(controlMessage, new UnicastRoutingStrategy(timeoutManagerAddress), context); var cache = context.Extensions.Get<IPipelineCache>(); var dispatchPipeline = cache.Pipeline<IRoutingContext>(); return dispatchPipeline.Invoke(dispatchContext); }
private void InvalidateCache(IBehaviorContext context) { GetCache(context).Invalidate(); }
public Task Publish(IBehaviorContext context, object message, PublishOptions options) { var messageType = messageMapper.GetMappedTypeFor(message.GetType()); return(Publish(context, messageType, message, options)); }
public static Task Send <T>(IBehaviorContext context, Action <T> messageConstructor, SendOptions options) { var mapper = context.Extensions.Get <IMessageMapper>(); return(SendMessage(context, typeof(T), mapper.CreateInstance(messageConstructor), options)); }
public void HandlePropertyChanged(IBehaviorContext context, ChangeArgs args) { PropertyChangedWasCalled = true; }
public void SetValue(IBehaviorContext context, T value) { Value = value; }
public IncomingPhysicalMessageContext(IncomingMessage message, IBehaviorContext parentContext) : base(message.MessageId, message.GetReplyToAddress(), message.Headers, parentContext) { Message = message; }
public string GetValue(IBehaviorContext context) { return(GetInvalidValueOrNext(context)); }
protected BehaviorContext(IBehaviorContext parentContext) : this(parentContext, parentContext?.CancellationToken ?? default) { }
public static GameObject GetGameObject(this IBehaviorContext ctx, string key = null) { key = key ?? "gameObject"; return(ctx.GetItem <GameObject>(key)); }
public DispatchContext(TransportOperation[] operations, IBehaviorContext parentContext) : base(parentContext?.Extensions) { this.operations = operations; }
public static T GetComponent <T>(this IBehaviorContext ctx) where T : Component { return(ctx.GetGameObject().GetComponent <T>()); }
protected override IVMCollection <TItemVM> ProvideValue(IBehaviorContext context) { return(this.CreateValueNext <IVMCollection <TItemVM> >(context)); }
protected override void RevalidateDescendantsCore(IBehaviorContext context, ValidationScope scope) { var items = (IEnumerable <IViewModel>) this.GetValueNext <IVMCollection <TItemVM> >(context); Revalidator.RevalidateItems(items, scope); }
public Task Send <T>(IBehaviorContext context, Action <T> messageConstructor, SendOptions options) { return(SendMessage(context, typeof(T), messageMapper.CreateInstance(messageConstructor), options)); }
public void SetValue(IBehaviorContext context, string value) { SetValueNextIfValidationSucceeds(context, value); }
public Task Send(IBehaviorContext context, object message, SendOptions options) { var messageType = messageMapper.GetMappedTypeFor(message.GetType()); return(SendMessage(context, messageType, message, options)); }
public RoutingContext(OutgoingMessage messageToDispatch, IReadOnlyCollection<RoutingStrategy> routingStrategies, IBehaviorContext parentContext) : base(messageToDispatch.MessageId, messageToDispatch.Headers, parentContext) { Message = messageToDispatch; RoutingStrategies = routingStrategies; }
public void Revalidate(IBehaviorContext context, ValidationController controller) { WasCalled = true; }
protected BehaviorContext(IBehaviorContext parentContext) : base(parentContext?.Extensions) { }
public T GetValue(IBehaviorContext context) { return(Value); }
public TValue GetValue(IBehaviorContext context) { RequireInitialized(); return(this.GetValueNext <TValue>(context)); }
/// <summary> /// Executes behavior with given context /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public override BehaviorReturnCode Behave(IBehaviorContext context) { UnitBehaviorContext unitContext = context as UnitBehaviorContext; if (unitContext == null) { returnCode = BehaviorReturnCode.Failure; return(returnCode); } StarSystem system = unitContext.Unit.Environment as StarSystem; if (system == null || system.Planets == null) { returnCode = BehaviorReturnCode.Failure; return(returnCode); } returnCode = BehaviorReturnCode.Failure; unitContext.EnvironmentTarget = null; int minDistance = int.MaxValue; foreach (var planet in system.Planets) { if (unitContext.Unit.Owner.ScannedStarSystemBodies.Contains(planet.GlobalKey)) { continue; } if (system.UnitsMap.ContainsKey(planet.HexMapKey)) { continue; } if (planet.Owner != null) { continue; } /* * if (!unitContext.Unit.Owner.ColonizablePlanetTypes.Contains(planet.PlanetType)) * { * continue; * } */ int distance = HexMap.Distance(unitContext.Unit, planet.Environment); if (minDistance > distance) { minDistance = distance; unitContext.EnvironmentTarget = planet; } } if (unitContext.EnvironmentTarget != null) { context.AddLogMessage("Planet found - " + ((Planet)unitContext.EnvironmentTarget).Name); returnCode = BehaviorReturnCode.Success; } return(returnCode); }
public void InitializeValue(IBehaviorContext context) { InitializeValueWasCalled = true; }
public IncomingLogicalMessageContext(LogicalMessage logicalMessage, string messageId, string replyToAddress, Dictionary <string, string> headers, IBehaviorContext parentContext) : base(messageId, replyToAddress, headers, parentContext) { Message = logicalMessage; Headers = headers; Set(logicalMessage); }
public override void SetValue(IBehaviorContext context, IVMCollection <TItemVM> value) { throw new NotSupportedException( ExceptionTexts.CannotSetVMCollectionProperties ); }
public void SetValue(IBehaviorContext context, IViewModel value) { LastSetValue = value; }
public Task Publish <T>(IBehaviorContext context, Action <T> messageConstructor, PublishOptions options) { return(Publish(context, typeof(T), messageMapper.CreateInstance(messageConstructor), options)); }
protected override string GetValueNext(IBehaviorContext context) { return(NextValue); }
public TValue CreateValue(IBehaviorContext context) { var sourceObject = _sourceObjectPath.GetValue((TVM)context.VM); return(_factoryMethod(context, (TVM)context.VM, sourceObject)); }
protected override void SetValueNext(IBehaviorContext context, string value) { LastSetNextValue = value; }
public void HandleChange(IBehaviorContext context, ChangeArgs args) { _changeHandler((TVM)context.VM, args); this.HandleChangedNext(context, args); }
public DispatchContext(IReadOnlyCollection<TransportOperation> operations, IBehaviorContext parentContext) : base(parentContext) { Operations = operations; }
public Task Reply(IBehaviorContext context, object message, ReplyOptions options) { var messageType = messageMapper.GetMappedTypeFor(message.GetType()); return(ReplyMessage(context, messageType, message, options)); }
public Task CancelDeferredMessages(string messageKey, IBehaviorContext context) { //no-op return TaskEx.CompletedTask; }
public IViewModel GetValue(IBehaviorContext context) { return(ValueToReturn); }