Ejemplo n.º 1
0
        public Task BindModelAsync(ModelBindingContext bindingContext)
        {
            var modelName           = bindingContext.ModelName;
            var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);

            if (valueProviderResult == ValueProviderResult.None)
            {
                return(Task.CompletedTask);
            }

            bindingContext.ModelState.SetModelValue(modelName, valueProviderResult);
            var value = valueProviderResult.FirstValue;

            if (string.IsNullOrEmpty(value))
            {
                return(Task.CompletedTask);
            }

            if (TimeSpanExtension.TryParse(value, out var timespan))
            {
                bindingContext.Result = ModelBindingResult.Success(timespan);
            }
            else
            {
                bindingContext.Result = ModelBindingResult.Failed();
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        public override void RunAction()
        {
            if (base.Target.Unit == null)
            {
                return;
            }

            ItemEntityWeapon maybeWeapon  = base.Target.Unit.Body.PrimaryHand.MaybeWeapon;
            ItemEntityWeapon maybeWeapon2 = base.Target.Unit.Body.SecondaryHand.MaybeWeapon;

            if (maybeWeapon != null && !maybeWeapon.Blueprint.IsUnarmed && !maybeWeapon.Blueprint.IsNatural)
            {
                base.Target.Unit.Descriptor.AddBuff(BlueprintRoot.Instance.SystemMechanics.DisarmMainHandBuff, this.Context, TimeSpanExtension.Seconds(6));
            }
            else if (maybeWeapon2 != null && !maybeWeapon2.Blueprint.IsUnarmed && !maybeWeapon2.Blueprint.IsNatural)
            {
                this.Target.Unit.Descriptor.AddBuff(BlueprintRoot.Instance.SystemMechanics.DisarmOffHandBuff, this.Context, TimeSpanExtension.Seconds(6));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Execute mapping from AMQP message structure to BrokeredMessage structure
        /// </summary>
        /// <param name="message">AMQP message instance</param>
        /// <param name="brokeredMessage">Brokered message instance</param>
        internal static void AmqpMessageToBrokeredMessage(Message message, BrokeredMessage brokeredMessage)
        {
            if (message.Header.Ttl != 0)
            {
                brokeredMessage.TimeToLive = TimeSpanExtension.FromMilliseconds(message.Header.Ttl);
            }
            if ((message.Properties.MessageId != null) && (message.Properties.MessageId != string.Empty))
            {
                brokeredMessage.MessageId = message.Properties.MessageId;
            }
            if ((message.Properties.CorrelationId != null) && (message.Properties.CorrelationId != string.Empty))
            {
                brokeredMessage.CorrelationId = message.Properties.CorrelationId;
            }
            if (message.Properties.ContentType != null)
            {
                brokeredMessage.ContentType = message.Properties.ContentType.ToString();
            }
            if ((message.Properties.Subject != null) && (message.Properties.Subject != string.Empty))
            {
                brokeredMessage.Label = message.Properties.Subject;
            }
            if ((message.Properties.To != null) && (message.Properties.To != string.Empty))
            {
                brokeredMessage.To = message.Properties.To;
            }
            if ((message.Properties.ReplyTo != null) && (message.Properties.ReplyTo != string.Empty))
            {
                brokeredMessage.ReplyTo = message.Properties.ReplyTo;
            }
            if ((message.Properties.GroupId != null) && (message.Properties.GroupId != string.Empty))
            {
                brokeredMessage.SessionId = message.Properties.GroupId;
            }
            if ((message.Properties.ReplyToGroupId != null) && (message.Properties.ReplyToGroupId != string.Empty))
            {
                brokeredMessage.ReplyToSessionId = message.Properties.ReplyToGroupId;
            }

            if (message.MessageAnnotations != null)
            {
                object annotation = null;
                annotation = message.MessageAnnotations[new Symbol(PUBLISHER_NAME)];
                if (annotation != null)
                {
                    brokeredMessage.Publisher = (string)annotation;
                }

                annotation = message.MessageAnnotations[new Symbol(PARTITION_KEY_NAME)];
                if (annotation != null)
                {
                    brokeredMessage.PartitionKey = (string)annotation;
                }

                annotation = message.MessageAnnotations[new Symbol(SCHEDULED_ENQUEUE_TIME_UTC)];
                if (annotation != null)
                {
                    brokeredMessage.ScheduledEnqueueTimeUtc = (DateTime)annotation;
                }

                annotation = message.MessageAnnotations[new Symbol(ENQUEUED_TIME_UTC_NAME)];
                if (annotation != null)
                {
                    brokeredMessage.EnqueuedTimeUtc = (DateTime)annotation;
                }

                annotation = message.MessageAnnotations[new Symbol(SEQUENCE_NUMBER_NAME)];
                if (annotation != null)
                {
                    brokeredMessage.SequenceNumber = (long)annotation;
                }

                annotation = message.MessageAnnotations[new Symbol(LOCKED_UNTIL_NAME)];
                if (annotation != null)
                {
                    brokeredMessage.LockedUntilUtc = (DateTime)annotation;
                }
            }

            if (message.ApplicationProperties != null)
            {
                foreach (var key in message.ApplicationProperties.Map.Keys)
                {
                    object netObject = null;
                    if (AqmpObjectToNetObject(message.ApplicationProperties.Map[key], out netObject))
                    {
                        brokeredMessage.Properties[key] = netObject;
                    }
                }
            }
        }