locked
More on Custom Profile Provider RRS feed

  • Question

  • User-378651560 posted
    I'm back. So once I got past the "I'm stupid" problem from earlier, there's still another. I've created a custom profile provider, and I can read values from a simple XML file (it's a demo). The GetPropertyValues procedure gets called, and I read the values from the XML file. All works. When it comes time to save the values (when I call Profile.Save in the page), the provider's SavePropertyValues procedure doesn't get called. I can't find how to convince it to call this procedure. Any ideas? Has anyone created a custom profile provider that WRITES values anywhere? Love to hear from you if you have any ideas... - ken
    Wednesday, July 14, 2004 7:44 PM

All replies

  • User961349301 posted
    When you call the Save method of the Profile, the providers SetPropertyValues will be called not the SavePropertyValues. But I suppose you mean the SetPropertyValues. Can you post your SetPropertyValues method to this thread? It will be easier to locate the problem.
    Thursday, July 15, 2004 3:42 AM
  • User-378651560 posted
    THanks. There's really nothing in it. It just never gets called. I put a breakpoint on the method, and it never gets hit. I did the same thing with the GetPropertyValues, and can single-step through it just fine. (Actually, there's a couple of debugging statements within SavePropertyValues, to see if it's just not getting the breakpoint set, but those never happen either). The point is that the GetPropertyValues is definitely being called, and I can verify that. The SavePropertyValues procedure is NOT being called, as far as I can tell, and I'm not sure why. I guess what I was looking for was if anyone had actually gotten this to work in Beta 1, to verify that I wasn't losing it. THanks -- Ken
    Thursday, July 15, 2004 9:27 AM
  • User-378651560 posted
    Just looked at the code; I'm referring to the SetPropertyValues override. This simply does not get called, at least in the provider I've written. GetPropertyValues works fine. Thanks -- Ken
    Thursday, July 15, 2004 9:32 AM
  • User961349301 posted
    If there is no property, the SetPropertyValues will not be called by the Save method.
    Thursday, July 15, 2004 2:51 PM
  • User-378651560 posted
    I'm sorry I'm not being clear. There are many properties in the Web.config file, and the GetPropertyValues in the driver is being called, and loading up the properties into the Profile object just fine. When I attempt to save the properties back to the data store, by calling the Profile.Save method, my SetPropertyValues method isn't being called. (At the time I replied to you, my SetPropertyValues procedure wasn't written yet, it was just a stub. Now it's completely written, and I'm pretty sure it works fine, IF IT GETS CALLED. But it's never been called as part of the standard load/save Profile mechanism. (I've tested it by adding code elsewhere in the provider to call SetPropertyValues internally, so I can step through it and verify that its logic is correct.) When I set the default provider to be AspNetAccessProvider, everything works perfectly. All the properties get read and written back to the MDB file. Same for AspNetSqlProvider. When I replace the default provider name with XmlProvider (the one I wrote), the property values never get written back to the XML file, but they do get correctly read from the XML file. I put a breakpoint on the declaration of SetPropertyValues. It simply never gets called. When I do the same thing with GetPropertyValues, it hits the breakpoint within the provider, and I can step through the code. It looks to me like the internal ASP.NET page framework code simply isn't calling my procedure. I'm wondering if there's something I have to do to make this work, or if it's just busted in Beta 1. I was hoping someone had actually written a custom provider that wrote data back to the data store, but I haven't heard from anyone who has. THanks -- Ken
    Thursday, July 15, 2004 4:47 PM
  • User-378651560 posted
    But your comment makes me thing. You say "if there is no property, the SetPropertyValues won't be called". Perhaps I'm misunderstanding. I DO have properties that are read from the data store into the Profile object, and it contains those values at runtime. I have verified that. In this case, when I call Profile.Save, it should call SetPropertyValues, right? -- Ken
    Thursday, July 15, 2004 4:48 PM
  • User961349301 posted
    What I meant was if the Properties property of the Profile class is null or have no items or if the PropertyVlaues property is null the SetPropertyValues will not be called. The SetPropertyValues method will also not be called if the Providers property has no providers which it should have in your case.
    Thursday, July 15, 2004 7:46 PM
  • User-378651560 posted
    Right. I think we're agreed -- it SHOULD work. I was hoping to confirm from someone (perhaps someone on the team that's lurking here) that either it's busted, or something is missing that I'm not doing that is required to make this happen. Perhaps some specific property being set somewhere, or some method besides SetPropertyValues that has to be provided in order to get the values saved. In my provider, I've only overriden the Initialize, GetPropertyValues and SetPropertyValues procedures, for example. This doesn't seem to affect the framework calling GetPropertyValues, and I can't see why SetPropertyValues isn't getting called. But it's not, and I'm not sure where to turn at this point. I filed a bug against this, and hope someone who's played with it can confirm what I'm finding. Thanks anyway. -- Ken
    Friday, July 16, 2004 9:33 AM
  • User331136620 posted
    From your description it sounds like the code in our base class is not recognizing any of the property values returned from GetPropertyValues as being associated with your provider. Can you confirm that each SettingsPropertyValue() instance that you create in GetPropertyValues is properly associated with an instance of SettingsProperty? And that furthermore the SettingsProperty instance that you use is correctly associated with your provider? Basically, somewhere in GetPropertyValues, there should be code new'ing up SettingsPropertyValue instances that looks like: SettingsPropertyValue sv = new SettingsPropertyValues(SettingsPropertyInstanceGoesHere); You get the SettingsProperty instance from the SettingsPropertyCollection that is passed in as a parameter to the GetPropertyValues method. After the Profile has loaded, can you aslo cast it to a SettingsBase reference, and then inspect the PropertyValues property on SettingsBase? You should be able to walk through the SettingsPropertyValueCollection returned by this property, and see all of the properties and property value-to-Settings Property associations using this collection.
    Tuesday, July 20, 2004 7:02 PM
  • User-378651560 posted
    Let me work through this. I'll get back to you soon. Clearly, the code in my GetPropertyValues method was filling in a collection, and sending it back, but I'm wondering if it was somehow bypassing the mechanism that convinces the provider that the properties are associated with the provider. You've given me some things to look into. I'll post back in a while. Thanks! -- Ken
    Wednesday, July 21, 2004 11:30 AM
  • User-378651560 posted
    That was it! I was filling in a NEW SettingsPropertyValue for each property, instead of using the one passed in. (Slap forhead here.) Of course, you have to associate the property with the provider. Thanks for following up. Glad to know it's not busted! I couldn't figure how it COULD be busted, since it worked fine for built-in providers. Case closed. Thanks again for everyone's help here. -- Ken
    Wednesday, July 21, 2004 12:57 PM
  • User-703164661 posted

    hi there!!

    i am not sure if you r still keeping track of this thread.I have a very similar probelm as yours.My Save () doesnt call the Setpropertyvalues().This doesnt happen always.Some properties do get called but others dont.I see that during the save,then property's isdirty is true and it needs to call the setpropertyvalues().Not sure what is happening.

    my usersettings is as follows

     [SettingsProvider(typeof(CustomSettingsProvider))]
        public class UserSettings : ApplicationSettingsBase
        {
            #region Members
            private static UserSettings _settings = ((UserSettings)(ApplicationSettingsBase.Synchronized(new UserSettings())));
            private static bool _initialized = false;
            private static bool? _passwordEncrypted = null;
            private static bool? _proxypasswordEncrypted = null;
            static bool _tfFunctionEnabled = true;
            static string _password = "";
            static string _proxypassword = "";
            static string _tsaServerAddress = "";
            
            #endregion
    
            private UserSettings()
            {
                if (!_initialized)
                {
                    try
                    {
                        base.Upgrade();
                        _initialized = true;
                    }
                    catch (ConfigurationErrorsException excep)
                    {
                        Debug.Assert(false, excep.ToString());
                    }
                }
            }
    
            #region Properties
            private string Key
            {
                set
                {
                    this.SettingsKey = value;
                    if(SettingsDictionary._keys.Contains(value))
                    _settings = SettingsDictionary.GetUserSetting(value);
                }
            }
    
            public static UserSettings Settings
            {
                get
                {
                    return _settings;
                }
            }
    
            public string UserConfigPath
            {
                get { return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + ApplicationContext.SettingFolderName + "\\UserSettings\\user.config"; }
            }
    
            #region Componant Settings
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ExpressionBuilder")]
            public string ExpressionbuilderSettingsGeneral
            {
                get { return (string)this["ExpressionbuilderSettingsGeneral"]; }
                set { this["ExpressionbuilderSettingsGeneral"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ExpressionBuilder")]
            public string ExpressionbuilderSettingsExport
            {
                get { return (string)this["ExpressionBuilderSettingsExport"]; }
                set { this["ExpressionBuilderSettingsExport"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("DILookUp")]
            public string DILookUpSettnigsGeneral
            {
                get { return (string)this["DILookUpSettnigsGeneral"]; }
                set { this["DILookUpSettnigsGeneral"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("DILookUp")]
            public string DILookUpSettingsExport
            {
                get { return (string)this["DILookUpSettingsExport"]; }
                set { this["DILookUpSettingsExport"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("IDLookUp")]
            public string IDLookUpSettingsGeneral
            {
                get { return (string)this["IDLookUpSettingsGeneral"]; }
                set { this["IDLookUpSettingsGeneral"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("IDLookUp")]
            public string IDLookUpSettingsExport
            {
                get { return (string)this["IDLookUpSettingsExport"]; }
                set { this["IDLookUpSettingsExport"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ScreenBuilder")]
            public string ScreenBuilderSettingsExport
            {
                get { return (string)this["ScreenBuilderSettingsExport"]; }
                set { this["ScreenBuilderSettingsExport"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ScreenBuilder")]
            public string ScreenBuilderSettingsGeneral
            {
                get { return (string)this["ScreenBuilderSettingsGeneral"]; }
                set { this["ScreenBuilderSettingsGeneral"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ReportBuilder")]
            public string ReportBuilderSettingsGeneral
            {
                get { return (string)this["ReportBuilderSettingsGeneral"]; }
                set { this["ReportBuilderSettingsGeneral"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ReportBuilder")]
            public string ReportBuilderSettingsExport
            {
                get { return (string)this["ReportBuilderSettingsExport"]; }
                set { this["ReportBuilderSettingsExport"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ConstituentLookup")]
            public string ConstituentLookupGeneralSettings
            {
                get { return (string)this["ConstituentLookupGeneralSettings"]; }
                set { this["ConstituentLookupGeneralSettings"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ConstituentLookup")]
            public string ConstituentLookupExportSettings
            {
                get { return (string)this["ConstituentLookupExportSettings"]; }
                set { this["ConstituentLookupExportSettings"] = value; }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(false)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("AggBuilder")]
            public string AggBuilderExportSettings
            {
                get { return (string)this["AggBuilderExportSettings"]; }
                set { this["AggBuilderExportSettings"] = value; }
            }
            #endregion
    
            #region Options
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("Options")]
            public string ServerAddress
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY;
                    if (_settings["ServerAddress"] == null)
                        return AppSettings.Settings.Server.ServerAddress;
                    else
                        return (string)_settings["ServerAddress"];
    
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _settings["ServerAddress"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("Options")]
            public string UserName
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    return (string)_settings["UserName"];
                }
                set
                {
                    this.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    this["UserName"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("Options")]
            public string Password
            {
                get
                {
                    string decryptedPassword = "";
                    Key = SettingsConstants.OPTIONSKEY; ;
                    if (_settings["Password"] == null)
                        return AppSettings.Settings.Server.Password;
                    else
                    {
                        if (_password == "")
                        {
                            if (PasswordEncrypted)
                            {
                                if (!Encryption.TransformString(false, (string)_settings["Password"], ref decryptedPassword, SettingsConstants.ENCRYPTION_KEY))
                                {
    
                                    ApplicationContext.Logger.LogMessage(LogImportance.ErrorLog, "Error in decrypting password, could cause problems");
                                }
                                else
                                {
                                    _password = decryptedPassword;
                                }
                            }
                            else
                                return (string)_settings["Password"];
                        }
                        else
                            return _password;
                    }
                    return decryptedPassword;
                }
                set
                {
                    string decryptedPassword="";
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    if (_password != value)
                    {
                        if (Encryption.TransformString(true, value, ref decryptedPassword, SettingsConstants.ENCRYPTION_KEY))
                        {
                            _settings["Password"] = decryptedPassword;
                            PasswordEncrypted = true;
                            _password = value;
                        }
                        else
                            ApplicationContext.Logger.LogMessage(LogImportance.ErrorLog, "Error in encrypting password, could cause problems");
                    }
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("False")]
            [SettingsGroupDescriptionAttribute("Options")]
            public bool PasswordEncrypted
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    if(_passwordEncrypted == null)
                        _passwordEncrypted = (bool)_settings["PasswordEncrypted"];
                    return (bool)_passwordEncrypted;
                }
                set
                {
                    this.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _passwordEncrypted = value;
                    this["PasswordEncrypted"] = value;
                }
            }
    
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("80")]
            [SettingsGroupDescriptionAttribute("Options")]
            public int ServerPort
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    return (int)_settings["ServerPort"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _settings["ServerPort"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true, "True", "False")]
            [DefaultSettingValue("False")]
            [SettingsGroupDescriptionAttribute("Options")]
            public bool UseProxy
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    return (bool)_settings["UseProxy"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _settings["UseProxy"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("False")]
            [SettingsGroupDescriptionAttribute("Options")]
            public string ProxyServer
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    if (_settings["ProxyServer"] == null)
                        return AppSettings.Settings.Server.ProxyServerAddress;
                    else
                        return (string)_settings["ProxyServer"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _settings["ProxyServer"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true, "80")]
            [DefaultSettingValue("80")]
            [SettingsGroupDescriptionAttribute("Options")]
            public int ProxyServerPort
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    return (int)_settings["ProxyServerPort"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _settings["ProxyServerPort"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("Options")]
            public string ProxyUserId
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    return (string)_settings["ProxyUserId"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _settings["ProxyUserId"] = value;
                }
            }
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("False")]
            [SettingsGroupDescriptionAttribute("Options")]
            public bool ProxyPasswordEncrypted
            {
                get
                {
                    Key = SettingsConstants.OPTIONSKEY; ;
                    if(_proxypasswordEncrypted == null)
                        _proxypasswordEncrypted = (bool)_settings["ProxyPasswordEncrypted"];
                    return (bool)_proxypasswordEncrypted;
                }
                set
                {
                    this.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    _proxypasswordEncrypted = value;
                    this["ProxyPasswordEncrypted"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("Options")]
            public string ProxyPassword
            {       
                 get
                {
                    string decryptedPassword = "";
                    Key = SettingsConstants.OPTIONSKEY; ;
                       if (_proxypassword == "")
                        {
                            if (ProxyPasswordEncrypted)
                            {
                                if (!Encryption.TransformString(false, (string)_settings["ProxyPassword"], ref decryptedPassword, SettingsConstants.ENCRYPTION_KEY))
                                {
    
                                    ApplicationContext.Logger.LogMessage(LogImportance.ErrorLog, "Error in decrypting proxy password, could cause problems");
                                }
                                else
                                {
                                    _proxypassword = decryptedPassword;
                                }
                            }
                            else
                                return (string)_settings["ProxyPassword"];
                        }
                        else
                            return _proxypassword;
                       return decryptedPassword;         
                }
                set
                {
                    string decryptedPassword="";
                    _settings.SettingsKey = SettingsConstants.OPTIONSKEY; ;
                    if (_proxypassword != value)
                    {
                        if (Encryption.TransformString(true, value, ref decryptedPassword, SettingsConstants.ENCRYPTION_KEY))
                        {
                            _settings["ProxyPassword"] = decryptedPassword;
                            ProxyPasswordEncrypted = true;
                            _proxypassword = value;
                        }
                        else
                            ApplicationContext.Logger.LogMessage(LogImportance.ErrorLog, "Error in encrypting proxy password, could cause problems");
                    }
                }
            }
            #endregion
    
            #region ChartBuilder
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int EntityType
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["EntityType"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["EntityType"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public bool AlwaysExport
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["AlwaysExport"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (bool)_settings["AlwaysExport"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int Chartlocation
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["Chartlocation"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["Chartlocation"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int Datalocation
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["Datalocation"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["Datalocation"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int SetAsDefault
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["SetAsDefault"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["SetAsDefault"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int CalculationType
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["CalculationType"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["CalculationType"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int Cleanup
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["Cleanup"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["Cleanup"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("-1")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int DefaultSettings
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["DefaultSettings"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["DefaultSettings"];
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ChartBuilder")]
            public int ImageType
            {
                set
                {
                    _settings.SettingsKey = SettingsConstants.CHARTBUILDERKEY;
                    _settings["ImageType"] = value;
                }
                get
                {
                    Key = SettingsConstants.CHARTBUILDERKEY;
                    return (int)_settings["ImageType"];
                }
            }
            #endregion
    
            #region Error Message
            [UserScopedSetting()]
            [DiagnosticsHint(true, "Offline")]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("ErrorMessages")]
            public string OfflineModeMessage
            {
                get
                {
                    Key = SettingsConstants.ERRORMESSAGEKEY;
                    return (string)_settings["OfflineModeMessage"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ERRORMESSAGEKEY;
                    _settings["OfflineModeMessage"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true, "...")]
            [DefaultSettingValue("...")]
            [SettingsGroupDescriptionAttribute("ErrorMessages")]
            public string RetrievingDataMessage
            {
                get
                {
                    Key = SettingsConstants.ERRORMESSAGEKEY;
                    return (string)_settings["RetrievingDataMessage"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ERRORMESSAGEKEY;
                    _settings["RetrievingDataMessage"] = value;
                }
            }
            #endregion
    
            #region General
            [UserScopedSetting()]
            [DefaultSettingValue("false")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("General")]
            public bool CodeMappedMode
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (bool)_settings["CodeMappedMode"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["CodeMappedMode"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true, "True", "False")]
            [DefaultSettingValue("false")]
            [SettingsGroupDescriptionAttribute("General")]
            public bool CodeMapEntitled
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (bool) (_settings["CodeMapEntitled"] ?? default(bool)) ;
                   
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["CodeMapEntitled"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("General")]
            public string UserSystemData
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (string)_settings["UserSystemData"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["UserSystemData"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("60")]
            [SettingsGroupDescriptionAttribute("General")]
            public int DataMemoryCacheMinutes
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (int)_settings["DataMemoryCacheMinutes"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["DataMemoryCacheMinutes"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("true")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("General")]
            public bool RealTimeStreamingEnabled
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (bool)_settings["RealTimeStreamingEnabled"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["RealTimeStreamingEnabled"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("true")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("General")]
            public bool TFFunctionEnabled
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    _tfFunctionEnabled = (bool)_settings["TFFunctionEnabled"];
                    return _tfFunctionEnabled;
                }
                set
                {
                    if (_tfFunctionEnabled != value)
                    {
                        _tfFunctionEnabled = value;
                        _settings.SettingsKey = SettingsConstants.GENERALKEY;
                        _settings["TFFunctionEnabled"] = value;
                        UserSettingsProvider.OnTFFunctionEnabledStatusChanged();
                    }
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("false")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("General")]
            public bool ShowIBComparables
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (bool)_settings["ShowIBComparables"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["ShowIBComparables"] = value;
                }
            }
            //[UserScopedSetting()]
            //[DefaultSettingValue("false")]
            //[SettingsGroupDescriptionAttribute("General")]
            //public bool MigrationCompleted
            //{
            //    get
            //    {
            //        Key = GENERALKEY;
            //        return (bool)_settings["MigrationCompleted"];
            //    }
            //    set
            //    {
            //        _settings.SettingsKey = GENERALKEY;
            //        _settings["MigrationCompleted"] = value;
            //    }
            //}
    
    
            [UserScopedSetting()]
            [DefaultSettingValue("2.1.0.0")]       
            [SettingsGroupDescriptionAttribute("General")]
            public string MigrationCompletedVersion
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (string)_settings["MigrationCompletedVersion"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["MigrationCompletedVersion"] = value;
                }
            }
    
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("10")]
            [SettingsGroupDescriptionAttribute("General")]
            public int LogLevel
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    if (_settings["Loglevel"] == null)
                        return (int)AppSettings.Settings.Log.LogLevel;
                    else
                        return (int)_settings["LogLevel"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["LogLevel"] = value;
                }
            }
    
            [UserScopedSetting()]
            [SettingsGroupDescriptionAttribute("General")]
            [DiagnosticsHint(false, "https://security.services.thomsonone.com/STS/2010-01-01/SamltokenIssuer.ashx", "https://security-qa.services.thomsononeqa.com/STS/2010-01-01/SamltokenIssuer.ashx")]
            public string  TSAServerAddress
            {
                get
                {       
                      return (string)AppSettings.Settings.TSA.ServerAddress;                    
                     
                }          
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("General")]
            public string OverriddenRealTimeProvider
            {
                get
                {
                    Key = SettingsConstants.GENERALKEY;
                    return (string)_settings["OverriddenRealTimeProvider"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.GENERALKEY;
                    _settings["OverriddenRealTimeProvider"] = value;
                }
            }
    
           
    
            #endregion
    
            #region Display
            [UserScopedSetting()]
            [DiagnosticsHint(true, "True", "False")]
            [DefaultSettingValue("false")]
            [SettingsGroupDescriptionAttribute("Display")]
            public bool VerboseCommandString
            {
                get
                {
                    Key = SettingsConstants.DISPLAYKEY;
                    return (bool)_settings["VerboseCommandString"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.DISPLAYKEY;
                    _settings["VerboseCommandString"] = value;
                }
            }
            #endregion
    
            #region Addin
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("3")]
            [SettingsGroupDescriptionAttribute("Addin")]
            public int AddinRefreshMode
            {
                get
                {
                    Key = SettingsConstants.ADDINKEY;
                    return (int)_settings["AddinRefreshMode"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ADDINKEY;
                    _settings["AddinRefreshMode"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("Notify")]
            [SettingsGroupDescriptionAttribute("Addin")]
            public UpgradeType UpgradeMode
            {
                get
                {
                    Key = SettingsConstants.ADDINKEY;
                    return (UpgradeType)_settings["UpgradeMode"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ADDINKEY;
                    _settings["UpgradeMode"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [SettingsGroupDescriptionAttribute("Addin")]
            public DateTime DontNotifyUpgradeUntil
            {
                get
                {
                    Key = SettingsConstants.ADDINKEY;
                    return (DateTime)_settings["DontNotifyUpgradeUntil"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ADDINKEY;
                    _settings["DontNotifyUpgradeUntil"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [SettingsGroupDescriptionAttribute("Addin")]
            public int ToolbarLeft
            {
                get
                {
                    Key = SettingsConstants.ADDINKEY;
                    return (int)_settings["ToolbarLeft"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ADDINKEY;
                    _settings["ToolbarLeft"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [SettingsGroupDescriptionAttribute("Addin")]
            public int ToolbarTop
            {
                get
                {
                    Key = SettingsConstants.ADDINKEY;
                    return (int)_settings["ToolbarTop"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ADDINKEY;
                    _settings["ToolbarTop"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [SettingsGroupDescriptionAttribute("Addin")]
            public int ToolbarPosition
            {
                get
                {
                    Key = SettingsConstants.ADDINKEY;
                    return (int)_settings["ToolbarPosition"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.ADDINKEY;
                    _settings["ToolbarPosition"] = value;
                }
            }
            #endregion
    
            #region Help
            
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("")]
            [SettingsGroupDescriptionAttribute("Help")]
            public string Checksum
            {
                get
                {
                    Key = SettingsConstants.HELPKEY;
                    return (string)_settings["Checksum"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.HELPKEY;
                    _settings["Checksum"] = value;
                }
            }
            #endregion
    
            #region Wsrds
    
            public const string DEWSRDS_SERVER_ADDRESS_DEFAULT = "www.wsrds.thomsonone.com";
            public const string DEWSRDS_SERVER_ADDRESS_DEFAULT_HTTPS = "https://www.wsrds.thomsonone.com";
    
            [UserScopedSetting()]
            [DefaultSettingValue("8")]
            [DiagnosticsHint(true, "2", "4", "8")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string DEWsrdsConnectionMode
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["DEWsrdsConnectionMode"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["DEWsrdsConnectionMode"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("https://www.wsrds.thomsonone.com")]
            [DiagnosticsHint(true, "https://www.wsrds.thomsonone.com", "www.wsrds.thomsonone.com")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string DEWsrdsServerAddress
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["DEWsrdsServerAddress"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["DEWsrdsServerAddress"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("")]
            [DiagnosticsHint(true)]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string DEWsrdsOverriddenIlxId
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["DEWsrdsOverriddenIlxId"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["DEWsrdsOverriddenIlxId"] = value;
                }
            }
    
    
            [UserScopedSetting()]
            [DefaultSettingValue("")]
            [DiagnosticsHint(true, "NamedPipe", "TCP")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string WsrdsConnectionMode
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["WsrdsConnectionMode"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["WsrdsConnectionMode"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("https://streaming.t1wfint.com")]
            [DiagnosticsHint(true, "https://streaming.thomsonone.com", "https://streaming.thomsononeqa.com", "https://streaming.t1wfint.com")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string WsrdsServerAddress
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["WsrdsServerAddress"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["WsrdsServerAddress"] = value;
                }
            }
    
    
            [UserScopedSetting()]
            [DefaultSettingValue("")]
            [DiagnosticsHint(true)]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string WsrdsExtraCommandLineSettings
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["WsrdsExtraCommandLineSettings"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["WsrdsExtraCommandLineSettings"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("Info")]
            [DiagnosticsHint(true, "Error", "Warning", "Info", "Trace", "Verbose")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string WsrdsLogLevel
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["WsrdsLogLevel"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["WsrdsLogLevel"] = value;
                }
            }
    
    
            [UserScopedSetting()]
            [DefaultSettingValue("false")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public bool WsrdsWindowVisible
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (bool)_settings["WsrdsWindowVisible"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["WsrdsWindowVisible"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("false")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public bool WsrdsOverrideT1ThinCookie
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (bool)_settings["WsrdsOverrideT1ThinCookie"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["WsrdsOverrideT1ThinCookie"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("http://www.thomsonone.com")]
            [DiagnosticsHint(true, "http://www.thomsonone.com", "http://www.thomsononeqa.com", "http://www.t1wfint.com")]
            [SettingsGroupDescriptionAttribute("Wsrds")]
            public string WsrdsT1ThinCookieUrl
            {
                get
                {
                    Key = SettingsConstants.WSRDSKEY;
                    return (string)_settings["WsrdsT1ThinCookieUrl"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.WSRDSKEY;
                    _settings["WsrdsT1ThinCookieUrl"] = value;
                }
            }
    
    
            #endregion
    
            #region Clickthru
    
            [UserScopedSetting()]
            [DefaultSettingValue("true")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("ClickThru")]
            public bool ClickthruEnabled
            {
                get
                {
                    Key = SettingsConstants.CLICKTHRUKEY;
                    if (_settings["ClickthruEnabled"] == null)
                        return AppSettings.Settings.ClickThru.Enabled;
                    else
                        return (bool)_settings["ClickthruEnabled"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.CLICKTHRUKEY;
                    _settings["ClickthruEnabled"] = value;
                    UserSettingsProvider.OnStateChanged();
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("http://164.179.238.41/Fundamentals.WebServices/FundamentalsClickThru.asmx")]
            [DiagnosticsHint(false, "http://164.179.238.41/Fundamentals.WebServices/FundamentalsClickThru.asmx")]
            [SettingsGroupDescriptionAttribute("ClickThru")]
            public string ClickthruWebServiceUrl
            {
                get
                {
                    return AppSettings.Settings.ClickThru.WebServiceUrl;
                }
    
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("true")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("ClickThru")]
            public bool ClickthruAskForWindowSelection
            {
                get
                {
                    Key = SettingsConstants.CLICKTHRUKEY;
                    return (bool)_settings["ClickthruAskForWindowSelection"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.CLICKTHRUKEY;
                    _settings["ClickthruAskForWindowSelection"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DefaultSettingValue("True")]
            [DiagnosticsHint(true, "True", "False")]
            [SettingsGroupDescriptionAttribute("ClickThru")]
            public bool ClickthruLoadInCurrentWindow
            {
                get
                {
                    Key = SettingsConstants.CLICKTHRUKEY;
                    return (bool)_settings["ClickthruLoadInCurrentWindow"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.CLICKTHRUKEY;
                    _settings["ClickthruLoadInCurrentWindow"] = value;
                }
            }
    
            [UserScopedSetting()]
            [DiagnosticsHint(true)]
            [DefaultSettingValue("0")]
            [SettingsGroupDescriptionAttribute("ClickThru")]
            public int ClickThruOverwriteColor
            {
                get
                {
                    Key = SettingsConstants.CLICKTHRUKEY;
                    return (int)_settings["ClickThruOverwriteColor"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.CLICKTHRUKEY;
                    _settings["ClickThruOverwriteColor"] = value;
                }
            }
            #endregion
    
            #region Diagnostics
    
            [UserScopedSetting()]
            [DefaultSettingValue("tf-tf-webqaapplicationsupport@thomson.com")]
            [DiagnosticsHint(true, "tf-tf-webqaapplicationsupport@thomson.com")]
            [SettingsGroupDescriptionAttribute("Diagnostics")]
            public string DiagnosticsLogSendEmailId
            {
                get
                {
                    Key = SettingsConstants.DIAGNOSTICSKEY;
                    return (string)_settings["DiagnosticsLogSendEmailId"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.DIAGNOSTICSKEY;
                    _settings["DiagnosticsLogSendEmailId"] = value;
                }
            }
    
    
            #endregion
    
            #region SystemInformation
    
            [UserScopedSetting()]
            [SettingsGroupDescriptionAttribute("SystemInformation")]
            public string MaxClockSpeeds
            {
                get
                {
                    Key = SettingsConstants.SYSTEMINFORMATIONKEY;
                    return (string)_settings["MaxClockSpeeds"];
                }
                set
                {
                    _settings.SettingsKey = SettingsConstants.SYSTEMINFORMATIONKEY;
                    _settings["MaxClockSpeeds"] = value;
                }
            }
    
            #endregion
    
            #endregion
    
            #region Helper Methods
            public static void SaveSetting(string key, string settingsValue)
            {
                Settings.SettingsKey = key;
                switch (key)
                {
                    case "ExpressionBuilder.General": Settings.ExpressionbuilderSettingsGeneral = settingsValue;
                        break;
                    case "ExpressionBuilderWrapper.Export": Settings.ExpressionbuilderSettingsExport = settingsValue;
                        break;
                    case "DILookup.General": Settings.DILookUpSettnigsGeneral = settingsValue;
                        break;
                    case "DILookupWrapper.Export": Settings.DILookUpSettingsExport = settingsValue;
                        break;
                    case "IDLookup.General": Settings.IDLookUpSettingsGeneral = settingsValue;
                        break;
                    case "IDLookupWrapper.Export": Settings.IDLookUpSettingsExport = settingsValue;
                        break;
                    case "ScreenBuilderWrapper.Export": Settings.ScreenBuilderSettingsExport = settingsValue;
                        break;
                    case "ScreenBuilder.General": Settings.ScreenBuilderSettingsGeneral = settingsValue;
                        break;
                    case "ReportBuilder.General": Settings.ReportBuilderSettingsGeneral = settingsValue;
                        break;
                    case "ReportBuilderWrapper.Export": Settings.ReportBuilderSettingsExport = settingsValue;
                        break;
                    case "ConstituentLookup.General": Settings.ConstituentLookupGeneralSettings = settingsValue;
                        break;
                    case "ConstiLookupWrapper.Export": Settings.ConstituentLookupExportSettings = settingsValue;
                        break;
                    case "AggBuilderWrapper.Export": Settings.AggBuilderExportSettings = settingsValue;
                        break;
                    default:
                        try
                        {
                            // Try to find a matching item in our settings
                            string nameToMatch = key.Contains(".") ? key.Substring(key.IndexOf(".") + 1) : key.Contains("\\") ? key.Substring(key.IndexOf("\\") + 1) : key;
                            var prop = typeof(UserSettings).GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).FirstOrDefault(x => x.Name == nameToMatch);
                            if (prop != null && prop.CanWrite)
                            {
                                object valToUse = Convert.ChangeType(settingsValue, prop.PropertyType);
                                prop.SetValue(Settings, valToUse, null);
                            }
                        }
                        catch (Exception excep)
                        {
                            Debug.Assert(false, "Error while setting a non-declared property." + excep.ToString());
                        }
    
                        break;
                }
            }
    
            public static string GetSettings(string settingsKey)
            {
                _settings = new UserSettings();
                _settings.SettingsKey = settingsKey;
    
                string value = null;
                switch (settingsKey)
                {
                    case "ExpressionBuilder.General": value = _settings.ExpressionbuilderSettingsGeneral;
                        break;
                    case "ExpressionBuilderWrapper.Export": value = _settings.ExpressionbuilderSettingsExport;
                        break;
                    case "DILookup.General": value = _settings.DILookUpSettnigsGeneral;
                        break;
                    case "DILookupWrapper.Export": value = _settings.DILookUpSettingsExport;
                        break;
                    case "IDLookup.General": value = _settings.IDLookUpSettingsGeneral;
                        break;
                    case "IDLookupWrapper.Export": value = _settings.IDLookUpSettingsExport;
                        break;
                    case "ScreenBuilderWrapper.Export": value = _settings.ScreenBuilderSettingsExport;
                        break;
                    case "ScreenBuilder.General": value = _settings.ScreenBuilderSettingsGeneral;
                        break;
                    case "ReportBuilder.General": value = _settings.ReportBuilderSettingsGeneral;
                        break;
                    case "ReportBuilderWrapper.Export": value = _settings.ReportBuilderSettingsExport;
                        break;
                    case "ConstituentLookup.General": value = _settings.ConstituentLookupGeneralSettings;
                        break;
                    case "ConstiLookupWrapper.Export": value = _settings.ConstituentLookupExportSettings;
                        break;
                    case "AggBuilderWrapper.Export": value = _settings.AggBuilderExportSettings;
                        break;
                    case "ServerAddress": value = _settings.ServerAddress;
                        break;
                    case "UserName": value = _settings.UserName;
                        break;
                    case "Password": value = _settings.Password;
                        break;                
                    default:
                        try
                        {
                            // Try to find a matching item in our settings
                            string nameToMatch = settingsKey.Contains(".") ? settingsKey.Substring(settingsKey.IndexOf(".") + 1) : settingsKey.Contains("\\") ? settingsKey.Substring(settingsKey.IndexOf("\\") + 1) : settingsKey;
                            var prop = typeof(UserSettings).GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).FirstOrDefault(x => x.Name == nameToMatch);
                            if (prop != null && prop.CanRead)
                                value = (prop.GetValue(Settings, null) ?? string.Empty).ToString();
                        }
                        catch (Exception excep)
                        {
                            Debug.Assert(false, "Error while getting a non-declared property." + excep.ToString());
                        }
                        break;
                }
                return value;
            }
    
            private void InitializeSetting(string value)
            {
                _settings = new UserSettings();
                _settings.SettingsKey = value;
            }
    
            #endregion
    
            #region overrides
    
            protected override void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
            {
                if (_settings != null)
                {
                    base.OnPropertyChanged(sender, e);
                    SettingsDictionary.objects[_settings.SettingsKey] = _settings;
                    _settings.Save();
                }
            }
    
            #endregion
    
            #region Nested Class
    
            internal static class SettingsDictionary
            {
                internal static List<string> _keys = new List<string>()
                {
                    SettingsConstants.OPTIONSKEY,
                    SettingsConstants.CHARTBUILDERKEY,
                    SettingsConstants.ERRORMESSAGEKEY,
                    SettingsConstants.DISPLAYKEY,
                    SettingsConstants.HELPKEY,
                    SettingsConstants.WSRDSKEY,
                    SettingsConstants.CLICKTHRUKEY,                
                    SettingsConstants.DIAGNOSTICSKEY,
                    SettingsConstants.SYSTEMINFORMATIONKEY
                };
    
                public static Dictionary<string, UserSettings> objects = new Dictionary<string, UserSettings>();
    
                public static UserSettings GetUserSetting(string key)
                {
                    if (!objects.ContainsKey(key))
                    {
                      objects.Add(key, new UserSettings() { SettingsKey = key });
                    }
                
                    return objects[key];
                }
            }
    
            #endregion
        }


    Can you let me know what is wrong with this???

    I just hope u see this question and reply back.. Thanks 

     

    Monday, April 19, 2010 8:31 AM