Class ConfigurationHelper
A component helper for managing component configuration.
Inheritance
Namespace: Microsoft.Psi
Assembly: Microsoft.Psi.dll
Syntax
public static class ConfigurationHelper : object
Methods
View SourceReadFromFileOrDefault<T>(String, T, Boolean, Type[])
Loads or creates a new instance of the configuration class.
Declaration
public static T ReadFromFileOrDefault<T>(string configurationFilename, T defaultConfiguration = null, bool createFileIfNotExist = false, Type[] extraTypes = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
configurationFilename | The name of the configuration file to load. |
T | defaultConfiguration | The default configuration to use if no configuration was loaded. |
System. |
createFileIfNotExist | Whether the configuration file should be created (using the default configuration) if one does not already exist. |
Type[] | extraTypes | Extra types that are required for serialization. |
Returns
Type | Description |
---|---|
T | The loaded configuration if it exists, or the default configuration. |
Type Parameters
Name | Description |
---|---|
T | The type of the configuration class. |
ReadFromStream<T>(Stream, Type[])
Reads a new instance of the configuration class from a
Declaration
public static T ReadFromStream<T>(Stream stream, Type[] extraTypes = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which to read the configuration. |
Type[] | extraTypes | Extra types that are required for serialization. |
Returns
Type | Description |
---|---|
T | The configuration object. |
Type Parameters
Name | Description |
---|---|
T | The type of the configuration class. |
WriteToFile<T>(String, T, Type[])
Write the instance of the configuration class to a specified file.
Declaration
public static void WriteToFile<T>(string configurationFilename, T configuration = null, Type[] extraTypes = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
configurationFilename | The name of the file to write to. |
T | configuration | The configuration to write to the file. |
Type[] | extraTypes | Extra types that are required for serialization. |
Type Parameters
Name | Description |
---|---|
T | The type of the configuration class. |
WriteToStream<T>(T, Stream, Type[])
Writes the configuration to a stream.
Declaration
public static void WriteToStream<T>(T configuration, Stream stream, Type[] extraTypes = null)
Parameters
Type | Name | Description |
---|---|---|
T | configuration | The configuration to write. |
Stream | stream | The stream to write to. |
Type[] | extraTypes | Extra types that are required for serialization. |
Type Parameters
Name | Description |
---|---|
T | The type of the configuration class. |