Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MmUserOptionsForm
Message
 
À
06/11/2008 17:45:16
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01359539
Message ID:
01360551
Vues:
11
Tim,

This works great for reading the values from the XML file into public properties. How about saving back to the file?

If I set one of the properties, I am attempting to use the method WriteKeysToConfig() to save the changes, but I am not seeing the change in the file. Any ideas?

For instance, there is a value for "DatabaseSetDefault" that is initially set to "CustA". Here is the code I am trying:

mmApp.SetConfigurationSection("appSettings");
mmApp.DatabaseSetDefault = "CustB";
mmApp.WriteKeysToConfig();

Kind Regards,

Mat


>I subclassed the mmAppConfiguration class for my specific application. Then added public properties for everything I wanted. I put a property in the App.cs to access it.
>
>public class TipTraxSettings : mmAppConfiguration
>{
>    public TipTraxSettings() : base(false)
>    {
>        // Specify the settings to be encrypted, and the encryption key
>        this.SetEncryption("WSUserId,WSPassword", "PacificaSys");
>			
>        // Use a custom Config file
>        this.ReadKeysFromConfig("TipTrax.Config");
>    }
>
>    #region Public Settings Properties
>
>    /// <summary>
>    /// MyTruckCode Property
>    /// </summary>
>    public string MyTruckCode
>    {
>        get { return _myTruckCode; }
>        set { _myTruckCode = value; }
>    }
>    private string _myTruckCode = "120";
>
>    /// <summary>
>    /// EnableGps Property
>    /// </summary>
>    public bool EnableGps
>    {
>        get { return _enableGps; }
>        set { _enableGps = value; }
>    }
>    private bool _enableGps = true;
>}
>
>Then in App.cs Add a static public property to get to access them.
>
>/// <summary>
>/// ApplicationSettings Property
>/// </summary>
>public static TipTraxSettings ApplicationSettings
>{
>    get
>    {
>				
>        if (_applicationSettings == null)
>            _applicationSettings = new TipTraxSettings();
>
>        return _applicationSettings;
>    }
>}
>private static TipTraxSettings _applicationSettings;
>
>Now anywhere in the application I can reference it like this:
>if (AppDesktop.ApplicationSettings.EnableGps)
>{
>    // Do something
>}
>or
>string truckCode = AppDesktop.ApplicationSettings.MyTruckCode;
>
>
>Hope that helps.
>Regards;
>Tim
Matthew Kennedy
Decision Support Technology Inc.

"I try to take one day at a time, but sometimes several days attack me all at once." ~ Ashleigh Brilliant

New Jersey Dot Net User Group
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform