Source/NFX/DataAccess/CRUD/Row.cs
/// <summary>
/// Copies fields from this row into another row/form.
/// Note: this is  shallow copy, as field values for complex types are just copied over
/// </summary>
Copies fields from this row into another row/form.
Note: this is  shallow copy, as field values for complex types are just copied over
Copies fields from this row into another row / form . Note : this is shallow copy as field values for complex types are just copied over
public void CopyFields(Row other,
                                   bool includeAmorphousData = true,
                                   bool invokeAmorphousAfterLoad = true,
                                   Func<string, Schema.FieldDef, bool> fieldFilter = null,
                                   Func<string, string, bool> amorphousFieldFilter = null)
            {
              if (other==null || object.ReferenceEquals(this, other)) return;
              var target = this is FormModel ? ((FormModel)this).DataStoreTargetName : string.Empty;
              var oad = includeAmorphousData ? other as IAmorphousData : null;
              if (oad!=null && this is IAmorphousData)
              {
               var athis = (IAmorphousData)this;
               if (oad.AmorphousDataEnabled && athis.AmorphousDataEnabled)
               {
                 foreach(var kvp in athis.AmorphousData)
                 {
                   if (amorphousFieldFilter!=null && !amorphousFieldFilter(target, kvp.Key)) continue;
                   var ofd = other.Schema[kvp.Key];
                   if (ofd!=null)
                   {
                     try
                     {
                       if (!isFieldDefLoaded(target, ofd)) continue;
                       other.SetFieldValue(ofd, kvp.Value);
                       continue;
                     }catch{} 
                   }
                   oad.AmorphousData[kvp.Key] = kvp.Value;
                 }
               }
              }
              foreach(var fdef in this.Schema)
              {
                if (fieldFilter!=null && !fieldFilter(target, fdef)) continue;
                if (!isFieldDefLoaded(target, fdef)) continue;
                var ofd = other.Schema[fdef.Name];
                if (ofd==null)
                {
                  if (oad!=null && oad.AmorphousDataEnabled)
                  {
                    oad.AmorphousData[fdef.Name] = GetFieldValue(fdef);
                  }
                  continue;
                }
                other.SetFieldValue(ofd, GetFieldValue(fdef));
              }
              if (oad!=null && oad.AmorphousDataEnabled && invokeAmorphousAfterLoad)
                oad.AfterLoad( target );
            }
public void CopyFields ( Row other , bool includeAmorphousData = true , bool invokeAmorphousAfterLoad = true , Func < string , Schema . FieldDef , bool > fieldFilter = null , Func < string , string , bool > amorphousFieldFilter = null ) { if ( other == null || object . ReferenceEquals ( this , other ) ) return ; var target = this is FormModel ? ( ( FormModel ) this ) . DataStoreTargetName : string . Empty ; var oad = includeAmorphousData ? other as IAmorphousData : null ; if ( oad != null && this is IAmorphousData ) { var athis = ( IAmorphousData ) this ; if ( oad . AmorphousDataEnabled && athis . AmorphousDataEnabled ) { foreach ( var kvp in athis . AmorphousData ) { if ( amorphousFieldFilter != null && ! amorphousFieldFilter ( target , kvp . Key ) ) continue ; var ofd = other . Schema [ kvp . Key ] ; if ( ofd != null ) { try { if ( ! isFieldDefLoaded ( target , ofd ) ) continue ; other . SetFieldValue ( ofd , kvp . Value ) ; continue ; } catch { } } oad . AmorphousData [ kvp . Key ] = kvp . Value ; } } } foreach ( var fdef in this . Schema ) { if ( fieldFilter != null && ! fieldFilter ( target , fdef ) ) continue ; if ( ! isFieldDefLoaded ( target , fdef ) ) continue ; var ofd = other . Schema [ fdef . Name ] ; if ( ofd == null ) { if ( oad != null && oad . AmorphousDataEnabled ) { oad . AmorphousData [ fdef . Name ] = GetFieldValue ( fdef ) ; } continue ; } other . SetFieldValue ( ofd , GetFieldValue ( fdef ) ) ; } if ( oad != null && oad . AmorphousDataEnabled && invokeAmorphousAfterLoad ) oad . AfterLoad ( target ) ; }
Copies fields from this row into another row/form.
Copies fields from this row into another row / form .
//only copy IF amorphous behavior is enabled here and in the destination //this may be impossible, then we assign to amorphous in other // IF amorphous behavior is enabled in destination //foreach
other
Row
includeAmorphousData
bool
invokeAmorphousAfterLoad
bool
fieldFilter
Func<string, Schema.FieldDef, bool>
amorphousFieldFilter
Func<string, string, bool>