public override void SetupServiceBus(string[] assemblyPaths, CommandDefinition cmdDef) { _commandDef = cmdDef; List <Assembly> asms = new List <Assembly>(); foreach (string path in assemblyPaths) { foreach (string file in Directory.GetFiles(path, "*.dll")) { try { asms.Add(Assembly.LoadFrom(file)); } catch { } } } _bus = Configure.With(asms) .DefineEndpointName("SBMQM_NSB_XML") .DefaultBuilder() //.MsmqSubscriptionStorage() .DefiningCommandsAs(t => _commandDef.IsCommand(t)) .XmlSerializer() .MsmqTransport() .UnicastBus() .SendOnly(); }
public void SetupServiceBus(string[] assemblyPaths, CommandDefinition cmdDef, Dictionary <string, object> connectionSettings) { _commandDef = cmdDef; Console.Write(typeof(global::NServiceBus.Configure).FullName); List <Assembly> asms = new List <Assembly>(); foreach (string path in assemblyPaths) { foreach (string file in Directory.GetFiles(path, "*.dll")) { try { asms.Add(Assembly.LoadFrom(file)); } catch { } } } if (CommandContentFormat == "XML") { Configure.Serialization.Xml(); } else if (CommandContentFormat == "JSON") { Configure.Serialization.Json(); } _bus = Configure.With(asms) .DefineEndpointName("SBMQM_NSB") .DefaultBuilder() .DefiningCommandsAs(t => _commandDef.IsCommand(t)) .UseTransport <global::NServiceBus.Msmq>() .UnicastBus() .SendOnly(); }
public void SetupServiceBus(string[] assemblyPaths, CommandDefinition cmdDef, Dictionary <string, object> connectionSettings) { _commandDef = cmdDef; List <Assembly> asms = new List <Assembly>(); foreach (string path in assemblyPaths) { foreach (string file in Directory.GetFiles(path, "*.dll")) { try { asms.Add(Assembly.LoadFrom(file)); } catch { } } } asms.Add( Assembly.LoadFile(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\Adapters\NServiceBus4\NServiceBus.Azure.Transports.WindowsAzureServiceBus.dll")); if (CommandContentFormat == "XML") { _bus = Configure.With(asms) .DefineEndpointName("SBMQM_NSB") .DefaultBuilder() .DefiningCommandsAs(t => _commandDef.IsCommand(t)) .XmlSerializer() .UseTransport <AzureServiceBus>(() => (string)connectionSettings["connectionStr"]) .UnicastBus() .SendOnly(); } else if (CommandContentFormat == "JSON") { _bus = Configure.With(asms) .DefineEndpointName("SBMQM_NSB") .DefaultBuilder() .DefiningCommandsAs(t => _commandDef.IsCommand(t)) .JsonSerializer() .UseTransport <AzureServiceBus>(() => (string)connectionSettings["connectionStr"]) .UnicastBus() .SendOnly(); } }
public void SetupServiceBus(string[] assemblyPaths, CommandDefinition cmdDef, Dictionary <string, object> connectionSettings) { _commandDef = cmdDef; List <Assembly> asms = new List <Assembly>(); foreach (string path in assemblyPaths) { foreach (string file in Directory.GetFiles(path, "*.dll")) { try { asms.Add(Assembly.LoadFrom(file)); } catch { } } } if (CommandContentFormat == "XML") { _bus = Configure.With(asms) .DefineEndpointName("SBMQM_NSB") .DefaultBuilder() //.MsmqSubscriptionStorage() .DefiningCommandsAs(t => _commandDef.IsCommand(t)) .XmlSerializer() .MsmqTransport() .UnicastBus() .SendOnly(); } else if (CommandContentFormat == "JSON") { _bus = Configure.With(asms) .DefineEndpointName("SBMQM_NSB") .DefaultBuilder() //.MsmqSubscriptionStorage() .DefiningCommandsAs(t => _commandDef.IsCommand(t)) .JsonSerializer() .MsmqTransport() .UnicastBus() .SendOnly(); } }
public Type[] GetAvailableCommands(string[] asmPaths, CommandDefinition commandDef) { List <Type> arr = new List <Type>(); List <string> nonExistingPaths = new List <string>(); foreach (var path in asmPaths) { if (Directory.Exists(path)) { foreach (var dll in Directory.GetFiles(path, "*.dll")) { if (IGNORE_DLL.Any(a => dll.EndsWith(a))) { continue; } try { var asm = Assembly.LoadFrom(dll); foreach (Type t in asm.GetTypes()) { if (commandDef.IsCommand(t)) { arr.Add(t); } } } catch { } } } else { nonExistingPaths.Add(path); } } if (nonExistingPaths.Count > 0) { OnError("The paths '{0}' doesn't exist, could not search for commands.".With(nonExistingPaths.Concat())); } return(arr.ToArray()); }
public Type[] GetAvailableCommands(string[] asmPaths, CommandDefinition cmdDef, bool suppressErrors) { List<Type> arr = new List<Type>(); List<string> nonExistingPaths = new List<string>(); foreach (var path in asmPaths) { if (Directory.Exists(path)) { foreach (var dll in Directory.GetFiles(path, "*.dll")) { if (IGNORE_DLL.Any(a => dll.EndsWith(a))) continue; try { var asm = Assembly.LoadFrom(dll); foreach (Type t in asm.GetTypes()) { if (cmdDef.IsCommand(t)) arr.Add(t); } } catch (ReflectionTypeLoadException fte) { if (suppressErrors) continue; StringBuilder sb = new StringBuilder(); if (fte.LoaderExceptions != null) { if (fte.LoaderExceptions.All(a => a.Message.EndsWith("does not have an implementation."))) continue; string lastMsg = null; foreach (var ex in fte.LoaderExceptions) { if (ex.Message != lastMsg) sb.AppendFormat(" - {0}\n\n", lastMsg = ex.Message); } } OnWarning("Could not search for Commands in Assembly '{0}'".With(Path.GetFileName(dll)), sb.ToString()); } catch { } } } else nonExistingPaths.Add(path); } if (nonExistingPaths.Count > 0) OnError("The paths '{0}' doesn't exist, could not search for commands.".With(nonExistingPaths.Concat())); return arr.ToArray(); }
public override void SetupServiceBus(string[] assemblyPaths, CommandDefinition cmdDef) { _commandDef = cmdDef; List<Assembly> asms = new List<Assembly>(); foreach( string path in assemblyPaths ) { foreach( string file in Directory.GetFiles(path, "*.dll") ) { try { asms.Add(Assembly.LoadFrom(file)); } catch { } } } _bus = Configure.With(asms) .DefineEndpointName("SBMQM_NSB_JSON") .DefaultBuilder() //.MsmqSubscriptionStorage() .DefiningCommandsAs(t => _commandDef.IsCommand(t)) .JsonSerializer() .MsmqTransport() .UnicastBus() .SendOnly(); }
public Type[] GetAvailableCommands(string[] asmPaths, CommandDefinition commandDef, bool suppressErrors) { List <Type> arr = new List <Type>(); List <string> nonExistingPaths = new List <string>(); foreach (var path in asmPaths) { if (Directory.Exists(path)) { foreach (var dll in Directory.GetFiles(path, "*.dll")) { if (IGNORE_DLL.Any(a => dll.EndsWith(a))) { continue; } try { var asm = Assembly.LoadFrom(dll); //var asm = Assembly.ReflectionOnlyLoadFrom(dll); foreach (Type t in asm.GetTypes()) { if (commandDef.IsCommand(t)) { arr.Add(t); } } } catch (ReflectionTypeLoadException fte) { if (suppressErrors) { continue; } StringBuilder sb = new StringBuilder(); if (fte.LoaderExceptions != null) { if (fte.LoaderExceptions.All(a => a.Message.EndsWith("does not have an implementation."))) { continue; } string lastMsg = null; foreach (var ex in fte.LoaderExceptions) { if (ex.Message != lastMsg) { sb.AppendFormat(" - {0}\n\n", lastMsg = ex.Message); } } } OnWarning("Could not search for Commands in Assembly '{0}'".With(Path.GetFileName(dll)), sb.ToString()); } catch { } } } else { nonExistingPaths.Add(path); } } if (nonExistingPaths.Count > 0) { OnError("The paths '{0}' doesn't exist, could not search for commands.".With(nonExistingPaths.Concat())); } return(arr.ToArray()); }
public Type[] GetAvailableCommands(string[] asmPaths, CommandDefinition commandDef) { List<Type> arr = new List<Type>(); List<string> nonExistingPaths = new List<string>(); foreach( var path in asmPaths ) { if( Directory.Exists(path) ) { foreach( var dll in Directory.GetFiles(path, "*.dll") ) { if( IGNORE_DLL.Any(a => dll.EndsWith(a)) ) continue; try { var asm = Assembly.LoadFrom(dll); foreach( Type t in asm.GetTypes() ) { if( commandDef.IsCommand(t) ) arr.Add(t); } } catch { } } } else nonExistingPaths.Add(path); } if( nonExistingPaths.Count > 0 ) OnError("The paths '{0}' doesn't exist, could not search for commands.".With(nonExistingPaths.Concat())); return arr.ToArray(); }