/// <summary> /// Create a FieldTransfer for a specific set of fields. The fields can be from /// different Types, so long as all Types declaring the given fields are in the same /// inheritance chain. The most-derived Type from all presented fields will be used as /// the requirement for objects passed to the Transfer method. /// /// If the fields are from two separate inheritance chains, an exception will be thrown. /// </summary> /// <param name="_fields">The fields to transfer between objects</param> /// <returns>A FieldTransfer object for the given fields</returns> public static CFieldTransfer CreateFromFields(IEnumerable <FieldInfo> _fields) { var ft = new CFieldTransfer(); var typ = GetCommonType(_fields); ft.CreateCopier(typ, _fields); return(ft); }
/// <summary> /// Create a FieldTransfer object for a particular type /// </summary> /// <param name="_type"> /// The Type to create a transfor object for. Will include all instance fields in this /// Type and any superclasses, both public and private. /// </param> /// <returns>A FieldTransfer object for the given Type</returns> public static CFieldTransfer CreateFromType(Type _type) { var ft = new CFieldTransfer(); var fields = _type.GetAllFields(); ft.CreateCopier(_type, fields); return(ft); }
/// <summary> /// Create a FieldTransfer object for a particular type /// </summary> /// <typeparam name="T"> /// The Type to create a transfor object for. Will include all instance fields in this /// Type and any superclasses, both public and private. /// </typeparam> /// <returns>A FieldTransfer object for the given Type</returns> public static CFieldTransfer CreateFromType <T>() { var ft = new CFieldTransfer(); var typ = typeof(T); var fields = typ.GetAllFields(); ft.CreateCopier(typ, fields); return(ft); }