Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        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]);
                }
            }
        }