Beispiel #1
0
 public void Populate(TKey key, TPayload payload, long startEdge, int hash)
 {
     this.Key       = key;
     this.Payload   = payload;
     this.StartEdge = startEdge;
     this.Hash      = hash;
 }
Beispiel #2
0
        public async Task <TPayload> DeserializePayloadAsync <TPayload>()
        {
            if (!this.HasEntityBody)
            {
                throw new InvalidOperationException("Cannot deserialize payload because there is no entity body.");
            }

            try
            {
                Type payloadType = typeof(TPayload);
                if (deserializedPayloads.TryGetValue(payloadType, out object value))
                {
                    return((TPayload)value);
                }

                if (this.PayloadStream.CanSeek)
                {
                    this.PayloadStream.Seek(0, SeekOrigin.Begin);
                }

                TPayload payload = await JsonSerializer.DeserializeAsync <TPayload>(this.PayloadStream);

                deserializedPayloads[payloadType] = payload;

                return(payload);
            }
            catch (Exception exception)
            {
                // TODO: Get the payload as a string to give back in the message.
                throw new HttpResponseException(
                          HttpStatusCode.BadRequest,
                          "Failed to deserialize request payload. See inner exception for details.",
                          exception);
            }
        }
 public void Populate(TKey key, TPayload payload, int hash, long other)
 {
     this.Key     = key;
     this.Payload = payload;
     this.Hash    = hash;
     this.Other   = other;
 }
            public BalancedBoundingNode Insert(TBounds lower, TBounds upper, TPayload value)
            {
                if (lower.CompareTo(upper) > 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(lower), $"lower ({lower}) needs to be <= upper ({upper})");
                }

                if (upper.CompareTo(LowerBound) <= 0)
                {
                    if (ReferenceEquals(LowerTree, Nil))
                    {
                        LowerTree = new BalancedBoundingNode(lower, upper, value, Colour.Black)
                        {
                            Parent = this
                        };
                        return(LowerTree);
                    }
                    return(LowerTree.Insert(lower, upper, value));
                }

                if (lower.CompareTo(UpperBound) >= 0)
                {
                    if (ReferenceEquals(UpperTree, Nil))
                    {
                        UpperTree = new BalancedBoundingNode(lower, upper, value, Colour.Black)
                        {
                            Parent = this
                        };
                        return(UpperTree);
                    }
                    return(UpperTree.Insert(lower, upper, value));
                }

                throw new ArgumentOutOfRangeException($"Lower {lower} and upper {upper} overlap with this tree l:{LowerBound},u:{UpperBound}");
            }
Beispiel #5
0
 public void Populate(TKey key, TPayload payload, long sync, long other, int hash)
 {
     this.Key     = key;
     this.Payload = payload;
     this.Sync    = sync;
     this.Other   = other;
     this.Hash    = hash;
 }
Beispiel #6
0
 public bool Invoke(TPayload payload)
 {
     if (!IsAlive || _disposed)
     {
         return(false);
     }
     if (ThreadOption == ThreadOption.Inherited && Context != null)
     {
         Context.Send(state => _callback(Reference?.Target, (TPayload)state), payload);
     }
     else
     {
         _callback(Reference?.Target, payload);
     }
     return(true);
 }
            public BalancedBoundingNode(TBounds lower, TBounds upper, TPayload value, Colour nodeColour)
            {
                if (lower.CompareTo(upper) > 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(lower), $"lower({lower}) must be <= upper({upper}");
                }

                LowerBound = lower;
                UpperBound = upper;
                Value      = value;
                NodeColour = nodeColour;

                LowerTree = Nil;
                UpperTree = Nil;
                Parent    = Nil;
            }
Beispiel #8
0
 public void Populate(TKey key, TPayload payload, int hash)
 {
     this.Key     = key;
     this.Payload = payload;
     this.Hash    = hash;
 }
Beispiel #9
0
 public void Populate(long start, ref TKey key, ref TPayload payload)
 {
     this.Start   = start;
     this.Key     = key;
     this.Payload = payload;
 }
Beispiel #10
0
 public void Populate(long end, ref TKey key, ref TPayload payload)
 {
     this.End     = end;
     this.Key     = key;
     this.Payload = payload;
 }
 public PayloadPipe(TPayload payload, IPipe <SendContext <TMessage> > pipe = default)
 {
     _payload = payload;
     _pipe    = pipe;
 }
Beispiel #12
0
 public AsyncQueueMessage(TPayload payload, CancellationToken cancellationToken)
 {
     Payload               = payload;
     CancellationToken     = cancellationToken;
     _taskCompletionSource = new TaskCompletionSource <TResult>();
 }