/// <summary> /// Creates new context <see cref="IContext"/>. /// </summary> /// <param name="fullCorrelationId">Full correlation-id.</param> /// <param name="correlationId">Correlation-id of context to be created.</param> /// <param name="localTag">Special user defined tag.</param> /// <param name="ct">Cancellation token.</param> /// <param name="disposeRegistry">Dispose registry.</param> /// <param name="progress">Progress reporter.</param> /// <param name="displayName">Display name.</param> /// <param name="outerCtx">Outer context of context to be created.</param> /// <returns></returns> public static IContext Create( XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, ArgumentPlaceholder <CancellationToken> ct = default, ArgumentPlaceholder <IVh <IDisposeRegistry> > disposeRegistry = default, ArgumentPlaceholder <IVh <IAsyncProgress <IFormattable> > > progress = default, ArgumentPlaceholder <IFormattable> displayName = default, IContext outerCtx = default) { // var ctx = new GenericContext(fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, outerCtx: outerCtx); // if (ct.HasExplicitValue) { CtProp.SetLocalValue(ctx: ctx, value: ct.ExplicitValue); } if (disposeRegistry.HasExplicitValue) { DisposeRegistryProp.SetLocalValue(ctx: ctx, value: disposeRegistry.ExplicitValue); } if (progress.HasExplicitValue) { ProgressProp.SetLocalValue(ctx: ctx, value: progress.ExplicitValue); } if (displayName.HasExplicitValue) { DisplayNameProp.SetLocalValue(ctx: ctx, value: displayName.ExplicitValue); } // return(ctx); }
public static TContext Set <TContext, T>(this TContext ctx, ContextProperty <T> prop, ArgumentUtilitiesHandle <T> value) where TContext : class, IContext { // if (ctx is null) { throw new ArgumentNullException(paramName: nameof(ctx)); } else if (prop is null) { throw new ArgumentNullException(paramName: nameof(prop)); } // prop.SetLocalValue(ctx: ctx, value: value); return(ctx); }