public string this[string sPrefName] { get { string str; try { GetReaderLock(this._RWLockPrefs); str = this._dictPrefs[sPrefName]; } finally { FreeReaderLock(this._RWLockPrefs); } return(str); } set { if (!this.isValidName(sPrefName)) { throw new ArgumentException(string.Format("Preference name must contain 1 or more characters from the set A-z0-9-_ and may not contain the word Internal.\nYou tried to set: \"{0}\"", sPrefName)); } if (value == null) { this.RemovePref(sPrefName); } else { bool flag = false; try { GetWriterLock(this._RWLockPrefs); flag = !this._dictPrefs.ContainsKey(sPrefName) || (this._dictPrefs[sPrefName] != value); this._dictPrefs[sPrefName] = value; } finally { FreeWriterLock(this._RWLockPrefs); } if (flag) { PrefChangeEventArgs oNotifyArgs = new PrefChangeEventArgs(sPrefName, value); this.AsyncNotifyWatchers(oNotifyArgs); } } } }
private void _NotifyThreadExecute(object objThreadState) { PrefChangeEventArgs e = (PrefChangeEventArgs)objThreadState; string prefName = e.PrefName; List <EventHandler <PrefChangeEventArgs> > list = null; try { GetReaderLock(this._RWLockWatchers); try { foreach (PrefWatcher watcher in this._listWatchers) { if (prefName.StartsWith(watcher.sPrefixToWatch, StringComparison.Ordinal)) { if (list == null) { list = new List <EventHandler <PrefChangeEventArgs> >(); } list.Add(watcher.fnToNotify); } } } finally { FreeReaderLock(this._RWLockWatchers); } if (list != null) { foreach (EventHandler <PrefChangeEventArgs> handler in list) { try { handler(this, e); } catch (Exception exception) { KProxyApplication.ReportException(exception); } } } } catch (Exception exception2) { KProxyApplication.ReportException(exception2); } }
public void RemovePref(string sPrefName) { bool flag = false; try { GetWriterLock(this._RWLockPrefs); flag = this._dictPrefs.ContainsKey(sPrefName); this._dictPrefs.Remove(sPrefName); } finally { FreeWriterLock(this._RWLockPrefs); } if (flag) { PrefChangeEventArgs oNotifyArgs = new PrefChangeEventArgs(sPrefName, null); this.AsyncNotifyWatchers(oNotifyArgs); } }
private void onNetworkPrefsChange(object sender, PrefChangeEventArgs oPCE) { if (oPCE.PrefName == "KProxy.network.sockets.ClientReadBufferSize") { ClientChatter._cbClientReadBuffer = KProxyApplication.Prefs.GetInt32Pref("KProxy.network.sockets.ClientReadBufferSize", 0x2000); } if (oPCE.PrefName == "KProxy.network.sockets.ServerReadBufferSize") { ServerChatter._cbServerReadBuffer = KProxyApplication.Prefs.GetInt32Pref("KProxy.network.sockets.ServerReadBufferSize", 0x8000); } if (oPCE.PrefName == "KProxy.network.egress.ip") { this.SetDefaultEgressEndPoint(oPCE.ValueString); } else if (oPCE.PrefName == "KProxy.network.https.NoDecryptionHosts") { KPCONFIG.SetNoDecryptList(oPCE.ValueString); } else if (oPCE.PrefName == "KProxy.network.proxy.RegistrationHostName") { KPCONFIG.sKProxyListenHostPort = KProxyApplication.Prefs.GetStringPref("KProxy.network.proxy.RegistrationHostName", "127.0.0.1") + ":" + KPCONFIG.ListenPort.ToString(); } }
private void AsyncNotifyWatchers(PrefChangeEventArgs oNotifyArgs) { ThreadPool.UnsafeQueueUserWorkItem(new WaitCallback(this._NotifyThreadExecute), oNotifyArgs); }