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 }); }
public Letter(string exchange, string routingKey, byte[] data, LetterMetadata metadata = null, RoutingOptions routingOptions = null) { Envelope = new Envelope { Exchange = exchange, RoutingKey = routingKey, RoutingOptions = routingOptions ?? DefaultRoutingOptions() }; Body = data; LetterMetadata = metadata ?? new LetterMetadata(); }
public Letter(string exchange, string routingKey, byte[] data, string id, byte priority) { Envelope = new Envelope { Exchange = exchange, RoutingKey = routingKey, RoutingOptions = DefaultRoutingOptions(priority) }; Body = data; if (!string.IsNullOrWhiteSpace(id)) { LetterMetadata = new LetterMetadata { Id = id }; } else { LetterMetadata = new LetterMetadata(); } }