/// <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 ErrorCode(IErrorCode other, ArgumentPlaceholder <string> description = default, ArgumentPlaceholder <SeverityLevel?> severityLevel = default) : this( identifier : other.EnsureNotNull(nameof(other)).Value.Identifier, severityLevel : severityLevel.Substitute(value : other.SeverityLevel), description : description.Substitute(value : other.Description)) { }
public ContextProperty(string name, Action <IContext, T> cleanup = default, ArgumentPlaceholder <T> fallbackValue = default, Action <ArgumentUtilitiesHandle <T> > validator = default) : base(name: name, type: typeof(T)) { _fallbackValue = fallbackValue; _cleanup = cleanup; _values = new DisposableTable <IContext, PropertyValueHolder <IContext, T> >(); _validator = validator; }
public static IContext New( this IContext outerCtx, 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) => Create(outerCtx: outerCtx, fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, ct: ct, disposeRegistry: disposeRegistry, progress: progress, displayName: displayName);
public TriggerSignalProperties(ITrigger trigger, ArgumentPlaceholder <DateTimeOffset> timestamp = default, ArgumentPlaceholder <XFullCorrelationId> correlationId = default) { trigger.EnsureNotNull(nameof(trigger)); if (correlationId.HasExplicitValue && correlationId.ExplicitValue.IsEmpty) { throw new ArgumentException(message: "Cannot be empty.", paramName: nameof(correlationId)); } // _trigger = trigger; _source = null; _timestamp = timestamp.Substitute(value: DateTimeOffset.Now); _correlationId = correlationId.Substitute(value: default);
protected MetadataLoadContextBase( bool skipLinkedMetadata, Uri baseUri, string mediaType = default, Uri siteOrigin = default, XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext outerCtx = default) : base(baseUri: baseUri, mediaType: mediaType, siteOrigin: siteOrigin, fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, outerCtx: outerCtx) { // _skipLinkedMetadata = skipLinkedMetadata; }
public DescriptionPackageIdentity(DescriptionPackageIdentity other, ArgumentPlaceholder <MetadataName> name = default, ArgumentPlaceholder <UriBasedIdentifier> publisherScopeId = default, ArgumentPlaceholder <Version> version = default, bool isReadOnly = default) : this( name: other .EnsureNotNull(nameof(other)) .Value .Name .Fluent() .If(condition : name.HasExplicitValue, trueBody : locOtherName => name.ExplicitValue, falseBody : locOtherName => locOtherName), publisherScopeId : publisherScopeId.HasExplicitValue ? publisherScopeId.ExplicitValue : other.PublisherScopeId, version : version.HasExplicitValue ? version.ExplicitValue : other.Version, isReadOnly : isReadOnly) { }
public Pool( Func <T> itemFactory, ArgumentPlaceholder <bool> ownsItem = default, ArgumentPlaceholder <TimeoutDuration> itemPreferredSlidingTtl = default, ArgumentPlaceholder <int> maxSize = default, string displayName = default, ArgumentPlaceholder <ILogger> logger = default) : this( itemFactory : P_MakeItemFactoryDelegate(itemFactory : itemFactory), ownsItem : ownsItem.Substitute(value : Pool.DefaultOfOwnsItem), itemPreferredSlidingTtl : itemPreferredSlidingTtl.Substitute(value : Pool.DefaultOfItemPreferredSlidingTtl), maxSize : maxSize.Substitute(value : Pool.DefaultOfMaxSize), displayName : displayName, logger : logger) { }
public SubjectFileLoadContext( string localFilePath, string mediaType = default, XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext ambientContext = default) : this( fileUri : new Uri(uriString : localFilePath.Arg(nameof(localFilePath)).EnsureNotNullOrWhiteSpace(), uriKind : UriKind.Absolute), mediaType : mediaType, fullCorrelationId : fullCorrelationId, correlationId : correlationId, localTag : localTag, ambientContext : ambientContext) { }
public SubjectFileLoadContext( Uri fileUri, string mediaType = default, XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext ambientContext = default) : base( baseUri: fileUri.Arg(nameof(fileUri)).EnsureFileScheme().EnsureLoopbackOrUnc(), mediaType: mediaType, fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, outerCtx: ambientContext) { }
public DescriptionPackageLoadContext( DescriptionPackageLocator locator, Uri loadUri, bool skipLinkedMetadata, string mediaType = default, Uri siteOrigin = default, XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext outerCtx = default) : base(skipLinkedMetadata: skipLinkedMetadata, baseUri: loadUri, mediaType: mediaType, siteOrigin: siteOrigin, fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, outerCtx: outerCtx) { // locator.EnsureNotNull(nameof(locator)); // _locator = locator; }
public SubjectFileLoadContext( FileInfo localFile, string mediaType = default, XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext ambientContext = default) : this( fileUri : new Uri(localFile.EnsureNotNull(nameof(localFile)).Value.FullName, UriKind.Absolute), mediaType : mediaType, fullCorrelationId : fullCorrelationId, correlationId : correlationId, localTag : localTag, ambientContext : ambientContext) { // _file = localFile; }
internal P_State( P_State other, ArgumentPlaceholder <bool> initializationDone = default, ArgumentPlaceholder <IDbContextTransaction> realTx = default, ArgumentPlaceholder <Action <PersistenceEfCoreDataContextTxScope> > disposeCallback = default, ArgumentPlaceholder <Action <PersistenceEfCoreDataContextTxScope> > completeCallback = default, ArgumentPlaceholder <bool> shouldRollback = default, ArgumentPlaceholder <bool> commitIntention = default, ArgumentPlaceholder <bool> finishingStart = default) { // InitializationDone = initializationDone.Substitute(other.InitializationDone); RealTx = realTx.Substitute(other.RealTx); DisposeCallback = disposeCallback.Substitute(other.DisposeCallback); CompleteCallback = completeCallback.Substitute(other.CompleteCallback); ShouldRollback = shouldRollback.Substitute(other.ShouldRollback); CommitIntention = commitIntention.Substitute(other.CommitIntention); FinishingStart = finishingStart.Substitute(other.FinishingStart); }
public DescriptionPackageFileLoadContext( DescriptionPackageLocator locator, Uri fileUri, bool skipLinkedMetadata, string mediaType = default, Uri siteOrigin = default, XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext outerCtx = default) : base( locator: locator, loadUri: fileUri.Arg(nameof(fileUri)).EnsureAbsolute().EnsureFileScheme().EnsureLoopbackOrUnc().Value, skipLinkedMetadata: skipLinkedMetadata, mediaType: mediaType, siteOrigin: siteOrigin, fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, outerCtx: outerCtx) { }
public Pool( Func <IContext, Task <T> > itemFactory, bool ownsItem, TimeoutDuration itemPreferredSlidingTtl, int maxSize, string displayName = default, ArgumentPlaceholder <ILogger> logger = default) { // itemFactory.EnsureNotNull(nameof(itemFactory)); itemPreferredSlidingTtl.EnsureNotNull(nameof(itemPreferredSlidingTtl)); maxSize.Arg(nameof(maxSize)).EnsureNotLessThan(operand: 1); displayName.Arg(nameof(displayName)).EnsureNotEmpty().EnsureHasMaxLength(maxLength: Pool.DisplayNameMaxLength); // _itemFactory = itemFactory; _ownsFactoriedItem = ownsItem; ItemPreferredSlidingTtl = itemPreferredSlidingTtl; MaxSize = maxSize; P_MaxSizeMinusOne = maxSize - 1; DisplayName = displayName; _poolItems = ImmutableStack <ImmutableStackEntry <Leasable <T> > > .Empty; _logger = logger.Substitute(value: default);
/// <summary> /// Creates a new context using context class <typeparamref name="TContext"/> special constructor. /// <para>A special constructor must meet the following signature: (<see cref="XFullCorrelationId"/> fullCorrelationId, <see cref="ArgumentPlaceholder{XCorrelationId}"/> correlationId, <see cref="object"/> localTag, <see cref="IContext"/> outerCtx).</para> /// <para>Visibility level of a special constructor doesn't matter.</para> /// </summary> /// <typeparam name="TContext">Type of context to be created.</typeparam> /// <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> public static TContext Create <TContext>( 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) where TContext : class, IContext { // var ctx = ActivationUtilities .RequireConstructor <XFullCorrelationId, ArgumentPlaceholder <XCorrelationId>, object, IContext, TContext>() (arg1 : fullCorrelationId, arg2 : correlationId, arg3 : localTag, arg4 : 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 IContext New( this IContext outerCtx, IDataContext2 dataCtx, 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) { // var newCtx = default(IContext); try { newCtx = ContextUtilities.Create(outerCtx: outerCtx, fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, ct: ct, disposeRegistry: disposeRegistry, progress: progress, displayName: displayName); DataContextFlowContextProps.DataContextProp.SetLocalValue(ctx: newCtx, value: dataCtx); return(newCtx); } catch (Exception exception) { newCtx?.Dispose(exception); throw; } }
public Leasable(Func <IContext, Task <IVh <T> > > acquire, Func <IVh <T>, Task> release, TimeoutDuration preferredSlidingTtl, ArgumentPlaceholder <ILogger> logger = default) : base(preferredSlidingTtl : preferredSlidingTtl, logger : logger) { // acquire.EnsureNotNull(nameof(acquire)); release.EnsureNotNull(nameof(release)); // _acquire = acquire; _release = release; }
// TODO: Put strings into the resources. // public GenericContext(XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext outerCtx = default) { if (!(outerCtx is null)) { fullCorrelationId.Arg(nameof(fullCorrelationId)).EnsureIsNull(); }
public TriggerSignalProperties(ITrigger trigger, ITriggerSignalProperties source, ArgumentPlaceholder <DateTimeOffset> timestamp = default) { trigger.EnsureNotNull(nameof(trigger)); source.EnsureNotNull(nameof(source)); // _trigger = trigger; _source = source; _timestamp = timestamp.Substitute(value: source.Timestamp); _correlationId = source.CorrelationId; _explicitlyDefinedProps = timestamp.HasExplicitValue ? ExplicitlyDefinedProps.Timestamp : ExplicitlyDefinedProps.None; }
public Leasable(Func <IContext, Task <IVh <T> > > acquire, TimeoutDuration preferredSlidingTtl, ArgumentPlaceholder <ILogger> logger = default) : this(acquire : acquire, release : P_DefaultRelease, preferredSlidingTtl : preferredSlidingTtl, logger : logger) { }
protected SubjectLoadContextBase(Uri baseUri, string mediaType = default, Uri siteOrigin = default, XFullCorrelationId fullCorrelationId = default, ArgumentPlaceholder <XCorrelationId> correlationId = default, object localTag = default, IContext outerCtx = default) : base(fullCorrelationId: fullCorrelationId, correlationId: correlationId, localTag: localTag, outerCtx: outerCtx) { // SubjectLoadContextProps.SubjectLoadBaseUriProp.SetLocalValue(ctx: this, baseUri.Arg(nameof(baseUri))); SubjectLoadContextProps.SubjectLoadSiteOriginProp.SetLocalValue(ctx: this, siteOrigin is null ? baseUri.Arg(nameof(baseUri)) : siteOrigin.Arg(nameof(baseUri))); SubjectLoadContextProps.SubjectLoadMediaTypeProp.SetLocalValue(ctx: this, value: mediaType ?? MediaTypeNameUtilities.AppOctetStream); }
internal RunControlAttemptSuccess(IRunControlAttemptSuccess other, ArgumentPlaceholder <bool> isMaster = default) : this(props : other.EnsureNotNull(nameof(other)).Value, duration : other.Duration, isMaster : isMaster.Substitute(value : other.IsMaster)) { }
public Leasable(Func <IContext, Task <T> > acquire, bool ownsAcquired, TimeoutDuration preferredSlidingTtl, ArgumentPlaceholder <ILogger> logger = default) : this(acquire : P_GetAcquireDelegate(acquire : acquire, ownsAcquired : ownsAcquired), release : P_DefaultRelease, preferredSlidingTtl : preferredSlidingTtl, logger : logger) { }
public Leasable(Func <IVh <T> > acquire, Action <IVh <T> > release, TimeoutDuration preferredSlidingTtl, ArgumentPlaceholder <ILogger> logger = default) : this(acquire : P_GetAcquireDelegate(acquire : acquire), release : P_GetReleaseDelegate(release : release), preferredSlidingTtl : preferredSlidingTtl, logger : logger) { }