[blam] Channel: Get an ItemStore instance on ctor



commit 837959d0d7cb3a88c4055cffe1f67cdb0a47c91e
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Thu Sep 16 18:47:33 2010 +0100

    Channel: Get an ItemStore instance on ctor

 src/Channel.cs   |   28 ++++++++++++++++------------
 src/ItemStore.cs |    8 ++++----
 2 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/src/Channel.cs b/src/Channel.cs
index bbb9732..1202856 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -39,6 +39,8 @@ namespace Imendio.Blam {
 		[XmlAttribute] public string http_username = "";
 		[XmlAttribute] public string http_password = "";
 
+        ItemStore store = null;
+
         private Gtk.TreeIter mIter;
 
         public string Name {
@@ -114,19 +116,21 @@ namespace Imendio.Blam {
             }
         }
 
-		public Channel ()
-		{
-			mItems = new Hashtable ();
-			mIter = new Gtk.TreeIter();
-		}
+        public Channel ()
+        {
+            mItems = new Hashtable ();
+            mIter = new Gtk.TreeIter();
+            store = ItemStore.GetInstance();
+        }
 
-		public Channel (string name, string url)
-		{
-			mItems = new Hashtable ();
-			mIter = new Gtk.TreeIter();
-			Name = name;
-			Url = url;
-		}
+        public Channel (string name, string url)
+        {
+            mItems = new Hashtable ();
+            mIter = new Gtk.TreeIter();
+            store = ItemStore.GetInstance();
+            Name = name;
+            Url = url;
+        }
 
         public Item GetItem (string id)
         {
diff --git a/src/ItemStore.cs b/src/ItemStore.cs
index f6a74bd..4825ac5 100644
--- a/src/ItemStore.cs
+++ b/src/ItemStore.cs
@@ -10,7 +10,7 @@ namespace Imendio.Blam
     public class ItemStore
     {
         Hashtable items;
-        ItemStore instance = null;
+        static ItemStore instance = null;
         static XmlSerializer serializer = new XmlSerializer(typeof(ItemStore));
         static string itemfile = Defines.APP_HOMEDIR + "/" + Defines.APP_ITEMSTORE_FILE;
 
@@ -26,7 +26,7 @@ namespace Imendio.Blam
             items.Add(item.Id, item);
         }
 
-        public ItemStore GetInstance()
+        public static ItemStore GetInstance()
         {
             if(instance == null){
                 Load();
@@ -35,13 +35,13 @@ namespace Imendio.Blam
             return instance;
         }
 
-        private void Load()
+        private static void Load()
         {
             XmlTextReader reader = new XmlTextReader(itemfile);
             instance = serializer.Deserialize(reader) as ItemStore;
         }
 
-        private void Save()
+        private static void Save()
         {
             Stream writer = new FileStream(itemfile, FileMode.Create);
             serializer.Serialize(writer, instance);



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