/[xmltv_parser]/trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs
ViewVC logotype

Diff of /trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs	2013/03/17 01:50:27	220
+++ trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs	2013/03/17 02:23:17	221
@@ -46,7 +46,7 @@
 
         #region DATABASE DEFINITIONS
 
-        public interface ICHANNEL
+        public interface ICHANNEL : ICloneable
         {
             Int64 oid { get; }
             String name { get; }
@@ -55,7 +55,7 @@
             String favourite_channel { get; }
             String display_name { get; }
         }
-        private class CHANNEL : ICHANNEL
+        private class CHANNEL : ICHANNEL, ICloneable
         {
             public CHANNEL()
             {
@@ -75,8 +75,15 @@
             public String favourite_channel { get; set; }
             public String display_name { get; set; }
             #endregion
+
+            public object Clone()
+            {
+                CHANNEL p = new CHANNEL();
+                BaseDatabaseDefinition<CHANNEL>.Create(this, ref p);
+                return p;   
+            }
         }
-        public interface IRECORDING_SCHEDULE
+        public interface IRECORDING_SCHEDULE : ICloneable
         {
             Int64 oid { get; }
             Int64 programme_oid { get; }
@@ -130,6 +137,23 @@
                     throw ex;
                 }
             }
+            public static void Create(T source, ref T destination)
+            {
+                Type t = source.GetType();
+                var props = t.GetProperties();
+                foreach (var prop in props)
+                {
+                    try
+                    {
+                        object value = prop.GetValue(source, null);
+                        prop.SetValue(destination, value, null);
+                    }
+                    catch (Exception ex)
+                    {
+                        throw ex;
+                    }
+                }
+            }
             public static void Create(ref T instance, SQLiteDataReader r, int index)
             {
                 string field_name = r.GetName(index);
@@ -174,7 +198,7 @@
             }
         }
 
-        private class RECORDING_SCHEDULE : IRECORDING_SCHEDULE
+        private class RECORDING_SCHEDULE : IRECORDING_SCHEDULE, ICloneable
         {
             public RECORDING_SCHEDULE()
             {
@@ -186,7 +210,12 @@
             {
                 BaseDatabaseDefinition<RECORDING_SCHEDULE>.Create(ref instance, r, index);
             }
-
+            public object Clone()
+            {
+                RECORDING_SCHEDULE p = new RECORDING_SCHEDULE();
+                BaseDatabaseDefinition<RECORDING_SCHEDULE>.Create(this, ref p);
+                return p;   
+            }
             #region IRECORDING_SCHEDULE members
             public Int64 oid { get; set; }
             public Int64 programme_oid { get; set; }
@@ -204,9 +233,11 @@
             public Int32 priority { get; set; }
             public String conversion_profile { get; set; }
             #endregion
+
+            
         }
 
-        public interface IPROGRAMME : IEquatable<IPROGRAMME>
+        public interface IPROGRAMME : IEquatable<IPROGRAMME>, ICloneable
         {
             Int64 oid { get; set; }
             String name { get; set; }
@@ -221,8 +252,16 @@
             string ToString();
             IProgramDefinition AsXMLTVProgramDefinition(ISQLLITE sqllite);
         }
-        private class PROGRAMME : IPROGRAMME
+        private class PROGRAMME : IPROGRAMME, ICloneable
         {
+
+            public object Clone()
+            {
+                PROGRAMME p = new PROGRAMME();
+                BaseDatabaseDefinition<PROGRAMME>.Create(this, ref p);
+                return p;   
+            }
+
             public PROGRAMME()
             {
                 BaseDatabaseDefinition<PROGRAMME>.CreateDefault(this);
@@ -293,6 +332,8 @@
             {
                 return this.ToString().GetHashCode();
             }
+
+            
         }
         #endregion
         private static class TABLES
@@ -377,8 +418,8 @@
                     // check if the xmltv entry has different data from the current program
                     if (!xmltv_entry.Equals(program_xmltv_entry))
                     {
-                        // data is different
-                        var updated_program = program;
+                        // data is different                        
+                        var updated_program = (IPROGRAMME)program.Clone();
 
                         if (program_xmltv_entry.Title != xmltv_entry.Title)
                         {

 

  ViewVC Help
Powered by ViewVC 1.1.22