コード例 #1
0
        public ProcessResult Process(ElementNode node, ProcessContext context = null,
                                     Dictionary <string, object> settings     = null)
        {
            if (string.IsNullOrEmpty(node?.Value?.ToString()))
            {
                return(new ProcessResult());
            }

            if (node.IsDateNode())
            {
                return(DateTimeUtility.RedactDateNode(node, EnablePartialDatesForRedact));
            }

            if (node.IsDateTimeNode() || node.IsInstantNode())
            {
                return(DateTimeUtility.RedactDateTimeAndInstantNode(node, EnablePartialDatesForRedact));
            }

            if (node.IsAgeDecimalNode())
            {
                return(DateTimeUtility.RedactAgeDecimalNode(node, EnablePartialAgesForRedact));
            }

            if (node.IsPostalCodeNode())
            {
                return(PostalCodeUtility.RedactPostalCode(node, EnablePartialZipCodesForRedact,
                                                          RestrictedZipCodeTabulationAreas));
            }

            node.Value = null;
            var result = new ProcessResult();

            result.AddProcessRecord(AnonymizationOperations.Redact, node);
            return(result);
        }
コード例 #2
0
        public static ProcessResult RedactPostalCode(ElementNode node, bool enablePartialZipCodesForRedact = false, List <string> restrictedZipCodeTabulationAreas = null)
        {
            var processResult = new ProcessResult();

            if (!node.IsPostalCodeNode() || string.IsNullOrEmpty(node?.Value?.ToString()))
            {
                return(processResult);
            }

            if (enablePartialZipCodesForRedact)
            {
                if (restrictedZipCodeTabulationAreas != null && restrictedZipCodeTabulationAreas.Any(x => node.Value.ToString().StartsWith(x)))
                {
                    node.Value = new string(s_replacementDigit, node.Value.ToString().Length);
                }
                else if (node.Value.ToString().Length >= s_initialDigitsCount)
                {
                    node.Value = $"{node.Value.ToString().Substring(0, s_initialDigitsCount)}{new string(s_replacementDigit, node.Value.ToString().Length - s_initialDigitsCount)}";
                }
                processResult.AddProcessRecord(AnonymizationOperations.Abstract, node);
            }
            else
            {
                node.Value = null;
                processResult.AddProcessRecord(AnonymizationOperations.Redact, node);
            }

            return(processResult);
        }
コード例 #3
0
 public void Process(ElementNode node)
 {
     if (node.IsDateNode())
     {
         DateTimeUtility.RedactDateNode(node, EnablePartialDatesForRedact);
     }
     else if (node.IsDateTimeNode() || node.IsInstantNode())
     {
         DateTimeUtility.RedactDateTimeAndInstantNode(node, EnablePartialDatesForRedact);
     }
     else if (node.IsAgeDecimalNode())
     {
         DateTimeUtility.RedactAgeDecimalNode(node, EnablePartialAgesForRedact);
     }
     else if (node.IsPostalCodeNode())
     {
         PostalCodeUtility.RedactPostalCode(node, EnablePartialZipCodesForRedact, RestrictedZipCodeTabulationAreas);
     }
     else
     {
         node.Value = null;
     }
 }
コード例 #4
0
        public static void RedactPostalCode(ElementNode node, bool enablePartialZipCodesForRedact = false, List <string> restrictedZipCodeTabulationAreas = null)
        {
            if (!node.IsPostalCodeNode())
            {
                return;
            }

            if (enablePartialZipCodesForRedact)
            {
                if (restrictedZipCodeTabulationAreas != null && restrictedZipCodeTabulationAreas.Any(x => node.Value.ToString().StartsWith(x)))
                {
                    node.Value = new string(s_replacementDigit, node.Value.ToString().Length);
                }
                else if (node.Value.ToString().Length >= s_initialDigitsCount)
                {
                    node.Value = $"{node.Value.ToString().Substring(0, s_initialDigitsCount)}{new string(s_replacementDigit, node.Value.ToString().Length - s_initialDigitsCount)}";
                }
            }
            else
            {
                node.Value = null;
            }
        }