MetadataDefaultsProvider Class
The MetadataDefaultsProvider class is the concrete implementation of
IDataTypeDefaultValueProvider in the PocoDataSet.Data assembly.
It provides a dependency-injection-friendly entry point for resolving default values for
newly created cells based on a column's logical data type and nullability.
Internally, MetadataDefaultsProvider delegates all default-value decisions to the
static MetadataDefaults helper. This keeps defaulting rules centralized while allowing
higher-level components (factories, UI frameworks, adapters) to depend on an interface rather than
calling static methods directly.
Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll
public class MetadataDefaultsProvider : IDataTypeDefaultValueProvider
{
public object? GetDefaultValue(string? dataType, bool isNullable)
{
return MetadataDefaults.GetDefaultValue(dataType, isNullable);
}
}
GetDefaultValue returns the default value for the specified logical dataType
(typically a value from DataTypeNames) and the isNullable flag.
isNullable is true, many consumers choose to keep the cell value as
null; the exact rule is determined by MetadataDefaults.
MetadataDefaultsProvider contains no defaulting logic of its own; it exists so
default value resolution can be swapped or mocked in tests.
// Example: resolving a default value from column metadata
IDataTypeDefaultValueProvider provider = new MetadataDefaultsProvider();
// Suppose the column is an INT32 and not nullable
object? defaultValue = provider.GetDefaultValue(DataTypeNames.INT32, false);
// defaultValue can now be assigned to a newly created cell
// (exact value depends on MetadataDefaults rules)
Use MetadataDefaults directly when a static call is sufficient (for example, in simple
extension methods). Use MetadataDefaultsProvider when you want an interface boundary
for dependency injection, unit testing, or alternative strategies.
Table of Content POCO DataSet PocoDataSet.Data
Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the
Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate
credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness
or suitability of the information and are not responsible for any damages
resulting from its use.