/// <summary> /// Deserializes the object from Xml, and returns it. /// </summary> public static T ToObject <T>(this IMessage message) where T : class { try { if (null != message) { return((T)NMSConvert.DeserializeObjFromMessage(message)); } } catch (Exception ex) { Tracer.ErrorFormat("Error converting message to object: {0}", ex.Message); } return(null); }
/// <summary> /// Finds the <see cref="System.Type" /> associated with the given scheme. /// </summary> /// <param name="scheme">The scheme (e.g. <c>tcp</c>, <c>activemq</c> or <c>stomp</c>).</param> /// <returns>The <see cref="System.Type" /> of the ConnectionFactory that will be used /// to create the connection for the specified <paramref name="scheme" />.</returns> private static Type GetTypeForScheme(string scheme) { string[] paths = GetConfigSearchPaths(); string assemblyFileName; string factoryClassName; Type factoryType = null; Tracer.DebugFormat("Locating provider for scheme: {0}", scheme); if (LookupConnectionFactoryInfo(paths, scheme, out assemblyFileName, out factoryClassName)) { Assembly assembly = null; Tracer.DebugFormat("Attempting to load provider assembly: {0}", assemblyFileName); try { assembly = Assembly.Load(assemblyFileName); if (null != assembly) { Tracer.Debug("Succesfully loaded provider."); } } catch (Exception ex) { Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message); assembly = null; } if (null == assembly) { foreach (string path in paths) { string fullpath = Path.Combine(path, assemblyFileName) + ".dll"; Tracer.DebugFormat("Looking for: {0}", fullpath); if (File.Exists(fullpath)) { Tracer.Debug("\tAssembly found! Attempting to load..."); try { assembly = Assembly.LoadFrom(fullpath); } catch (Exception ex) { Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message); assembly = null; } if (null != assembly) { Tracer.Debug("Successfully loaded provider."); break; } Tracer.Debug("Failed to load provider. Continuing search..."); } } } if (null != assembly) { #if NETCF factoryType = assembly.GetType(factoryClassName, true); #else factoryType = assembly.GetType(factoryClassName, true, true); #endif if (null == factoryType) { Tracer.Fatal("Failed to load class factory from provider."); } } else { Tracer.Fatal("Failed to load provider assembly."); } } return(factoryType); }