//holding in a form such as List <EDOID>, not as List<string>, makes it possible to identify whether the ID of any part. It would be easier to debug. private static void CollectIds(IIDPropertiesProvider obj, List <string> ids) { foreach (string propertyName in obj.IdProperties) { string id = (string)PropertyPathHelper.GetValue(obj, propertyName); ids.Add(id); } }
private static void RenameIds(IIDPropertiesProvider obj, List <string> ids, Action <RenameResult> action) { foreach (string propertyName in obj.IdProperties) { RenameResult result = RenameId(obj, propertyName, ids); if (result.IsIdPropertyRenamed && action != null) { action(result); } } }
private static RenameResult RenameId(IIDPropertiesProvider obj, string propertyName, List <string> ids) { RenameResult result = new RenameResult(propertyName); string id = (string)PropertyPathHelper.GetValue(obj, propertyName); if (ids.Contains(id)) { string newId = IDUtils.NewGuid(); PropertyPathHelper.SetValue(obj, propertyName, newId); result.OldId = id; result.NewId = newId; return(result); } return(result); }
private static void RenameIds(IIDPropertiesProvider obj, List <string> ids) { RenameIds(obj, ids, null); }