/// <summary> /// Converts the specified object to an object of another class. /// </summary> /// <typeparam name="T">The type of the target to convert to.</typeparam> /// <param name="target">The target object to convert to.</param> /// <param name="source">The object to convert.</param> public static T Pack <T>(T target, object source) where T : new() { // allow null if (source == null) { return(target); } return(ClassConverter.SetClass(target, source)); }
/// <summary> /// Converts the specified object to an object of another class. /// </summary> /// <typeparam name="T">The type of the target to convert to.</typeparam> /// <param name="source">The object to convert.</param> public static T Pack <T>(object source) where T : new() { // allow null if (source == null) { return(default(T)); } var target = new T(); ClassConverter.SetClass(target, source); return(target); }
/// <summary> /// Copy data from the source object into the row. /// </summary> /// <typeparam name="T">The type of the row.</typeparam> /// <param name="target">The target row object.</param> /// <param name="source">The source object.</param> public static T Pack <T>(this T target, object source) where T : DbRow { if (target == null) { throw new QueryTalkException("extensions.Pack<T>", QueryTalkExceptionType.ArgumentNull, "target = null", Text.Method.Pack); } if (source == null) { throw new QueryTalkException("extensions.Pack<T>", QueryTalkExceptionType.ArgumentNull, "source = null", Text.Method.Pack); } if (source != null) { return(ClassConverter.SetClass <T>(target, source)); } return(target); }