1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
|
6 |
namespace libxmltv.Core |
7 |
{ |
8 |
internal static class Internals |
9 |
{ |
10 |
internal static bool VerifyInstance<T>(object xmltv, out T t) where T : class |
11 |
{ |
12 |
try |
13 |
{ |
14 |
t = null; |
15 |
if (xmltv == null) { return false; } |
16 |
t = (xmltv as T); |
17 |
if (t == null) { throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name)); } |
18 |
else { return true; } |
19 |
} |
20 |
catch (Exception ex) |
21 |
{ |
22 |
throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name), ex); |
23 |
} |
24 |
} |
25 |
} |
26 |
} |