HumanReadableSerializerScrubExtensions Class
Provides extension methods for scrubbing values during serialization with HumanReadableSerializerOptions.
public static class HumanReadableSerializerScrubExtensionsMethods
| Name | Description |
|---|---|
| ScrubGuid(HumanReadableSerializerOptions) | Scrubs GUID values by replacing them with deterministic values based on their order of appearance. |
| ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, string?>) | Scrubs JSON values matching the specified JSONPath expression, returning a string value. |
| ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, JsonNode?>) | Scrubs JSON values matching the specified JSONPath expression, returning a JSON node. |
| ScrubValue<T>(HumanReadableSerializerOptions) | Scrubs values of type T by replacing them with deterministic values like "TypeName_0", "TypeName_1", etc. |
| ScrubValue<T>(HumanReadableSerializerOptions, IEqualityComparer<T>?) | Scrubs values of type T by replacing them with deterministic values, using the specified comparer to determine uniqueness. |
| ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>) | Scrubs values of type T by replacing them with the result of the specified scrubber function that receives the value and its index. |
| ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>, IEqualityComparer<T>?) | Scrubs values of type T by replacing them with the result of the specified scrubber function, using the specified comparer to determine uniqueness. |
| ScrubValue<T>(HumanReadableSerializerOptions, Func<T, string>) | Scrubs values of type T by replacing them with the result of the specified scrubber function. |
| ScrubXmlAttribute(HumanReadableSerializerOptions, string, Func<XAttribute, string?>) | Scrubs XML attributes matching the specified XPath expression. |
| ScrubXmlAttribute(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XAttribute, string?>) | Scrubs XML attributes matching the specified XPath expression with namespace resolution. |
| ScrubXmlNode(HumanReadableSerializerOptions, string, Action<XNode>) | Scrubs XML nodes matching the specified XPath expression using an action. |
| ScrubXmlNode(HumanReadableSerializerOptions, string, Func<XNode, XNode?>) | Scrubs XML nodes matching the specified XPath expression. |
| ScrubXmlNode(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XNode, XNode?>) | Scrubs XML nodes matching the specified XPath expression with namespace resolution. |
| UseRelativeDateTime(HumanReadableSerializerOptions, DateTime) | Serializes DateTime values relative to the specified origin. |
| UseRelativeDateTimeOffset(HumanReadableSerializerOptions, DateTimeOffset) | Serializes DateTimeOffset values relative to the specified origin. |
| UseRelativeTimeSpan(HumanReadableSerializerOptions, TimeSpan) | Serializes TimeSpan values relative to the specified origin. |
ScrubGuid(HumanReadableSerializerOptions)
HumanReadableSerializerScrubExtensions.csScrubs GUID values by replacing them with deterministic values based on their order of appearance.
public static void ScrubGuid(this HumanReadableSerializerOptions options)Parameters
optionsHumanReadableSerializerOptions
ScrubJsonValue overloads
ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, string?>)
HumanReadableSerializerScrubExtensions.csScrubs JSON values matching the specified JSONPath expression, returning a string value.
public static void ScrubJsonValue(this HumanReadableSerializerOptions options, string jsonPath, Func<JsonNode, string?> scrubber)Parameters
optionsHumanReadableSerializerOptionsjsonPathstringscrubberFunc<JsonNode, string?>
Remarks
A match whose value is JSON null is left unchanged, as there is no JsonNode to hand to the scrubber. When the expression matches the document root, the returned value becomes the whole document, and returning null reduces the document to JSON null.
ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, JsonNode?>)
HumanReadableSerializerScrubExtensions.csScrubs JSON values matching the specified JSONPath expression, returning a JSON node.
public static void ScrubJsonValue(this HumanReadableSerializerOptions options, string jsonPath, Func<JsonNode, JsonNode?> scrubber)Parameters
optionsHumanReadableSerializerOptionsjsonPathstringscrubberFunc<JsonNode, JsonNode?>
Remarks
A match whose value is JSON null is left unchanged, as there is no JsonNode to hand to the scrubber. When the expression matches the document root, the returned node becomes the whole document, and returning null reduces the document to JSON null.
ScrubValue overloads
ScrubValue<T>(HumanReadableSerializerOptions)
HumanReadableSerializerScrubExtensions.csScrubs values of type T by replacing them with deterministic values like "TypeName_0", "TypeName_1", etc.
public static void ScrubValue<T>(this HumanReadableSerializerOptions options)ScrubValue<T>(HumanReadableSerializerOptions, IEqualityComparer<T>?)
HumanReadableSerializerScrubExtensions.csScrubs values of type T by replacing them with deterministic values, using the specified comparer to determine uniqueness.
public static void ScrubValue<T>(this HumanReadableSerializerOptions options, IEqualityComparer<T>? comparer)ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>)
HumanReadableSerializerScrubExtensions.csScrubs values of type T by replacing them with the result of the specified scrubber function that receives the value and its index.
public static void ScrubValue<T>(this HumanReadableSerializerOptions options, Func<T, int, string> scrubber)ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>, IEqualityComparer<T>?)
HumanReadableSerializerScrubExtensions.csScrubs values of type T by replacing them with the result of the specified scrubber function, using the specified comparer to determine uniqueness.
public static void ScrubValue<T>(this HumanReadableSerializerOptions options, Func<T, int, string> scrubber, IEqualityComparer<T>? comparer)Type parameters
T
Parameters
optionsHumanReadableSerializerOptionsscrubberFunc<T, int, string>comparerIEqualityComparer<T>?
ScrubValue<T>(HumanReadableSerializerOptions, Func<T, string>)
HumanReadableSerializerScrubExtensions.csScrubs values of type T by replacing them with the result of the specified scrubber function.
public static void ScrubValue<T>(this HumanReadableSerializerOptions options, Func<T, string> scrubber)ScrubXmlAttribute overloads
ScrubXmlAttribute(HumanReadableSerializerOptions, string, Func<XAttribute, string?>)
HumanReadableSerializerScrubExtensions.csScrubs XML attributes matching the specified XPath expression.
public static void ScrubXmlAttribute(this HumanReadableSerializerOptions options, string xpath, Func<XAttribute, string?> scrubber)Parameters
optionsHumanReadableSerializerOptionsxpathstringscrubberFunc<XAttribute, string?>
ScrubXmlAttribute(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XAttribute, string?>)
HumanReadableSerializerScrubExtensions.csScrubs XML attributes matching the specified XPath expression with namespace resolution.
public static void ScrubXmlAttribute(this HumanReadableSerializerOptions options, string xpath, IXmlNamespaceResolver? nsResolver, Func<XAttribute, string?> scrubber)Parameters
optionsHumanReadableSerializerOptionsxpathstringnsResolverIXmlNamespaceResolver?scrubberFunc<XAttribute, string?>
ScrubXmlNode overloads
ScrubXmlNode(HumanReadableSerializerOptions, string, Action<XNode>)
HumanReadableSerializerScrubExtensions.csScrubs XML nodes matching the specified XPath expression using an action.
public static void ScrubXmlNode(this HumanReadableSerializerOptions options, string xpath, Action<XNode> scrubber)Parameters
optionsHumanReadableSerializerOptionsxpathstringscrubberAction<XNode>
ScrubXmlNode(HumanReadableSerializerOptions, string, Func<XNode, XNode?>)
HumanReadableSerializerScrubExtensions.csScrubs XML nodes matching the specified XPath expression.
public static void ScrubXmlNode(this HumanReadableSerializerOptions options, string xpath, Func<XNode, XNode?> scrubber)Parameters
optionsHumanReadableSerializerOptionsxpathstringscrubberFunc<XNode, XNode?>
Remarks
Returning the matched node replaces nothing, so a scrubber can mutate the node in place. Returning null removes the node; removing the document element leaves an empty document.
ScrubXmlNode(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XNode, XNode?>)
HumanReadableSerializerScrubExtensions.csScrubs XML nodes matching the specified XPath expression with namespace resolution.
public static void ScrubXmlNode(this HumanReadableSerializerOptions options, string xpath, IXmlNamespaceResolver? nsResolver, Func<XNode, XNode?> scrubber)Parameters
optionsHumanReadableSerializerOptionsxpathstringnsResolverIXmlNamespaceResolver?scrubberFunc<XNode, XNode?>
Remarks
Returning the matched node replaces nothing, so a scrubber can mutate the node in place. Returning null removes the node; removing the document element leaves an empty document.
UseRelativeDateTime(HumanReadableSerializerOptions, DateTime)
HumanReadableSerializerScrubExtensions.csSerializes DateTime values relative to the specified origin.
public static void UseRelativeDateTime(this HumanReadableSerializerOptions options, DateTime origin)Parameters
optionsHumanReadableSerializerOptionsoriginDateTime
UseRelativeDateTimeOffset(HumanReadableSerializerOptions, DateTimeOffset)
HumanReadableSerializerScrubExtensions.csSerializes DateTimeOffset values relative to the specified origin.
public static void UseRelativeDateTimeOffset(this HumanReadableSerializerOptions options, DateTimeOffset origin)Parameters
optionsHumanReadableSerializerOptionsoriginDateTimeOffset
UseRelativeTimeSpan(HumanReadableSerializerOptions, TimeSpan)
HumanReadableSerializerScrubExtensions.csSerializes TimeSpan values relative to the specified origin.
public static void UseRelativeTimeSpan(this HumanReadableSerializerOptions options, TimeSpan origin)Parameters
optionsHumanReadableSerializerOptionsoriginTimeSpan