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);
 }
예제 #2
0
 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);
 }
예제 #4
0
 public RoutingContext(OutgoingMessage messageToDispatch, RoutingStrategy routingStrategy, IBehaviorContext parentContext)
     : this(messageToDispatch, new[]
     {
         routingStrategy
     }, parentContext)
 {
 }
예제 #5
0
 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);
        }
예제 #9
0
        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();
 }
예제 #12
0
        public Task Publish(IBehaviorContext context, object message, PublishOptions options)
        {
            var messageType = messageMapper.GetMappedTypeFor(message.GetType());

            return(Publish(context, messageType, message, options));
        }
예제 #13
0
        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));
        }
예제 #14
0
 public void HandlePropertyChanged(IBehaviorContext context, ChangeArgs args)
 {
     PropertyChangedWasCalled = true;
 }
예제 #15
0
 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));
 }
예제 #18
0
 protected BehaviorContext(IBehaviorContext parentContext) : this(parentContext, parentContext?.CancellationToken ?? default)
 { }
예제 #19
0
 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;
 }
예제 #21
0
 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));
 }
예제 #23
0
        protected override void RevalidateDescendantsCore(IBehaviorContext context, ValidationScope scope)
        {
            var items = (IEnumerable <IViewModel>) this.GetValueNext <IVMCollection <TItemVM> >(context);

            Revalidator.RevalidateItems(items, scope);
        }
예제 #24
0
 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);
 }
예제 #26
0
        public Task Send(IBehaviorContext context, object message, SendOptions options)
        {
            var messageType = messageMapper.GetMappedTypeFor(message.GetType());

            return(SendMessage(context, messageType, message, options));
        }
예제 #27
0
 public RoutingContext(OutgoingMessage messageToDispatch, IReadOnlyCollection<RoutingStrategy> routingStrategies, IBehaviorContext parentContext)
     : base(messageToDispatch.MessageId, messageToDispatch.Headers, parentContext)
 {
     Message = messageToDispatch;
     RoutingStrategies = routingStrategies;
 }
예제 #28
0
 public void Revalidate(IBehaviorContext context, ValidationController controller)
 {
     WasCalled = true;
 }
예제 #29
0
 protected BehaviorContext(IBehaviorContext parentContext) : base(parentContext?.Extensions)
 {
 }
예제 #30
0
 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;
 }
예제 #37
0
 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);
 }
예제 #42
0
 public DispatchContext(IReadOnlyCollection<TransportOperation> operations, IBehaviorContext parentContext)
     : base(parentContext)
 {
     Operations = operations;
 }
예제 #43
0
        public Task Reply(IBehaviorContext context, object message, ReplyOptions options)
        {
            var messageType = messageMapper.GetMappedTypeFor(message.GetType());

            return(ReplyMessage(context, messageType, message, options));
        }
예제 #44
0
 public Task CancelDeferredMessages(string messageKey, IBehaviorContext context)
 {
     //no-op
     return TaskEx.CompletedTask;
 }
 public IViewModel GetValue(IBehaviorContext context)
 {
     return(ValueToReturn);
 }