Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Type Availability - Using Application Settings Architecture across applications - Strongly Typed Config
    primarykey
    data
    text
    <p>I am looking to write a unified configuration class that aggregates the settings in multiple applications which exist from within Visual Studio's Application Settings Architecture (ASA). (http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx)</p> <p>The ASA generates a Settings.Designer.cs class for each project. What I'd like to do is aggregate all of the settings classes of several projects together to be available from one class. For instance I have a project that's only used to store shared settings and that's it. This project has a class like:</p> <pre><code>public static class ConfigManager { public static TopNamespace.Configuration.Properties.Settings Shared { get { return TopNamespace.Configuration.Properties.Settings.Default; } } } </code></pre> <p>This allows me to access config like:</p> <pre><code>ConfigManager.Shared.ConfigKey </code></pre> <p>What I'd like to do is extend this ConfigManager class to give me access to the generated settings classes of other projects. I'm not sure if this is possible or how to go about doing this. For instance I'd like to be able to do:</p> <pre><code>ConfigManager.ApplicationName.ConfigKey ConfigManager.OtherApplicationName.ConfigKey </code></pre> <p>Circular references prevent me from adding references to the application projects from the Configuration project to get access to the types to make more members like:</p> <pre><code>public static class ConfigManager { public static TopNamespace.Configuration.Properties.Settings ApplicationName { get { return TopNamespace.ApplicationName.Properties.Settings.Default; } } public static TopNamespace.Configuration.Properties.Settings OtherApplicationName { get { return TopNamespace.OtherApplicationName.Properties.Settings.Default; } } } </code></pre> <p>And then trying to add a reference to the Configuration project back from the application projects to gain access to the ConfigManager class. </p> <p>I thought about extending the classes but partial classes won't work across assemblies and you can't inherit from static classes. Using generics doesn't seem like it'd be a very good solution either since you couldn't have a nice clean ConfigManager.ApplicationName.SettingName type of signatures for the property members. </p> <p>Is there any way to use inheritance or do some kind of dynamic examination of available types in the Application Domain and load the settings types for available applications to be made available from a single ConfigManager class? Making all the settings classes across several projects generated by visual studio available from one single manager class with properties for each project settings instance. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload