コード例 #1
0
 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);
             }
         }
     }
 }
コード例 #2
0
        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)
                        {
                            SDVPApplication.ReportException(exception);
                        }
                    }
                }
            }
            catch (Exception exception2)
            {
                SDVPApplication.ReportException(exception2);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: Proxy.cs プロジェクト: Arsslensoft/WKDV
 private void onNetworkPrefsChange(object sender, PrefChangeEventArgs oPCE)
 {
     if (oPCE.PrefName == "SDVP.network.sockets.ClientReadBufferSize")
     {
         ClientChatter._cbClientReadBuffer = SDVPApplication.Prefs.GetInt32Pref("SDVP.network.sockets.ClientReadBufferSize", 0x2000);
     }
     if (oPCE.PrefName == "SDVP.network.sockets.ServerReadBufferSize")
     {
         ServerChatter._cbServerReadBuffer = SDVPApplication.Prefs.GetInt32Pref("SDVP.network.sockets.ServerReadBufferSize", 0x8000);
     }
     if (oPCE.PrefName == "SDVP.network.egress.ip")
     {
         this.SetDefaultEgressEndPoint(oPCE.ValueString);
     }
     else if (oPCE.PrefName == "SDVP.network.https.NoDecryptionHosts")
     {
         Browser.SetNoDecryptList(oPCE.ValueString);
     }
     else if (oPCE.PrefName == "SDVP.network.proxy.RegistrationHostName")
     {
         Browser.sSDVPListenHostPort = SDVPApplication.Prefs.GetStringPref("SDVP.network.proxy.RegistrationHostName", "127.0.0.1") + ":" + Browser.ListenPort.ToString();
     }
 }
コード例 #5
0
 private void AsyncNotifyWatchers(PrefChangeEventArgs oNotifyArgs)
 {
     ThreadPool.UnsafeQueueUserWorkItem(new WaitCallback(this._NotifyThreadExecute), oNotifyArgs);
 }