public override void Init(string serverName, string[] commandQueues, string[] eventQueues,
                      string[] messageQueues, string[] errorQueues, CommandDefinition commandDef)
        {
            base.Init(serverName, commandQueues, eventQueues, messageQueues, errorQueues, commandDef);

              _ignoreMessageBody = new StreamReader(this.GetType().Assembly.GetManifestResourceStream("ServiceBusMQ.NServiceBus.CheckMessage.xml")).ReadToEnd();
        }
 public Type[] GetAvailableCommands(string[] _asmPath, CommandDefinition cmdDef, bool suppressErrors = false)
 {
     var sc = _mgr as ISendCommand;
       if( sc != null )
     return sc.GetAvailableCommands(_asmPath, cmdDef, suppressErrors);
       else return new Type[0];
 }
        public Type[] GetAvailableCommands(string messageBus, string version, string queueType, string[] asmPaths, CommandDefinition cmdDef, bool suppressErrors)
        {
            var mgr = ServiceBusFactory.CreateManager(messageBus, version, queueType) as ISendCommand;

              if( mgr != null ) {
            return mgr.GetAvailableCommands(asmPaths, cmdDef, suppressErrors);

              } else return new Type[0];
        }
 public Type[] GetAvailableCommands(string[] _asmPath, CommandDefinition cmdDef)
 {
     var sc = _mgr as ISendCommand;
       if( sc != null )
     return sc.GetAvailableCommands(_asmPath, cmdDef);
       else return new Type[0];
 }
    protected override void FillDefaulValues() {

      if( VersionCheck == null ) 
        VersionCheck = new VersionCheck();

      // Convert MSMQ plain to XML, as we now support more then one content serializer
      foreach( var srv in this.Servers ) {
        if( srv.MessageBus == "NServiceBus" ) {

          if( srv.MessageBusQueueType == "MSMQ (XML)" )
            srv.MessageBusQueueType = "MSMQ";

          else if( srv.MessageBusQueueType == "MSMQ (JSON)" )
            srv.MessageBusQueueType = "MSMQ";

        }
      }

      if( CommandDefinition == null ) {
      
        CommandDefinition = new CommandDefinition(); 
        
        // Temp until support for more then NServiceBus is implemented
        CommandDefinition.InheritsType = "NServiceBus.ICommand, NServiceBus";

      }

    }
        private void UpdateSendCommandInfo(bool animate = true)
        {
            StringBuilder sb = new StringBuilder();

              if( asmPaths.ItemsCount > 0 ) {

            CommandDefinition cmdDef = new CommandDefinition();

            if( tbCmdInherits.Text.IsValid() )
              cmdDef.InheritsType = tbCmdInherits.Text;

            var cmdNamespace = tbNamespace.RetrieveValue<string>();
            if( cmdNamespace.IsValid() )
              cmdDef.NamespaceContains = cmdNamespace;

            if( _sys.GetAvailableCommands(asmPaths.GetItems(), cmdDef).Length == 0 ) {

              sb.Append("No commands found ");

              if( cmdDef.InheritsType.IsValid() )
            sb.Append("that inherits " + cmdDef.InheritsType.Substring(0, cmdDef.InheritsType.IndexOf(',')).CutBeginning(40));

              if( cmdDef.NamespaceContains.IsValid() ) {

            if( cmdDef.InheritsType.IsValid() )
              sb.Append(" or ");
            else sb.Append("that ");

            sb.AppendFormat("contains '{0}' in Namespace", cmdDef.NamespaceContains);

              }

              sb.Append(", make sure your Command Definition is correct");
            }

              } else {
            sb.Append("You need to add atleast one assembly path to be able to send commands");

              }

              if( sb.Length > 0 ) {
            lbSendCommandInfo.Text = sb.ToString();
              }

              UpdateInfoBox(sb.Length > 0, animate, ROW_SENDCMD_INFO, ConfigWindow.SendCommandInfoHeightProperty);
        }
    private void UpdateSendCommandInfo(bool animate = true) {
      StringBuilder sb = new StringBuilder();

      try {

        if( asmPaths.ItemsCount > 0 ) {

          CommandDefinition cmdDef = new CommandDefinition();

          if( tbCmdInherits.Text.IsValid() )
            cmdDef.InheritsType = tbCmdInherits.Text;

          var cmdNamespace = tbNamespace.RetrieveValue<string>();
          if( cmdNamespace.IsValid() )
            cmdDef.NamespaceContains = cmdNamespace;

          var mw = App.Current.MainWindow as MainWindow;


          if( !ServiceBusFactory.CanSendCommand(CurrentServer.ServiceBus, CurrentServer.ServiceBusVersion, CurrentServer.ServiceBusQueueType) ) {
            sb.Append("Service Bus Adapter doesn't support Sending Commands");
            lbCmdsFound.Content = string.Empty;
            return;
          }

          var cmds = GetAvailableCommands(asmPaths.GetItems(), cmdDef, !animate); // !animate = on dialog startup

          lbCmdsFound.Content = "{0} Commands Found".With(cmds.Length);

          if( cmds.Length == 0 ) {

            sb.Append("No commands found");

            if( cmdDef.InheritsType.IsValid() )
              sb.Append(" that inherits " + cmdDef.InheritsType.Substring(0, cmdDef.InheritsType.IndexOf(',')).CutBeginning(40));

            if( cmdDef.NamespaceContains.IsValid() ) {

              if( cmdDef.InheritsType.IsValid() )
                sb.Append(" or");
              else sb.Append(" that");

              sb.AppendFormat(" contains '{0}' in Namespace", cmdDef.NamespaceContains);

            }

            sb.Append(", make sure your Command Definition is correct");
          }

        } else {
          sb.Append("You need to add at least one assembly path containing commands libraries to be able to Send Commands");
          lbCmdsFound.Content = string.Empty;
        }

      } finally {

        if( sb.Length > 0 ) {
          lbSendCommandInfo.Text = sb.ToString();
        }

        UpdateInfoBox(sb.Length > 0, animate, ROW_SENDCMD_INFO, ConfigWindow.SendCommandInfoHeightProperty);
      }
    }
    private Type[] GetAvailableCommands(string[] asmPaths, CommandDefinition cmdDef, bool suppressErrors) {
      var srv = CurrentServer;

      return _sys.GetAvailableCommands(srv.ServiceBus, srv.ServiceBusVersion, srv.ServiceBusQueueType, asmPaths, cmdDef, suppressErrors);
    }
        public Type[] GetAvailableCommands(string messageBus, string version, string queueType, string[] asmPaths, CommandDefinition cmdDef, bool suppressErrors)
        {
            var mgr = ServiceBusFactory.CreateManager(messageBus, version, queueType) as ISendCommand;

            if (mgr != null)
            {
                return(mgr.GetAvailableCommands(asmPaths, cmdDef, suppressErrors));
            }
            else
            {
                return(new Type[0]);
            }
        }
        public override void Init(string serverName, string[] commandQueues, string[] eventQueues, string[] messageQueues, string[] errorQueues, CommandDefinition commandDef)
        {
            base.Init(serverName, commandQueues, eventQueues, messageQueues, errorQueues, commandDef);

              StartPeekThreads();
        }
        public override Type[] GetAvailableCommands(string[] asmPaths, CommandDefinition commandDef)
        {
            List<Type> arr = new List<Type>();

              foreach( var path in asmPaths )
            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 { }

            }

              return arr.ToArray();
        }