/// <summary> /// Initializes a new instance of the <see cref="CorrelationContextBuilder"/> struct using some context. /// </summary> /// <param name="context">Initial context.</param> public CorrelationContextBuilder(CorrelationContext context) { if (DistributedContext.Carrier is NoopDistributedContextCarrier) { this.entries = null; return; } this.entries = new List <CorrelationContextEntry>(context.Entries); }
/// <summary> /// Build a Correlation Context from current builder. /// </summary> /// <returns><see cref="CorrelationContext"/> instance.</returns> public CorrelationContext Build() { if (DistributedContext.Carrier is NoopDistributedContextCarrier || this.entries == null) { return(CorrelationContext.Empty); } var context = new CorrelationContext(this.entries); this.entries = null; // empty current builder entries. return(context); }
/// <summary> /// Initializes a new instance of the <see cref="DistributedContext"/> struct. /// </summary> /// <param name="correlationContext">The correlation context.</param> internal DistributedContext(CorrelationContext correlationContext) { this.correlationContext = correlationContext; }