/// <summary> /// 异步获取创建者。 /// </summary> /// <typeparam name="TUpdatedBy">指定的创建者类型(提供对整数、字符串、GUID 等类型的支持)。</typeparam> /// <param name="updator">给定的 <see cref="IUpdator{TUpdatedBy}"/>。</param> /// <param name="newUpdatedByFactory">给定的新创建者工厂方法。</param> /// <param name="cancellationToken">给定的 <see cref="CancellationToken"/>(可选)。</param> /// <returns>返回一个包含 <typeparamref name="TUpdatedBy"/>(兼容标识或字符串)的异步操作。</returns> public static async ValueTask <TUpdatedBy?> SetUpdatedByAsync <TUpdatedBy>(this IUpdator <TUpdatedBy> updator, Func <TUpdatedBy?, TUpdatedBy?> newUpdatedByFactory, CancellationToken cancellationToken = default) where TUpdatedBy : IEquatable <TUpdatedBy> { await updator.SetCreatedByAsync(newUpdatedByFactory, cancellationToken).DisableAwaitContext(); return(updator.UpdatedBy = newUpdatedByFactory(updator.UpdatedBy)); }
///// <summary> ///// 填充创建属性(支持日期时间为可空类型)。 ///// </summary> ///// <exception cref="ArgumentNullException"> ///// <paramref name="updation"/> is null. ///// </exception> ///// <typeparam name="TUpdation">指定的创建类型。</typeparam> ///// <param name="updation">给定的 <typeparamref name="TUpdation"/>。</param> ///// <param name="newUpdatedTime">给定的新创建日期对象(可选)。</param> ///// <param name="newUpdatedBy">给定的新创建者对象。</param> ///// <returns>返回 <typeparamref name="TUpdation"/>。</returns> //public static TUpdation PopulateUpdation<TUpdation>(this TUpdation updation, // object newUpdatedBy, object? newUpdatedTime = null) // where TUpdation : IObjectUpdation //{ // updation.PopulateCreation(newUpdatedBy, newUpdatedTime); // if (newUpdatedTime.IsNotNull()) // updation.SetObjectUpdatedTime(newUpdatedTime); // updation.SetObjectUpdatedBy(newUpdatedBy); // return updation; //} ///// <summary> ///// 异步填充创建属性(支持日期时间为可空类型)。 ///// </summary> ///// <exception cref="ArgumentNullException"> ///// <paramref name="updation"/> is null. ///// </exception> ///// <typeparam name="TUpdation">指定的创建类型。</typeparam> ///// <param name="updation">给定的 <typeparamref name="TUpdation"/>。</param> ///// <param name="newUpdatedBy">给定的新创建者对象。</param> ///// <param name="newUpdatedTime">给定的新创建日期对象(可选)。</param> ///// <param name="cancellationToken">给定的 <see cref="CancellationToken"/>(可选)。</param> ///// <returns>返回一个包含 <typeparamref name="TUpdation"/> 的异步操作。</returns> //public static async Task<TUpdation> PopulateUpdationAsync<TUpdation>(this TUpdation updation, // object? newUpdatedBy, object? newUpdatedTime = null, CancellationToken cancellationToken = default) // where TUpdation : IObjectUpdation //{ // await updation.PopulateCreationAsync(newUpdatedBy, newUpdatedTime) // .ConfigureAwait(); // if (newUpdatedTime.IsNotNull()) // { // await updation.SetObjectUpdatedTimeAsync(newUpdatedTime, cancellationToken) // .ConfigureAwaitWithoutContext(); // } // await updation.SetObjectUpdatedByAsync(newUpdatedBy, cancellationToken) // .ConfigureAwaitWithoutContext(); // return updation; //} #endregion #region IUpdator<TUpdatedBy> /// <summary> /// 获取创建者。 /// </summary> /// <typeparam name="TUpdatedBy">指定的创建者类型(提供对整数、字符串、GUID 等类型的支持)。</typeparam> /// <param name="updator">给定的 <see cref="IUpdator{TUpdatedBy}"/>。</param> /// <param name="newUpdatedByFactory">给定的新创建者工厂方法。</param> /// <returns>返回 <typeparamref name="TUpdatedBy"/>(兼容标识或字符串)。</returns> public static TUpdatedBy?SetUpdatedBy <TUpdatedBy>(this IUpdator <TUpdatedBy> updator, Func <TUpdatedBy?, TUpdatedBy?> newUpdatedByFactory) where TUpdatedBy : IEquatable <TUpdatedBy> { updator.SetCreatedBy(newUpdatedByFactory); return(updator.UpdatedBy = newUpdatedByFactory(updator.UpdatedBy)); }