Search Results for

    Show / Hide Table of Contents

    Class ConfigurationHelper

    A component helper for managing component configuration.

    Inheritance
    System.Object
    ConfigurationHelper
    Namespace: Microsoft.Psi
    Assembly: Microsoft.Psi.dll
    Syntax
    public static class ConfigurationHelper : object

    Methods

    View Source

    ReadFromFileOrDefault<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.String configurationFilename

    The name of the configuration file to load.

    T defaultConfiguration

    The default configuration to use if no configuration was loaded.

    System.Boolean 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.

    View Source

    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.

    View Source

    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.String 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.

    View Source

    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.

    • View Source
    In This Article
    • Methods
      • ReadFromFileOrDefault<T>(String, T, Boolean, Type[])
      • ReadFromStream<T>(Stream, Type[])
      • WriteToFile<T>(String, T, Type[])
      • WriteToStream<T>(T, Stream, Type[])
    Back to top Privacy & Cookies | Terms Of Use | Trademarks | © Microsoft
    Generated by DocFX