private void PopulateDetails(DataAccessor <DMSource> accessor, DMSource result) { accessor.DATA_MAP.ConnectionTypes.ForEach(connectionType => { Type managerType = RC.GetManagerType(connectionType); var method = managerType.GetMethod("GetByConnection", BindingFlags.NonPublic | BindingFlags.Instance); var connections = accessor.LoadConnections((connection) => connection.ParentID == result.ID, result, accessor.DATA_MAP.Connection(connectionType)); connections.ForEach(connection => { IList children = method.Invoke(RC.GetManager(connectionType), new object[] { connection }) as IList; IList items = accessor.DATA_MAP.Connection(connectionType).Property.GetValue(result) as IList; foreach (var child in children) { int index = items.FirstIndex <IDataModel>((value) => value.ID == (child as IDataModel).ID); if (index != -1) { items.RemoveAt(index); } items.Add(child); } }); }); }
private void ExicuteNextChain(PatchTypeEnum type, DataAccessor <DMSource> accessor, Type connectionType, DMSource model, IDataModel connectionModel) { switch (type.EnumValue) { case PatchTypeEnum.Enum.Create: { Type managerType = RC.GetManagerType(connectionType); var method = GetMethod(managerType, connectionType); method.Invoke(RC.GetManager(connectionType), new object[] { CommitTypeEnum.ADD, connectionModel, 0 }); accessor.CreateConnection(model, accessor.DATA_MAP.Connection(connectionType), connectionModel.ID); break; } case PatchTypeEnum.Enum.Update: { Type managerType = RC.GetManagerType(connectionType); var method = GetMethod(managerType, connectionType); method.Invoke(RC.GetManager(connectionType), new object[] { CommitTypeEnum.UPDATE, connectionModel, connectionModel.ID }); accessor.UpdateConnection(model, accessor.DATA_MAP.Connection(connectionType), connectionModel.ID); break; } case PatchTypeEnum.Enum.Delete: { Type managerType = RC.GetManagerType(connectionType); var method = GetMethod(managerType, connectionType); method.Invoke(RC.GetManager(connectionType), new object[] { CommitTypeEnum.REMOVE, connectionModel, connectionModel.ID }); accessor.DeleteConnection(model.GetConnectionID(connectionType, connectionModel.ID)); break; } default: break; } }