NumberRollup API
API function
.NET:
decimal HushHush.MaskingLogic.SSRS.Mask.NumberRollup(decimal data, string rangesConfiguration, decimal defaultReplacement, RollupConfigurationFormat format = RollupConfigurationFormat.Xml)
Expected input
data: value to be masked.
rangesConfiguration: proper rollup ranges in XML or CSV format.
defaultReplacement: default replacement for values not covered by rollup ranges.
format: RollupConfigurationFormat.Xml (default) or RollupConfigurationFormat.Csv. Selects whether rangesConfiguration is XML or CSV.
Expected output
Masked numeric value
Error handling
InvalidOperationException when the rollup configuration is invalid. For XML (“There is an error in XML document”), the details are in the inner exception. For CSV, the message names the row and column of each problem, and ArgumentException is thrown when the configuration is null or empty. An empty XML configuration is not an error: every value gets defaultReplacement. The message does not include the value being masked.
Examples
string rangesXML =
"<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
"<ArrayOfRollupOfDecimal xmlns:xsi=" +
"\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
" <RollupOfDecimal>" +
" <Replacement>" +
" <decimal>235</decimal>" +
" </Replacement>" +
" <Filter type=\"Range\">" +
" <RangeRollupFilterOfDecimal>" +
" <Min>300</Min>" +
" <Max>500</Max>" +
" </RangeRollupFilterOfDecimal>" +
" </Filter>" +
" <MatchValues />" +
" </RollupOfDecimal>" +
" <RollupOfDecimal>" +
" <Replacement>" +
" <decimal>125</decimal>" +
" </Replacement>" +
" <Filter type=\"Range\">" +
" <RangeRollupFilterOfDecimal>" +
" <Min>100</Min>" +
" <Max>299</Max>" +
" </RangeRollupFilterOfDecimal>" +
" </Filter>" +
" <MatchValues />" +
" </RollupOfDecimal>" +
"</ArrayOfRollupOfDecimal>";
HushHush.MaskingLogic.SSRS.Mask.NumberRollup(117, rangesXML, 0) // 125
HushHush.MaskingLogic.SSRS.Mask.NumberRollup(345, rangesXML, 0) // 235
HushHush.MaskingLogic.SSRS.Mask.NumberRollup(12345, rangesXML, 0) // 0
Note: XML written by earlier versions using the full assembly-qualified type value still loads correctly.
using HushHush.MaskingLogic.Helpers; // for RollupConfigurationFormat
string rangesCsv = "Min,Max,Replacement" + System.Environment.NewLine + "300,500,235" + System.Environment.NewLine + "100,299,125";
HushHush.MaskingLogic.SSRS.Mask.NumberRollup(117, rangesCsv, 0, RollupConfigurationFormat.Csv) // 125
HushHush.MaskingLogic.SSRS.Mask.NumberRollup(345, rangesCsv, 0, RollupConfigurationFormat.Csv) // 235
HushHush.MaskingLogic.SSRS.Mask.NumberRollup(12345, rangesCsv, 0, RollupConfigurationFormat.Csv) // 0
Note: The first row is a header: Min,Max,Replacement. One range per line.
API Reference: Number Rollup