Пример #1
0
 public string this[string sPrefName]
 {
     get
     {
         string result;
         try
         {
             PreferenceBag.GetReaderLock(this._RWLockPrefs);
             result = this._dictPrefs[sPrefName];
         }
         finally
         {
             PreferenceBag.FreeReaderLock(this._RWLockPrefs);
         }
         return(result);
     }
     set
     {
         if (!PreferenceBag.isValidName(sPrefName))
         {
             throw new ArgumentException(string.Format("Preference name must contain 1 to 255 characters from the set A-z0-9-_ and may not contain the word Internal.\n\nCaller tried to set: \"{0}\"", sPrefName));
         }
         if (value == null)
         {
             this.RemovePref(sPrefName);
             return;
         }
         bool flag = false;
         try
         {
             PreferenceBag.GetWriterLock(this._RWLockPrefs);
             if (value != this._dictPrefs[sPrefName])
             {
                 flag = true;
                 this._dictPrefs[sPrefName] = value;
             }
         }
         finally
         {
             PreferenceBag.FreeWriterLock(this._RWLockPrefs);
         }
         if (flag)
         {
             PrefChangeEventArgs oNotifyArgs = new PrefChangeEventArgs(sPrefName, value);
             this.AsyncNotifyWatchers(oNotifyArgs);
         }
     }
 }
Пример #2
0
 public string[] GetPrefArray()
 {
     string[] result;
     try
     {
         PreferenceBag.GetReaderLock(this._RWLockPrefs);
         string[] array = new string[this._dictPrefs.Count];
         this._dictPrefs.Keys.CopyTo(array, 0);
         result = array;
     }
     finally
     {
         PreferenceBag.FreeReaderLock(this._RWLockPrefs);
     }
     return(result);
 }
Пример #3
0
        private void _NotifyThreadExecute(object objThreadState)
        {
            PrefChangeEventArgs prefChangeEventArgs = (PrefChangeEventArgs)objThreadState;
            string prefName = prefChangeEventArgs.PrefName;
            List <EventHandler <PrefChangeEventArgs> > list = null;

            try
            {
                PreferenceBag.GetReaderLock(this._RWLockWatchers);
                try
                {
                    foreach (PreferenceBag.PrefWatcher current in this._listWatchers)
                    {
                        if (prefName.OICStartsWith(current.sPrefixToWatch))
                        {
                            if (list == null)
                            {
                                list = new List <EventHandler <PrefChangeEventArgs> >();
                            }
                            list.Add(current.fnToNotify);
                        }
                    }
                }
                finally
                {
                    PreferenceBag.FreeReaderLock(this._RWLockWatchers);
                }
                if (list != null)
                {
                    foreach (EventHandler <PrefChangeEventArgs> current2 in list)
                    {
                        try
                        {
                            current2(this, prefChangeEventArgs);
                        }
                        catch (Exception eX)
                        {
                            FiddlerApplication.ReportException(eX);
                        }
                    }
                }
            }
            catch (Exception eX2)
            {
                FiddlerApplication.ReportException(eX2);
            }
        }
Пример #4
0
        internal string FindMatches(string sFilter)
        {
            StringBuilder stringBuilder = new StringBuilder(128);

            try
            {
                PreferenceBag.GetReaderLock(this._RWLockPrefs);
                foreach (DictionaryEntry dictionaryEntry in this._dictPrefs)
                {
                    if (((string)dictionaryEntry.Key).OICContains(sFilter))
                    {
                        stringBuilder.AppendFormat("{0}:\t{1}\r\n", dictionaryEntry.Key, dictionaryEntry.Value);
                    }
                }
            }
            finally
            {
                PreferenceBag.FreeReaderLock(this._RWLockPrefs);
            }
            return(stringBuilder.ToString());
        }
Пример #5
0
        private void WriteRegistry()
        {
            if (CONFIG.bIsViewOnly)
            {
                return;
            }
            if (this._sRegistryPath == null)
            {
                return;
            }
            RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(this._sRegistryPath, RegistryKeyPermissionCheck.ReadWriteSubTree);

            if (registryKey == null)
            {
                return;
            }
            try
            {
                PreferenceBag.GetReaderLock(this._RWLockPrefs);
                registryKey.DeleteSubKey(this._sCurrentProfile, false);
                if (this._dictPrefs.Count >= 1)
                {
                    registryKey = registryKey.CreateSubKey(this._sCurrentProfile, RegistryKeyPermissionCheck.ReadWriteSubTree);
                    foreach (DictionaryEntry dictionaryEntry in this._dictPrefs)
                    {
                        string text = (string)dictionaryEntry.Key;
                        if (!text.OICContains("ephemeral"))
                        {
                            registryKey.SetValue(text, dictionaryEntry.Value);
                        }
                    }
                }
            }
            finally
            {
                PreferenceBag.FreeReaderLock(this._RWLockPrefs);
                registryKey.Close();
            }
        }
Пример #6
0
        public string ToString(bool bVerbose)
        {
            StringBuilder stringBuilder = new StringBuilder(128);

            try
            {
                PreferenceBag.GetReaderLock(this._RWLockPrefs);
                stringBuilder.AppendFormat("PreferenceBag [{0} Preferences. {1} Watchers.]", this._dictPrefs.Count, this._listWatchers.Count);
                if (bVerbose)
                {
                    stringBuilder.Append("\n");
                    foreach (DictionaryEntry dictionaryEntry in this._dictPrefs)
                    {
                        stringBuilder.AppendFormat("{0}:\t{1}\n", dictionaryEntry.Key, dictionaryEntry.Value);
                    }
                }
            }
            finally
            {
                PreferenceBag.FreeReaderLock(this._RWLockPrefs);
            }
            return(stringBuilder.ToString());
        }