private static object RedactSingleOrListValue(object original, MethodInfo redactor, PiiMap piiMap) { IList list = original as IList; if (list != null) { bool flag = list is MultiValuedPropertyBase; if (list.IsReadOnly) { if (!flag) { return(null); } ((MultiValuedPropertyBase)list).SetIsReadOnly(false, null); } for (int i = 0; i < list.Count; i++) { object value = SuppressingPiiProperty.RedactSingleValue(list[i], redactor, piiMap); if (flag && !(original is ProxyAddressCollection)) { list.RemoveAt(i); list.Insert(i, value); } else { list[i] = value; } } } else { original = SuppressingPiiProperty.RedactSingleValue(original, redactor, piiMap); } return(original); }
public static string Initialize(string redactionConfigFile) { string result; using (StreamReader streamReader = new StreamReader(redactionConfigFile)) { result = SuppressingPiiProperty.Initialize(streamReader); } return(result); }
private object InternalSuppressPii(PropertyDefinition propertyDefinition, object value) { if (SuppressingPiiContext.NeedPiiSuppression) { bool skipPiiRedaction; using (SuppressingPiiContext.Create(false, null)) { skipPiiRedaction = this.SkipPiiRedaction; } if (!skipPiiRedaction) { value = SuppressingPiiProperty.TryRedact(propertyDefinition, value, SuppressingPiiContext.PiiMap); } } return(value); }
public static object TryRedact(PropertyDefinition property, object original, PiiMap piiMap) { if (original == null) { return(original); } if (!SuppressingPiiProperty.Initialized || SuppressingPiiProperty.piiDataRedaction == null) { Type type = original.GetType(); if (type.IsValueType) { return(Activator.CreateInstance(type)); } return(null); } else { if (!SuppressingPiiProperty.piiDataRedaction.Enable) { return(original); } object result = original; MethodInfo redactor; if (SuppressingPiiProperty.piiDataRedaction.TryGetRedactor(property, out redactor)) { if (piiMap != null && !SuppressingPiiProperty.piiDataRedaction.NeedAddIntoPiiMap(property, original)) { piiMap = null; } if (property.Type.IsArray) { result = SuppressingPiiProperty.RedactArray(original, redactor, piiMap); } else { result = SuppressingPiiProperty.RedactSingleOrListValue(original, redactor, piiMap); } } return(result); } }
public static T TryRedactValue <T>(PropertyDefinition property, T original) { return((T)((object)SuppressingPiiProperty.TryRedact(property, original, null))); }
public static object TryRedact(PropertyDefinition property, object original) { return(SuppressingPiiProperty.TryRedact(property, original, null)); }