/[xmltv_parser]/trunk/libxmltv/Core/XMLTVSerializer.cs
ViewVC logotype

Diff of /trunk/libxmltv/Core/XMLTVSerializer.cs

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

--- trunk/libxmltv/Core/XMLTVSerializer.cs	2013/03/08 05:20:12	49
+++ trunk/libxmltv/Core/XMLTVSerializer.cs	2013/03/10 17:41:52	118
@@ -10,7 +10,7 @@
 
 namespace libxmltv.Core
 {
-    public class XMLTVSerializer<T> : IXMLTVSerializer<T>
+    internal class XMLTVSerializer<T> : IXMLTVSerializer<T>
     {
         private T data;
         public XMLTVSerializer(T Data) { data = Data; }
@@ -18,6 +18,7 @@
         public bool Serialize(string file)
         {
             bool retVal = false;
+            xmltv_logger.Debug.WriteLine("Serializing data to file: '{0}'", file);
             using (Stream stream = File.Open(file, FileMode.Create)) { retVal = Serialize(stream); }
             return retVal;
         }
@@ -25,29 +26,34 @@
         {
             try
             {
+                xmltv_logger.Debug.WriteLine("Serializing data to stream");
                 BinaryFormatter bin = new BinaryFormatter();
                 bin.Serialize(stream, data);
+                xmltv_logger.Debug.WriteLine("Serialized data to stream");
             }
-            catch (Exception ex) { xmltv_logger.Log.Error.WriteLine(ex.ToString()); return false; }
+            catch (Exception ex) { xmltv_logger.Error.WriteLine(ex.ToString()); return false; }
             return true;
         }
-        public bool DeSerialize(string file, out T unpacked_data)
+        public T DeSerialize(string file, out bool status)
         {
-            unpacked_data = default(T);
-            bool retVal = false;
-            using (Stream stream = File.Open(file, FileMode.Open)) { retVal = DeSerialize(stream, out unpacked_data); }
-            return retVal;
+           T  unpacked_data = default(T);
+           xmltv_logger.Debug.WriteLine("DeSerializing data from file: '{0}'", file);
+            using (Stream stream = File.Open(file, FileMode.Open)) { unpacked_data = DeSerialize(stream, out status); }
+            return unpacked_data;
         }
-        public bool DeSerialize(Stream stream, out T unpacked_data)
+        public T DeSerialize(Stream stream, out bool status)
         {
-            unpacked_data = default(T);
+           T unpacked_data = default(T);
             try
             {
+                xmltv_logger.Debug.WriteLine("DeSerializing data from stream");
                 BinaryFormatter bin = new BinaryFormatter();
                 unpacked_data = (T)bin.Deserialize(stream);
+                xmltv_logger.Debug.WriteLine("DeSerialized data from stream");
             }
-            catch (Exception ex) { xmltv_logger.Log.Error.WriteLine(ex.ToString()); return false; }
-            return true;
+            catch (Exception ex) { xmltv_logger.Error.WriteLine(ex.ToString()); status = false; }
+            status = true;
+            return unpacked_data;
         }
         #endregion
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22