Class DirectoryLoaderBuilder
- Namespace
- DirectoryToObject.Builder
- Assembly
- DirectoryToObject.dll
Builder class for file or directory handlers.
public class DirectoryLoaderBuilder : IDirectoryLoaderContextHandler
- Inheritance
-
DirectoryLoaderBuilder
- Implements
- Inherited Members
Methods
AsArray(string?, StringComparer?)
Apply a node transformer to the loaded JSON node such that the node is converted to a JsonArray. If the node is already a JsonArray, it is returned as-is. If the node is null or a JsonValue, the value becomes the single item in the returned array. If the node is a JsonObject, it is transformed using ToJsonArray(JsonObject, string, StringComparer).
public DirectoryLoaderBuilder AsArray(string? propertyForKeys = null, StringComparer? comparer = null)
Parameters
propertyForKeysstringThe name of the JSON object property to write keys to. Only applies to JsonObject nodes. If null, the keys are not written anywhere.
comparerStringComparerThe comparer to establish the order of items in the array by sorting object keys. Only applies to JsonObject nodes. If null, defaults to Ordinal.
Returns
- See Also
CaseSensitiveWhenExtensionIsOneOf(params string[])
Add extension matching to the handler: only handle file/directory entries that have one of the supplied extensions (case-sensitive).
public DirectoryLoaderBuilder CaseSensitiveWhenExtensionIsOneOf(params string[] extensions)
Parameters
extensionsstring[]The file name extension to handle.
Returns
- DirectoryLoaderBuilder
A new DirectoryLoaderBuilder instance with the added extension matching constraint.
Remarks
This adds a condition to the CanProcessEntry(IFileSystemDirectory, IFileSystemEntry, string) implementation in the new handler. So, if the original handler already has name or extension constraints in place, this will apply in addition to, not in the place of the existing constraints.
CaseSensitiveWhenPathMatchesAny(params string[])
Add path and name matching to the handler: only handle file/directory entries that match any of the supplied glob expressions (case-sensitive).
public DirectoryLoaderBuilder CaseSensitiveWhenPathMatchesAny(params string[] globExpressions)
Parameters
globExpressionsstring[]The glob expressions to match against.
Returns
- DirectoryLoaderBuilder
A new DirectoryLoaderBuilder instance with the added glob matching constraint.
Remarks
This adds a condition to the CanProcessEntry(IFileSystemDirectory, IFileSystemEntry, string) implementation in the new handler. So, if the original handler already has name or extension constraints in place, this will apply in addition to, not in the place of the existing constraints.
WhenExtensionIsOneOf(params string[])
Add extension matching to the handler: Only handle file/directory entries that have one of the supplied extensions (case-insensitive).
public DirectoryLoaderBuilder WhenExtensionIsOneOf(params string[] extensions)
Parameters
extensionsstring[]The file name extension to handle.
Returns
- DirectoryLoaderBuilder
A new DirectoryLoaderBuilder instance with the added extension matching constraint.
Remarks
This adds a condition to the CanProcessEntry(IFileSystemDirectory, IFileSystemEntry, string) implementation in the new handler. So, if the original handler already has name or extension constraints in place, this will apply in addition to, not in the place of the existing constraints.
WhenPathMatchesAny(params string[])
Add path and name matching to the handler: only handle file/directory entries that match any of the supplied glob expressions (case-insensitive).
public DirectoryLoaderBuilder WhenPathMatchesAny(params string[] globExpressions)
Parameters
globExpressionsstring[]The glob expressions to match against.
Returns
- DirectoryLoaderBuilder
A new DirectoryLoaderBuilder instance with the added glob matching constraint.
Remarks
This adds a condition to the CanProcessEntry(IFileSystemDirectory, IFileSystemEntry, string) implementation in the new handler. So, if the original handler already has name or extension constraints in place, this will apply in addition to, not in the place of the existing constraints.
WithKeyComputation(Func<string, string>)
Override the underlying key in the JSON object with a custom function that transforms the original name in an arbitrary way.
public DirectoryLoaderBuilder WithKeyComputation(Func<string, string> keyMappingFunction)
Parameters
Returns
- DirectoryLoaderBuilder
A new DirectoryLoaderBuilder instance with the added key mapping constraint.
WithNodeTransformer(Func<JsonNode?, JsonNode?>)
Apply a node transformer function to the loaded JSON node. If the loader already has a transformer, the functions are combined.
public DirectoryLoaderBuilder WithNodeTransformer(Func<JsonNode?, JsonNode?> nodeTransformer)
Parameters
Returns
- DirectoryLoaderBuilder
A new DirectoryLoaderBuilder instance with the added node transformer.