Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
 /// <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;
 }