public static async Task <IPublication <TPublishedBy> > PopulatePublicationAsync <TPublishedBy> (this IPublication <TPublishedBy> publication, IClockService clock, CancellationToken cancellationToken = default) where TPublishedBy : IEquatable <TPublishedBy> { await publication.PopulateCreationAsync(clock, cancellationToken) .ConfigureAwait(); publication.PublishedTime = publication.CreatedTime; publication.PublishedTimeTicks = publication.CreatedTimeTicks; return(publication); }
/// <summary> /// 异步填充创建属性。 /// </summary> /// <typeparam name="TPublishedBy">指定的创建者类型(提供对整数、字符串、GUID 等类型的支持)。</typeparam> /// <param name="publication">给定的 <see cref="IPublication{TPublishedBy}"/>。</param> /// <param name="newPublishedBy">给定的新创建者。</param> /// <param name="newPublishedTime">给定的新创建日期。</param> /// <param name="cancellationToken">给定的 <see cref="CancellationToken"/>(可选)。</param> /// <returns>返回一个包含 <see cref="IPublication{TPublishedBy}"/> 的异步操作。</returns> public static async Task <IPublication <TPublishedBy> > PopulatePublicationAsync <TPublishedBy>(this IPublication <TPublishedBy> publication, TPublishedBy?newPublishedBy, DateTimeOffset newPublishedTime, CancellationToken cancellationToken = default) where TPublishedBy : IEquatable <TPublishedBy> { await publication.PopulateCreationAsync <TPublishedBy>(newPublishedBy, newPublishedTime, cancellationToken) .DisableAwaitContext(); publication.PublishedTime = newPublishedTime; publication.PublishedTimeTicks = publication.PublishedTime.Ticks; publication.PublishedBy = newPublishedBy; return(publication); }