ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/xmltv_parser/trunk/libxmltv/Core/Internals.cs
Revision: 22
Committed: Thu Mar 7 10:20:50 2013 UTC (10 years, 6 months ago) by william
File size: 849 byte(s)
Log Message:

File Contents

# User Rev Content
1 william 22 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     }