Beispiel #1
0
        /// <summary>
        ///     对<see cref="WorkResult" />对象进行深拷贝,会同时拷贝附加内容
        /// </summary>
        /// <param name="workResult"></param>
        /// <returns></returns>
        public static WorkResult DeepCopy(this WorkResult workResult)
        {
            var result = new WorkResult();

            foreach (var propertyName in workResult.PropertyNameList)
            {
                if (workResult.GetProperty(propertyName, out object obj))
                {
                    result.SetProperty(propertyName, obj);
                }
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        ///     对泛型<see cref="WorkResult" />对象进行深拷贝,会同时拷贝附加内容
        /// </summary>
        /// <param name="workResult"></param>
        /// <returns></returns>
        public static WorkResult <T> DeepCopy <T>(this WorkResult <T> workResult)
        {
            var result = new WorkResult <T>
            {
                Data = workResult.Data
            };

            foreach (var propertyName in workResult.PropertyNameList)
            {
                if (workResult.GetProperty(propertyName, out object obj))
                {
                    result.SetProperty(propertyName, obj);
                }
            }

            return(result);
        }
Beispiel #3
0
 /// <summary>
 ///     将<see cref="WorkResult" />转换为泛型对象
 /// </summary>
 /// <typeparam name="T">泛型类型</typeparam>
 /// <param name="workResult">待转换的<see cref="WorkResult" />对象</param>
 /// <param name="copyAttachedContent">是否拷贝附加内容</param>
 /// <returns></returns>
 public static WorkResult <T> ToWorkResult <T>(this WorkResult workResult, bool copyAttachedContent = true)
 {
     return(workResult.ToWorkResult <T>(default, copyAttachedContent));