static public bool Commit() { try { XmlStream stream = new XmlStream("webproxy"); stream.Save("useproxy", (int)_useProxy); stream.Save("server", _server); stream.Save("port", _port); stream.Save("exceptions", _exceptions); stream.Save("domain", _domain); stream.Save("user", _user); stream.Save("password", _password); stream.WriteStream(SystemVariables.CommonApplicationData + @"/options_webproxy.xml"); ProxySettings.LoadProxy(); return(true); } catch { return(false); } }
static public void Load() { try { _loaded = true; XmlStream stream = new XmlStream("webproxy"); if (!stream.ReadStream(SystemVariables.CommonApplicationData + @"/options_webproxy.xml")) { stream = new XmlStream("webproxy"); stream.Save("useproxy", (int)UseProxyType.none); stream.Save("server", String.Empty); stream.Save("port", 80); stream.Save("exceptions", "localhost;127.0.0.1"); stream.Save("domain", String.Empty); stream.Save("user", String.Empty); stream.Save("password", String.Empty); stream.WriteStream(SystemVariables.CommonApplicationData + @"/options_webproxy.xml"); stream = new XmlStream("webproxy"); stream.ReadStream(SystemVariables.CommonApplicationData + @"/options_webproxy.xml"); } _useProxy = (UseProxyType)stream.Load("useproxy"); _server = (string)stream.Load("server", ""); _port = (int)stream.Load("port", 80); _exceptions = (string)stream.Load("exceptions", ""); _domain = (string)stream.Load("domain", ""); _user = (string)stream.Load("user", ""); _password = (string)stream.Load("password", ""); ProxySettings.LoadProxy(); } catch (Exception ex) { LastErrorMessage = ex.Message; _useProxy = UseProxyType.defaultProxy; } }