예제 #1
0
        public Letter Clone()
        {
            var clone = this.Clone <Letter>();

            clone.LetterMetadata = LetterMetadata.Clone <LetterMetadata>();
            return(clone);
        }
예제 #2
0
파일: Letter.cs 프로젝트: lsfera/Tesseract
        public Letter Clone()
        {
            var metadata = new LetterMetadata
            {
                Compressed = LetterMetadata.Compressed,
                Encrypted  = LetterMetadata.Encrypted,
            };

            foreach (var kvp in LetterMetadata.CustomFields)
            {
                metadata.CustomFields.Add(kvp.Key, kvp.Value);
            }

            return(new Letter
            {
                Envelope = new Envelope
                {
                    Exchange = Envelope.Exchange,
                    RoutingKey = Envelope.RoutingKey,
                    RoutingOptions = new RoutingOptions
                    {
                        DeliveryMode = Envelope.RoutingOptions?.DeliveryMode ?? 2,
                        Mandatory = Envelope.RoutingOptions?.Mandatory ?? false,
                        PriorityLevel = Envelope.RoutingOptions?.PriorityLevel ?? 0,
                    }
                },
                LetterMetadata = metadata
            });
        }
예제 #3
0
 public Letter(string exchange, string routingKey, byte[] data, LetterMetadata metadata = null, RoutingOptions routingOptions = null)
 {
     Envelope = new Envelope
     {
         Exchange       = exchange,
         RoutingKey     = routingKey,
         RoutingOptions = routingOptions ?? RoutingOptions.CreateDefaultRoutingOptions()
     };
     Body           = data;
     LetterMetadata = metadata ?? new LetterMetadata();
 }
예제 #4
0
 public Letter(string exchange, string routingKey, byte[] data, string id, RoutingOptions routingOptions = null)
 {
     Envelope = new Envelope
     {
         Exchange       = exchange,
         RoutingKey     = routingKey,
         RoutingOptions = routingOptions ?? RoutingOptions.CreateDefaultRoutingOptions()
     };
     Body = data;
     if (!string.IsNullOrWhiteSpace(id))
     {
         LetterMetadata = new LetterMetadata {
             Id = id
         };
     }
     else
     {
         LetterMetadata = new LetterMetadata();
     }
 }
예제 #5
0
 public IDictionary <string, object> GetHeadersOutOfMetadata() => LetterMetadata.GetHeadersOutOfMetadata();
예제 #6
0
 public bool RemoveHeader(string key) => LetterMetadata.RemoveHeader(key);
예제 #7
0
 public T GetHeader <T>(string key) => LetterMetadata.GetHeader <T>(key);