Mastersign.ConfigModel
Show / Hide Table of Contents

Class ConfigModelManager<TRootModel>

The main class of the Mastersign.ConfigModel library.

Inheritance
object
ConfigModelManager<TRootModel>
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Mastersign.ConfigModel
Assembly: Mastersign.ConfigModel.dll
Syntax
public class ConfigModelManager<TRootModel> : IDisposable where TRootModel : class, new()
Type Parameters
Name Description
TRootModel

The type of the root class of the configuration model tree.

Constructors

ConfigModelManager(StringComparison, PropertyNameHandling, TRootModel, YamlDeserializerBuildCustomizer, IReadOnlyDictionary<Type, IReadOnlyDictionary<string, Type>>, IReadOnlyDictionary<Type, Tuple<string, IReadOnlyDictionary<string, Type>>>, bool)

Declaration
public ConfigModelManager(StringComparison filenameComparison = StringComparison.Ordinal, PropertyNameHandling propertyNameHandling = PropertyNameHandling.PascalCase, TRootModel defaultModel = null, YamlDeserializerBuildCustomizer deserializationCustomizer = null, IReadOnlyDictionary<Type, IReadOnlyDictionary<string, Type>> typeDiscriminationsByPropertyExistence = null, IReadOnlyDictionary<Type, Tuple<string, IReadOnlyDictionary<string, Type>>> typeDiscriminationsByPropertyValue = null, bool withMergeKeys = false)
Parameters
Type Name Description
StringComparison filenameComparison
PropertyNameHandling propertyNameHandling
TRootModel defaultModel
YamlDeserializerBuildCustomizer deserializationCustomizer
IReadOnlyDictionary<Type, IReadOnlyDictionary<string, Type>> typeDiscriminationsByPropertyExistence
IReadOnlyDictionary<Type, Tuple<string, IReadOnlyDictionary<string, Type>>> typeDiscriminationsByPropertyValue
bool withMergeKeys

ConfigModelManager(StringComparison, INamingConvention, TRootModel, YamlDeserializerBuildCustomizer, IReadOnlyDictionary<Type, IReadOnlyDictionary<string, Type>>, IReadOnlyDictionary<Type, Tuple<string, IReadOnlyDictionary<string, Type>>>, bool)

Declaration
public ConfigModelManager(StringComparison filenameComparison, INamingConvention propertyNamingConvention, TRootModel defaultModel, YamlDeserializerBuildCustomizer deserializationCustomizer, IReadOnlyDictionary<Type, IReadOnlyDictionary<string, Type>> typeDiscriminationsByPropertyExistence, IReadOnlyDictionary<Type, Tuple<string, IReadOnlyDictionary<string, Type>>> typeDiscriminationsByPropertyValue, bool withMergeKeys)
Parameters
Type Name Description
StringComparison filenameComparison
INamingConvention propertyNamingConvention
TRootModel defaultModel
YamlDeserializerBuildCustomizer deserializationCustomizer
IReadOnlyDictionary<Type, IReadOnlyDictionary<string, Type>> typeDiscriminationsByPropertyExistence
IReadOnlyDictionary<Type, Tuple<string, IReadOnlyDictionary<string, Type>>> typeDiscriminationsByPropertyValue
bool withMergeKeys

Properties

IsWatching

Declaration
public bool IsWatching { get; }
Property Value
Type Description
bool

ReloadDelay

Declaration
public TimeSpan ReloadDelay { get; set; }
Property Value
Type Description
TimeSpan

Methods

AddLayer(string)

Declaration
public void AddLayer(string fileName)
Parameters
Type Name Description
string fileName

AddLayers(string, string)

Declaration
public void AddLayers(string filePattern, string rootPath = null)
Parameters
Type Name Description
string filePattern
string rootPath

Dispose()

Declaration
public void Dispose()

~ConfigModelManager()

Declaration
protected ~ConfigModelManager()

GetIncludePatterns()

Declaration
public string[] GetIncludePatterns()
Returns
Type Description
string[]

GetLayerPatterns()

Declaration
public string[] GetLayerPatterns()
Returns
Type Description
string[]

GetLoadedIncludePaths()

Declaration
public string[] GetLoadedIncludePaths()
Returns
Type Description
string[]

GetLoadedLayerPaths()

Declaration
public string[] GetLoadedLayerPaths()
Returns
Type Description
string[]

GetLoadedStringSourcePaths()

Declaration
public string[] GetLoadedStringSourcePaths()
Returns
Type Description
string[]

LoadModel()

Declaration
public TRootModel LoadModel()
Returns
Type Description
TRootModel

StopWatching()

Declaration
public void StopWatching()

WatchAndReload()

Starts watching for changes on any files, matching the glob patterns added model layers, includes, and string sources. Every time a change is detected the ReloadDelay is waited, to filter out multiple change events in a short time, then the model is reloaded. When the reload was successful, the ModelChanged event is fired. If the reload failed, the ModelReloadFailed event is fired.

Declaration
public void WatchAndReload()
Remarks

The environment variable DOTNET_USE_POLLING_FILE_WATCHER can be set to 1 or true to use polling for the watcher. But keep in mind, that polling is slow: Probably around 4 seconds interval.

Exceptions
Type Condition
ObjectDisposedException

Is thrown if the mamager was disposed.

Events

ModelChanged

Declaration
public event ModelChangeHandler<TRootModel> ModelChanged
Event Type
Type Description
ModelChangeHandler<TRootModel>

ModelReloadFailed

Declaration
public event ModelReloadErrorHandler ModelReloadFailed
Event Type
Type Description
ModelReloadErrorHandler

Implements

IDisposable
In This Article
Back to top
mastersign