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 |
|
|
|
10 |
|
|
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 |
|
|
|
28 |
|
|
#region IXMLTVBase members |
29 |
|
|
public T GetInstance() { return TryConvertInstance(Instance); } |
30 |
|
|
#endregion |
31 |
|
|
|
32 |
william |
73 |
|
33 |
|
|
private object _handler; |
34 |
|
|
public object Handler |
35 |
|
|
{ |
36 |
|
|
get { return _handler; } |
37 |
|
|
private set { _handler = value; } |
38 |
|
|
} |
39 |
william |
72 |
} |
40 |
|
|
} |