/// <summary> /// Checks if something in the Arary has changed, if yes, stores the change /// </summary> /// <param name="nnoi1"> The first Object meta representation (nnoi = NonNativeObjectInfo) </param> /// <param name="nnoi2"> The second object meta representation </param> /// <param name="fieldId"> The field index that this collection represents </param> /// <param name="aoi1"> The Meta representation of the array 1 (aoi = ArraybjectInfo) </param> /// <param name="aoi2"> The Meta representation of the array 2 </param> /// <param name="objectRecursionLevel"> </param> /// <returns> true if the 2 array representations are different </returns> private bool ManageArrayChanges(NonNativeObjectInfo nnoi1, NonNativeObjectInfo nnoi2, int fieldId, ArrayObjectInfo aoi1, ArrayObjectInfo aoi2, int objectRecursionLevel) { var array1 = aoi1.GetArray(); var array2 = aoi2.GetArray(); if (array1.Length != array2.Length) { var buffer = new StringBuilder(); buffer.Append("Array size has changed oldsize=").Append(array1.Length).Append("/newsize=").Append( array2.Length); StoreChangedObject(nnoi1, nnoi2, fieldId, aoi1, aoi2, buffer.ToString(), objectRecursionLevel); return(true); } for (var i = 0; i < array1.Length; i++) { var value1 = (AbstractObjectInfo)array1[i]; var value2 = (AbstractObjectInfo)array2[i]; var localHasChanged = HasChanged(value1, value2, objectRecursionLevel); if (!localHasChanged) { continue; } _nbChanges++; return(true); } return(false); }
/// <summary>Checks if something in the Arary has changed, if yes, stores the change</summary> /// <param name="nnoi1"> /// The first Object meta representation (nnoi = /// NonNativeObjectInfo) /// </param> /// <param name="nnoi2">The second object meta representation</param> /// <param name="fieldIndex">The field index that this collection represents</param> /// <param name="aoi1">The Meta representation of the array 1 (aoi = ArraybjectInfo)</param> /// <param name="aoi2">The Meta representation of the array 2</param> /// <param name="objectRecursionLevel"></param> /// <returns>true if the 2 array representations are different</returns> private bool ManageArrayChanges(NonNativeObjectInfo nnoi1, NonNativeObjectInfo nnoi2, int fieldId , ArrayObjectInfo aoi1, ArrayObjectInfo aoi2, int objectRecursionLevel) { object[] array1 = aoi1.GetArray(); object[] array2 = aoi2.GetArray(); if (array1.Length != array2.Length) { System.Text.StringBuilder buffer = new System.Text.StringBuilder(); buffer.Append("Array size has changed oldsize=").Append(array1.Length).Append("/newsize=" ).Append(array2.Length); StoreChangedObject(nnoi1, nnoi2, fieldId, aoi1, aoi2, buffer.ToString(), objectRecursionLevel ); supportInPlaceUpdate = false; return(true); } AbstractObjectInfo value1 = null; AbstractObjectInfo value2 = null; // check if this array supports in place update bool localSupportInPlaceUpdate = ODBType.HasFixSize (aoi2.GetComponentTypeId()); int index = 0; bool hasChanged = false; try { for (int i = 0; i < array1.Length; i++) { value1 = (AbstractObjectInfo)array1[i]; value2 = (AbstractObjectInfo)array2[i]; bool localHasChanged = this.HasChanged(value1, value2, objectRecursionLevel); if (localHasChanged) { StoreArrayChange(nnoi1, fieldId, i, value2, localSupportInPlaceUpdate); if (localSupportInPlaceUpdate) { hasChanged = true; } else { hasChanged = true; return(hasChanged); } } index++; } } finally { if (hasChanged && !localSupportInPlaceUpdate) { supportInPlaceUpdate = false; } } return(hasChanged); }
/// <summary> /// Builds an instance of an array /// </summary> private object BuildArrayInstance(ArrayObjectInfo aoi) { // first check if array element type is native (int,short, for example) var type = OdbType.GetFromName(aoi.GetRealArrayComponentClassName()); var arrayClazz = type.GetNativeClass(); object array = Array.CreateInstance(arrayClazz, aoi.GetArray().Length); for (var i = 0; i < aoi.GetArrayLength(); i++) { var abstractObjectInfo = (AbstractObjectInfo)aoi.GetArray()[i]; if (abstractObjectInfo == null || abstractObjectInfo.IsDeletedObject() || abstractObjectInfo.IsNull()) { continue; } var instance = BuildOneInstance(abstractObjectInfo); ((Array)array).SetValue(instance, i); } return(array); }
/// <summary>Builds an instance of an array</summary> public virtual object BuildArrayInstance(ArrayObjectInfo aoi) { // first check if array element type is native (int,short, for example) ODBType type = ODBType.GetFromName(aoi.GetRealArrayComponentClassName()); System.Type arrayClazz = type.GetNativeClass(); object array = System.Array.CreateInstance(arrayClazz, aoi.GetArray().Length); object o = null; AbstractObjectInfo aboi = null; for (int i = 0; i < aoi.GetArrayLength(); i++) { aboi = (AbstractObjectInfo)aoi.GetArray()[i]; if (aboi != null && !aboi.IsDeletedObject() && !aboi.IsNull()) { o = BuildOneInstance(aboi); ((Array)array).SetValue(o, i); } } return(array); }
/// <summary> /// Checks if something in the Arary has changed, if yes, stores the change /// </summary> /// <param name="nnoi1"> The first Object meta representation (nnoi = NonNativeObjectInfo) </param> /// <param name="nnoi2"> The second object meta representation </param> /// <param name="fieldId"> The field index that this collection represents </param> /// <param name="aoi1"> The Meta representation of the array 1 (aoi = ArraybjectInfo) </param> /// <param name="aoi2"> The Meta representation of the array 2 </param> /// <param name="objectRecursionLevel"> </param> /// <returns> true if the 2 array representations are different </returns> private bool ManageArrayChanges(NonNativeObjectInfo nnoi1, NonNativeObjectInfo nnoi2, int fieldId, ArrayObjectInfo aoi1, ArrayObjectInfo aoi2, int objectRecursionLevel) { var array1 = aoi1.GetArray(); var array2 = aoi2.GetArray(); if (array1.Length != array2.Length) { var buffer = new StringBuilder(); buffer.Append("Array size has changed oldsize=").Append(array1.Length).Append("/newsize=").Append( array2.Length); StoreChangedObject(nnoi1, nnoi2, fieldId, aoi1, aoi2, buffer.ToString(), objectRecursionLevel); return true; } for (var i = 0; i < array1.Length; i++) { var value1 = (AbstractObjectInfo) array1[i]; var value2 = (AbstractObjectInfo) array2[i]; var localHasChanged = HasChanged(value1, value2, objectRecursionLevel); if (!localHasChanged) continue; _nbChanges++; return true; } return false; }