[tasque] Extract interface from Preferences class



commit 52a2933caecac9604a823195f96726cc08b25c18
Author: Antonius Riha <antoniusriha gmail com>
Date:   Thu Jan 3 17:09:33 2013 +0100

    Extract interface from Preferences class

 src/libtasque/IPreferences.cs  |   44 ++++++++++++++++++++++++++++++++++++++++
 src/libtasque/Preferences.cs   |    6 +---
 src/libtasque/libtasque.csproj |    1 +
 3 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/src/libtasque/IPreferences.cs b/src/libtasque/IPreferences.cs
new file mode 100644
index 0000000..9828a3e
--- /dev/null
+++ b/src/libtasque/IPreferences.cs
@@ -0,0 +1,44 @@
+//
+// IPreferences.cs
+//
+// Author:
+//       Antonius Riha <antoniusriha gmail com>
+//
+// Copyright (c) 2012 Antonius Riha
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System.Collections.Generic;
+
+namespace Tasque
+{
+	public delegate void SettingChangedHandler (Preferences preferences, string settingKey);
+
+	public interface IPreferences
+	{
+		string Get (string settingKey);
+		bool GetBool (string settingKey);
+		int GetInt (string settingKey);
+		List<string> GetStringList (string settingKey);
+		void Set (string settingKey, string settingValue);
+		void SetBool (string settingKey, bool settingValue);
+		void SetInt (string settingKey, int settingValue);
+		void SetStringList (string settingKey, List<string> stringList);
+		event SettingChangedHandler SettingChanged;
+	}
+}
diff --git a/src/libtasque/Preferences.cs b/src/libtasque/Preferences.cs
index 874d1b3..ae7992b 100644
--- a/src/libtasque/Preferences.cs
+++ b/src/libtasque/Preferences.cs
@@ -38,7 +38,7 @@ namespace Tasque
 	// <summary>
 	// Class used to store Tasque preferences
 	// </summary>
-	public class Preferences
+	public class Preferences : IPreferences
 	{
 		private System.Xml.XmlDocument document;
 		private string location;
@@ -72,9 +72,7 @@ namespace Tasque
 		/// A <see cref="System.String"/>
 		/// </returns>
 		public const string CompletedTasksRange = "CompletedTasksRange";
-		
-		public delegate void SettingChangedHandler (Preferences preferences,
-													string settingKey);
+
 		public event SettingChangedHandler SettingChanged;
 		
 		public string Get (string settingKey)
diff --git a/src/libtasque/libtasque.csproj b/src/libtasque/libtasque.csproj
index b1df76e..870c1d5 100644
--- a/src/libtasque/libtasque.csproj
+++ b/src/libtasque/libtasque.csproj
@@ -78,6 +78,7 @@
     <Compile Include="CategoryComparer.cs" />
     <Compile Include="TaskComparer.cs" />
     <Compile Include="AllCategory.cs" />
+    <Compile Include="IPreferences.cs" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="DateFormatters\" />



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]