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

Annotation of /trunk/libxmltv/Core/XMLTVBase.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (hide annotations) (download)
Sat Mar 9 11:28:41 2013 UTC (7 years, 6 months ago) by william
File size: 1117 byte(s)

1 william 72 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using libxmltv.Interfaces;
6    
7     namespace libxmltv.Core
8     {
9 william 77 [Serializable]
10 william 72 internal abstract class XMLTVBase<T> : IXMLTVBase<T> where T: class, new()
11     {
12 william 73 public XMLTVBase(object instance, object handler) { this.Instance = instance; this.Handler = handler; }
13 william 72 private T TryConvertInstance(object instance)
14     {
15     try
16     {
17     T gInstance = (T)Convert.ChangeType(instance, typeof(T));
18     return gInstance;
19     }
20     catch (Exception ex)
21     {
22     xmltv_logger.Error.WriteLine(ex.ToString());
23     return new T();
24     }
25     }
26     private object Instance;
27     #region IXMLTVBase members
28     public T GetInstance() { return TryConvertInstance(Instance); }
29     #endregion
30 william 73 private object _handler;
31     public object Handler
32     {
33     get { return _handler; }
34     private set { _handler = value; }
35     }
36 william 72 }
37     }

  ViewVC Help
Powered by ViewVC 1.1.22