using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace libxmltv.Core { internal static class Internals { internal static bool VerifyInstance(object xmltv, out T t) where T : class { try { t = null; if (xmltv == null) { return false; } t = (xmltv as T); if (t == null) { throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name)); } else { return true; } } catch (Exception ex) { throw new InvalidCastException(string.Format("Unable to cast type: {0} to {1}", xmltv.GetType().Name, typeof(T).Name), ex); } } } }