Note that there are some explanatory texts on larger screens.

plurals
  1. POSerialize/deserialize to/from multiple XML config files
    primarykey
    data
    text
    <p>I have a set of custom XML configuration management classes in .NET.</p> <p>There are two configuration scopes in my application:</p> <p><strong>User</strong>: the setting applies to the user regardless of the account she's logged into. Stored in a XML config file in the user's directory.</p> <p><strong>User/Account:</strong> the setting applies to the user when logged into a particular account. Stored in a XML config file in the user's directory under an account specific sub-directory.</p> <p>The two XML documents have the same structure and can be modified by hand. When the application starts up, I read the XML config from the user's profile and the XML config from the User/Account directory. I then merge the two XML documents into a single XDocument and then deserialize the XML into objects modeled after the XDocument's sections. If there is a User/Account-level setting present, it should override the User-level setting. Example: </p> <p><strong>User file:</strong></p> <pre><code>&lt;FileSettings&gt; &lt;DownloadPath&gt;C:\downloads&lt;/DownloadPath&gt; &lt;UploadPath&gt;C:\uploads&lt;/UploadPath&gt; &lt;/FileSettings&gt; </code></pre> <p><strong>User/Account file for account XYZ:</strong></p> <pre><code>&lt;FileSettings&gt; &lt;DownloadPath&gt;C:\newlocation\xyz\mystuff&lt;/DownloadPath&gt; &lt;/FileSettings&gt; </code></pre> <p><strong>Result after merge:</strong></p> <pre><code>&lt;FileSettings&gt; &lt;DownloadPath&gt;C:\newlocation\xyz\mystuff&lt;/DownloadPath&gt; &lt;UploadPath&gt;C:\uploads&lt;/UploadPath&gt; &lt;/FileSettings&gt; </code></pre> <p>In the above example, a FileSettings object with 2 properties - DownloadPath and UploadPath will be instantiated from the section. </p> <p><strong>Here's my issue:</strong> I have no idea which config file (i.e., scope) the DownloadPath and UploadPath came from. As a result, when the object needs to serialize again, it doesn't know which properties go in which file. </p> <p><strong>Question:</strong> What's the best way to store the "source," on a property-by-property basis, so that I can ensure a setting gets written to the same config file that it was read from?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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