public T Scramble <T>(T objectToScramble, ScrambleMap scrambleMap) { var props = objectToScramble.GetType().GetProperties(); ScrambleObjectProperties(objectToScramble, props, scrambleMap); return(objectToScramble); }
public T Scramble <T>(T objectToScramble, Action <ScrambleMap> scrambleMapConfigurator) { var props = objectToScramble.GetType().GetProperties(); var scrambleMap = new ScrambleMap(); scrambleMapConfigurator?.Invoke(scrambleMap); ScrambleObjectProperties(objectToScramble, props, scrambleMap); return(objectToScramble); }
public IEnumerable <T> ScrambleEnumerable <T>(IEnumerable <T> collectionToScramble, Action <ScrambleMap> scrambleMapConfigurator) { var scrambleMap = new ScrambleMap(); scrambleMapConfigurator?.Invoke(scrambleMap); foreach (var objectToScramble in collectionToScramble) { Scramble(objectToScramble, scrambleMap); } return(collectionToScramble); }
public void RegisterMap(string key, ScrambleMap map) { RegisteredMaps[key] = map; }
public IEnumerable <T> ScrambleEnumerable <T>(IEnumerable <T> collectionToScramble, ScrambleMap scrambleMap) { foreach (var objectToScramble in collectionToScramble) { Scramble(objectToScramble, scrambleMap); } return(collectionToScramble); }
private void UnscrambleObjectProperties <T>(T objectToUnscramble, PropertyInfo[] props, ScrambleMap scrambleMap) { foreach (var prop in props) { var replaceCondition = scrambleMap.FindReplaceCondition(prop.Name); if (replaceCondition?.ReplaceValue.Equals(prop.GetValue(objectToUnscramble)) ?? false) { prop.SetValue(objectToUnscramble, replaceCondition.ConditonValue); } else if (scrambleMap.HasCustomScrambler(prop.PropertyType)) { var customeScrambler = scrambleMap.GetCustomScrambler(prop.PropertyType); customeScrambler.UnscrambleValue(objectToUnscramble, prop); } } }
private void ScrambleObjectProperties <T>(T objectToScramble, PropertyInfo[] props, ScrambleMap scrambleMap) { for (int i = 0; i < props.Length; i++) { var replaceCondition = scrambleMap.FindReplaceCondition(props[i].Name); if (replaceCondition?.ConditonValue.Equals(props[i].GetValue(objectToScramble)) ?? false) { props[i].SetValue(objectToScramble, replaceCondition.ReplaceValue); } else if (scrambleMap.HasCustomScrambler(props[i].PropertyType)) { var customScrambler = scrambleMap.GetCustomScrambler(props[i].PropertyType); customScrambler.ScrambleValue(objectToScramble, props[i]); } } }