public override IObjectsDataSet CloneDirtyObjects(IObjectsDataSet rootDataSet) { var clone = new GOUserGroupObjectsDataSet(rootDataSet as ObjectsDataSet); bool completed; foreach (var keyValue in this.GOUserGroupObjects.Where(o => o.Value.IsDirty || o.Value.IsMarkedForDeletion)) { var cloneObject = (GOUserGroupDataObject)keyValue.Value.Clone(false); cloneObject.InternalObjectId = keyValue.Value.InternalObjectId; completed = false; while (!completed) { completed = clone.GOUserGroupObjects.TryAdd(keyValue.Key, cloneObject); } } foreach (var keyValue in this.GOUserGroupObjectInternalIds .Where(o => this.GOUserGroupObjects[o.Value].IsDirty || this.GOUserGroupObjects[o.Value].IsMarkedForDeletion)) { completed = false; var count = 0; while (!completed && count++ < 15) { completed = clone.GOUserGroupObjectInternalIds.TryAdd(keyValue.Key.Clone(), keyValue.Value); } } // CloneDirtyObjects is used to pass only dirty objects to server to save changes. Since indexes are not serialized, no need to clone them return(clone); }
public override IObjectsDataSet Clone(IObjectsDataSet rootDataSet) { var clone = new GOUserGroupObjectsDataSet(rootDataSet as ObjectsDataSet); bool completed; foreach (var keyValue in this.GOUserGroupObjects) { var cloneObject = (GOUserGroupDataObject)keyValue.Value.Clone(false); cloneObject.InternalObjectId = keyValue.Value.InternalObjectId; completed = false; var count = 0; while (!completed && count++ < 15) { completed = clone.GOUserGroupObjects.TryAdd(keyValue.Key, cloneObject); } } foreach (var keyValue in this.GOUserGroupObjectInternalIds) { completed = false; var count = 0; while (!completed && count++ < 15) { completed = clone.GOUserGroupObjectInternalIds.TryAdd(keyValue.Key.Clone(), keyValue.Value); } } foreach (var fkKeyValue in this.Group_FKIndex) { var iscompleted = false; var count2 = 0; while (!iscompleted && count2++ < 15) { iscompleted = clone.Group_FKIndex.TryAdd(fkKeyValue.Key, new List <int>()); } foreach (var pk in fkKeyValue.Value) { clone.Group_FKIndex[fkKeyValue.Key].Add(pk); } } foreach (var fkKeyValue in this.User_FKIndex) { var iscompleted = false; var count2 = 0; while (!iscompleted && count2++ < 15) { iscompleted = clone.User_FKIndex.TryAdd(fkKeyValue.Key, new List <int>()); } foreach (var pk in fkKeyValue.Value) { clone.User_FKIndex[fkKeyValue.Key].Add(pk); } } return(clone); }