PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/src/NUnit/util/MemorySettingsStorage.cs

#
C# | 79 lines | 50 code | 16 blank | 13 comment | 2 complexity | c7327d3fc17f9d45b55bbd0a42b47d8f MD5 | raw file
Possible License(s): GPL-2.0
  1. // ****************************************************************
  2. // Copyright 2007, Charlie Poole
  3. // This is free software licensed under the NUnit license. You may
  4. // obtain a copy of the license at http://nunit.org
  5. // ****************************************************************
  6. using System;
  7. using System.Collections;
  8. namespace NUnit.Util
  9. {
  10. /// <summary>
  11. /// MemorySettingsStorage is used to hold settings for
  12. /// the NUnit tests and also serves as the base class
  13. /// for XmlSettingsStorage.
  14. /// </summary>
  15. public class MemorySettingsStorage : ISettingsStorage
  16. {
  17. protected Hashtable settings = new Hashtable();
  18. #region ISettingsStorage Members
  19. public object GetSetting(string settingName)
  20. {
  21. return settings[settingName];
  22. }
  23. public void RemoveSetting(string settingName)
  24. {
  25. settings.Remove( settingName );
  26. }
  27. public void RemoveGroup( string groupName )
  28. {
  29. ArrayList keysToRemove = new ArrayList();
  30. string prefix = groupName;
  31. if ( !prefix.EndsWith(".") )
  32. prefix = prefix + ".";
  33. foreach( string key in settings.Keys )
  34. if ( key.StartsWith( prefix ) )
  35. keysToRemove.Add( key );
  36. foreach( string key in keysToRemove )
  37. settings.Remove( key );
  38. }
  39. public void SaveSetting(string settingName, object settingValue)
  40. {
  41. settings[settingName] = settingValue;
  42. }
  43. public ISettingsStorage MakeChildStorage(string name)
  44. {
  45. return new MemorySettingsStorage();
  46. }
  47. public virtual void LoadSettings()
  48. {
  49. // No action required
  50. }
  51. public virtual void SaveSettings()
  52. {
  53. // No action required
  54. }
  55. #endregion
  56. #region IDisposable Members
  57. public void Dispose()
  58. {
  59. // TODO: Add MemorySettingsStorage.Dispose implementation
  60. }
  61. #endregion
  62. }
  63. }