public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
            {
                bool handled = false;
                int  hresult = VSConstants.S_OK;

                var commandKey = new DeveroomEditorCommandTargetKey(pguidCmdGroup, nCmdID);

                if (!CommandRegistry.TryGetValue(commandKey, out var commands))
                {
                    return(Next.Exec(commandKey.CommandGroup, commandKey.CommandId, nCmdexecopt, pvaIn, pvaOut));
                }

                // Pre-process
                foreach (var editorCommand in commands)
                {
                    handled = editorCommand.PreExec(TextView, commandKey, pvaIn);
                    if (handled)
                    {
                        break;
                    }
                }

                if (!handled)
                {
                    hresult = Next.Exec(commandKey.CommandGroup, commandKey.CommandId, nCmdexecopt, pvaIn, pvaOut);
                }

                // Post-process
                foreach (var editorCommand in commands)
                {
                    editorCommand.PostExec(TextView, commandKey, pvaIn);
                }

                return(hresult);
            }
Ejemplo n.º 2
0
        public void WhenNoAsyncHandlerRegistereded_ThenInvokesOnThreadPoolAndPersistsToStore()
        {
            var command = new FooCommand {
                Id = 5
            };
            var handler = new Mock <ICommandHandler <FooCommand> >();

            handler.Setup(x => x.IsAsync).Returns(true);
            var handlerCalled = false;

            handler.Setup(x => x.Handle(It.IsAny <FooCommand>(), It.IsAny <IDictionary <string, object> >()))
            .Callback <FooCommand, IDictionary <string, object> >((c, h) => handlerCalled = true);

            var store = new Mock <IMessageStore <IDomainCommand> >();

            var bus = new CommandRegistry <IDomainCommand>(store.Object, new[] { handler.Object });

            bus.Execute(command);

            while (!handlerCalled)
            {
                System.Threading.Thread.Sleep(10);
            }

            handler.Verify(x => x.Handle(command, It.IsAny <IDictionary <string, object> >()));
            store.Verify(x => x.Save(command, It.IsAny <IDictionary <string, object> >()));
        }
Ejemplo n.º 3
0
 public void Startup(ConfigurationLoader loader)
 {
     m_Commands = loader.CommandRegistry;
     m_WebIF    = loader.GetAdminWebIF();
     m_WebIF.ModuleNames.Add("console");
     m_WebIF.JsonMethods.Add("console.command", ConsoleCommand);
 }
Ejemplo n.º 4
0
        public UserUseCases()
        {
            _token          = Guid.NewGuid().ToString("N");
            _passwordHasher = s => Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(s)));
            _keyStore       = new ReallyInsecureAndVeryTemporaryKeyStore();
            _keyStore.CreateKeyIfNotExists("test");
            SerializationRegistry serializationRegistry = new SerializationRegistry();

            UserBoundedContext.RegisterSerializers(serializationRegistry, _keyStore);
            IKnownSerializers serialization = serializationRegistry.Build();

            _eventStore = new TestEventStore(serialization);
            CommandRegistry commandRegistry = new CommandRegistry();

            _lockoutPolicy = () => Clock.Now + TimeSpan.FromMinutes(5);
            UserBoundedContext.RegisterCommands(
                commandRegistry,
                new UserRepository(_eventStore, serialization),
                tokenSource: () => _token,
                passwordHasher: _passwordHasher,
                maxLoginAttempts: 3,
                lockoutPolicy: _lockoutPolicy);
            _handler         = commandRegistry.Build();
            _now             = DateTimeOffset.UtcNow;
            Clock.UtcNowFunc = () => _now;
        }
Ejemplo n.º 5
0
        public TestService(ISomneoApiClient somneoApiClient)
        {
            _commandRegistry = new CommandRegistry();

            var commandHandlers = new CommandHandlerBase[]
            {
                new DeviceCommandHandler(somneoApiClient),
                new SensorCommandHandler(somneoApiClient),
                new LightCommandHandler(somneoApiClient),
                new DisplayCommandHandler(somneoApiClient),
                new PlayerCommandHandler(somneoApiClient),
                new FMRadioCommandHandler(somneoApiClient),
                new WakeUpSoundCommandHandler(somneoApiClient),
                new AUXCommandHandler(somneoApiClient),
                new AlarmCommandHandler(somneoApiClient)
            };

            _commandRegistry.RegisterCommand("help", "Show available commands.", ShowHelp);

            foreach (var commandHandler in commandHandlers)
            {
                commandHandler.RegisterCommands(_commandRegistry);
            }

            _commandRegistry.RegisterCommand("exit", "Exit the application.", args => _canRun = false);
        }
Ejemplo n.º 6
0
        /// <summary> Show main menu. </summary>
        private static void ShowMainMenu()
        {
            while (true)
            {
                if (VersionHandler.TryGetCurrentDatabaseVersion(out double version))
                {
                    ConsoleUtility.Write(Environment.UserName, ConsoleColor.Yellow);
                    ConsoleUtility.WriteLine("->v" + version, ConsoleColor.Blue);
                    ConsoleUtility.Write("-> ", TextColor);
                    string command = ConsoleUtility.ReadLine(TextColor);

                    string[] args = command.Split(' ');
                    if (CommandRegistry.ContainCommand(args[0]))
                    {
                        CommandRegistry.ExecuteCommand(args[0], args);
                    }
                    else
                    {
                        ConsoleUtility.WriteLine("Unknown command.", ErrorColor);
                    }

                    Console.WriteLine();
                }
                else
                {
                    ConsoleUtility.WriteLine("Failed to get current database version.", ErrorColor);
                    Console.ReadKey();
                    return;
                }
            }
        }
Ejemplo n.º 7
0
        public void Startup(ConfigurationLoader loader)
        {
            HomeURI = loader.HomeURI;

            m_AgentInventoryService = loader.GetService <InventoryServiceInterface>(m_AgentInventoryServiceName);
            m_AgentAssetService     = loader.GetService <AssetServiceInterface>(m_AgentAssetServiceName);
            if (m_AgentProfileServiceName?.Length != 0)
            {
                m_AgentProfileService = loader.GetService <ProfileServiceInterface>(m_AgentProfileServiceName);
            }
            m_AgentFriendsService = loader.GetService <FriendsServiceInterface>(m_AgentFriendsServiceName);
            m_UserSessionService  = loader.GetService <UserSessionServiceInterface>(m_UserSessionServiceName);
            m_GridService         = loader.GetService <GridServiceInterface>(m_GridServiceName);
            if (m_OfflineIMServiceName?.Length != 0)
            {
                m_OfflineIMService = loader.GetService <OfflineIMServiceInterface>(m_OfflineIMServiceName);
            }
            if (m_AgentExperienceServiceName?.Length != 0)
            {
                loader.GetService(m_AgentExperienceServiceName, out m_AgentExperienceService);
            }
            if (m_AgentGroupsServiceName?.Length != 0)
            {
                loader.GetService(m_AgentGroupsServiceName, out m_AgentGroupsService);
            }
            m_UserAccountService    = loader.GetService <UserAccountServiceInterface>(m_UserAccountServiceName);
            m_AgentUserAgentService = new LocalUserAgentService(m_UserSessionService, m_UserAccountService, m_RequiresInventoryIDAsIMSessionID, HomeURI);

            m_Scenes               = loader.Scenes;
            m_Commands             = loader.CommandRegistry;
            m_CapsRedirector       = loader.CapsRedirector;
            m_PacketHandlerPlugins = loader.GetServicesByValue <IProtocolExtender>();
        }
Ejemplo n.º 8
0
        public void RegisterTheSameCommandTwice()
        {
            var registry = new CommandRegistry();
            registry.Register(new HelpCommand());

            Assert.Throws<ArgumentException>(() => registry.Register(new HelpCommand()));
        }
Ejemplo n.º 9
0
 public void FindShouldReturnTheSameCommandJustOnce()
 {
     var registry = new CommandRegistry();
     registry.Register(new HelpCommand());
     registry.Register(new HelpCommand(), "hlp");
     Assert.AreEqual(1, registry.Find("h").Count);
 }
Ejemplo n.º 10
0
 public void RegisterOne()
 {
     var registry = new CommandRegistry();
     registry.Register(new HelpCommand());
     Assert.AreEqual(1, registry.Commands.Count);
     Assert.IsTrue(registry.Contains("help"));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initialize the core game systems.
 /// </summary>
 public static void Initialize()
 {
     Routines = RoutineRunner.GetInstance();
     Assets   = AssetLoader.GetInstance();
     Scenes   = SceneLoader.GetInstance();
     Commands = CommandRegistry.GetInstance();
 }
        public void PriorityIsIndependentOfRegistryOrder(bool reverseRegistration)
        {
            // Arrange
            var registry = new CommandRegistry(new Mock <ICommandHandlerExecuter>().Object);

            // Act
            if (reverseRegistration)
            {
                registry.Register <SimpleCommandHandlerTwo>(order: 1500);
                registry.Register <SimpleCommandHandler>(order: 1000);
            }
            else
            {
                registry.Register <SimpleCommandHandler>(order: 1000);
                registry.Register <SimpleCommandHandlerTwo>(order: 1500);
            }


            // Assert
            var result = registry.GetPrioritisedCommandHandlers(new SimpleCommand());

            Assert.Collection(result, pca =>
            {
                if (pca.Priority != 1000)
                {
                    throw new Exception("Wrong order");
                }
            }, pca =>
            {
                if (pca.Priority != 1500)
                {
                    throw new Exception("Wrong order");
                }
            });
        }
Ejemplo n.º 13
0
        private Session CreateSession(
            Action <ScopedObjectRegistry> sessionObjectsConfigurator = null,
            params Type[] commandTypes)
        {
            var parser              = new Parser();
            var nameValidator       = new NameValidator();
            var descriptorGenerator = new CommandAttributeInspector();
            var registry            = new CommandRegistry(nameValidator, descriptorGenerator);

            foreach (var commandType in commandTypes)
            {
                registry.Register(commandType);
            }

            var services      = new CommandServices();
            var scopedObjects = new ScopedObjectRegistry();

            scopedObjects.Register <VariableCollection>();
            sessionObjectsConfigurator?.Invoke(scopedObjects);

            var factory = new CommandFactory(registry, services, scopedObjects);

            var variables = scopedObjects.Resolve(typeof(VariableCollection)) as VariableCollection;
            var replacer  = new VariableReplacer();
            var binder    = new CommandParameterBinder(registry, replacer, variables);

            return(new Session(parser, factory, binder));
        }
Ejemplo n.º 14
0
        public CommandHandler(IMessageBus messageBus, CommandRegistry commandRegistry)
        {
            _messageBus      = messageBus;
            _commandRegistry = commandRegistry;

            messageBus.Received += (sender, args) =>
            {
                try
                {
                    MessageBusOnReceived(sender, args);
                }
                catch
                {
                    // ignore
                }
            };
            messageBus.Sent += (sender, args) =>
            {
                try
                {
                    MessageBusOnSent(sender, args);
                }
                catch
                {
                    // ignore
                }
            };
        }
Ejemplo n.º 15
0
        public void CommandRegistry_WithCommands_SupportsThoseCommands()
        {
            List <TestCommand> commands = Build.Many.Commands(Build.A.Command, Build.A.Command, Build.A.Command);
            CommandRegistry    sut      = new CommandRegistry(commands);

            commands.All(c => sut.Supports(c.SupportedCommand)).Should().BeTrue();
        }
Ejemplo n.º 16
0
        private CommandFactory CreateCommandFactory(
            Action <CommandRegistry> commandRegistryConfigurator           = null,
            Action <CommandServices> commandServicesConfigurator           = null,
            Action <ScopedObjectRegistry> scopedObjectRegistryConfigurator = null)
        {
            var nameValidator       = new NameValidator();
            var descriptorGenerator = new CommandAttributeInspector();
            var registry            = new CommandRegistry(nameValidator, descriptorGenerator);

            if (commandRegistryConfigurator != null)
            {
                commandRegistryConfigurator.Invoke(registry);
            }

            var services = new CommandServices();

            if (commandServicesConfigurator != null)
            {
                commandServicesConfigurator.Invoke(services);
            }

            var sessionObjects = new ScopedObjectRegistry();

            sessionObjects.Register <VariableCollection>();

            if (scopedObjectRegistryConfigurator != null)
            {
                scopedObjectRegistryConfigurator.Invoke(sessionObjects);
            }

            return(new CommandFactory(registry, services, sessionObjects));
        }
Ejemplo n.º 17
0
        private void OnKick(string txt)
        {
            if (string.IsNullOrEmpty(txt))
            {
                CommandRegistry.ShowCurrentHelp();
                return;
            }
            if (!NetGame.isServer)
            {
                string str = ScriptLocalization.Get("XTRA/NetChat_OnlyHost");
                Print(str);
                return;
            }
            NetHost client = GetClient(txt);

            if (client != null)
            {
                if (client == NetGame.instance.local)
                {
                    string str2 = ScriptLocalization.Get("XTRA/NetChat_NoKickMe");
                    Print(str2);
                }
                else
                {
                    NetGame.instance.Kick(client);
                }
            }
        }
Ejemplo n.º 18
0
 public override void RegisterCommands(CommandRegistry commandRegistry)
 {
     commandRegistry.RegisterCommand("alarms", "Show the alarms.", ShowAlarms);
     commandRegistry.RegisterCommand("alarm-settings", "[1-16]", "Show the settings of an alarm.", ShowAlarmSettings);
     commandRegistry.RegisterCommand("toggle-alarm", "[1-16] [on/off]", "Toggle an alarm.", ToggleAlarm);
     commandRegistry.RegisterCommand("remove-alarm", "[1-16]", "Remove an alarm.", RemoveAlarm);
     commandRegistry.RegisterCommand("set-snooze-time", "[1-20]", "Sets the snooze time in minutes.", SetSnoozeTime);
 }
Ejemplo n.º 19
0
        public CommandHandler(IMessageBus messageBus, CommandRegistry commandRegistry)
        {
            _messageBus      = messageBus;
            _commandRegistry = commandRegistry;

            messageBus.Received += MessageBusOnReceived;
            messageBus.Sent     += MessageBusOnSent;
        }
Ejemplo n.º 20
0
        private static void InitiateCommands()
        {
            cmdController = new CommandRegistry();

            cmdController.Commands.Add(new Multiply());

            cmdController.Commands.Add(new Help(cmdController.Commands));
        }
Ejemplo n.º 21
0
        public void CommandRegistry_WithACommand_DoesNotSupportUnknownCommand()
        {
            List <TestCommand> commands       = Build.A.Command.InAList();
            CommandRegistry    sut            = new CommandRegistry(commands);
            TestCommand        unknownCommand = Build.A.Command;

            sut.Supports(unknownCommand.SupportedCommand).Should().BeFalse();
        }
Ejemplo n.º 22
0
 public override void RegisterCommands(CommandRegistry commandRegistry)
 {
     commandRegistry.RegisterCommand("device", "Show the device information.", ShowDeviceDetails);
     commandRegistry.RegisterCommand("firmware", "Show the firmware information.", ShowFirmwareDetails);
     commandRegistry.RegisterCommand("wifi", "Show the wifi connection details.", ShowWifiDetails);
     commandRegistry.RegisterCommand("locale", "Show the locale set for the device.", ShowLocale);
     commandRegistry.RegisterCommand("time", "Show the time of the device.", ShowTime);
 }
Ejemplo n.º 23
0
        public void SetDefaultCommand_ThrowsIfCommandNotRegistered()
        {
            CommandRegistry commandRegistry = new CommandRegistry();

            var ex = Assert.Throws <Exception>(() => commandRegistry.SetDefaultCommand(typeof(TestCommand)));

            Assert.That(ex.Message, Is.EqualTo("Command NConsole.Tests.Internal.CommandRegistryTests+TestCommand is not registered."));
        }
Ejemplo n.º 24
0
 public override void RegisterCommands(CommandRegistry commandRegistry)
 {
     commandRegistry.RegisterCommand("light", "Show the light state.", ShowLightState);
     commandRegistry.RegisterCommand("toggle-light", "[on/off]", "Toggle the light.", ToggleLight);
     commandRegistry.RegisterCommand("set-light-level", "[1-25]", "Set the light level.", SetLightLevel);
     commandRegistry.RegisterCommand("toggle-night-light", "[on/off]", "Toggle the night light.", ToggleNightLight);
     commandRegistry.RegisterCommand("toggle-sunrise-preview", "[on/off]", "Toggle the Sunrise Preview mode.", ToggleSunrisePreview);
 }
Ejemplo n.º 25
0
 public void TestAddition()
 {
     //Asserts that a command registry can register the command without throwing an exception
     using (CommandRegistry registry = new CommandRegistry(new RegistrySettings()))
     {
         registry.AddCommand(typeof(TestCommand));
     }
 }
Ejemplo n.º 26
0
 public void RegisterBothCommandAndAliasAndFindWithPrefix()
 {
     var registry = new CommandRegistry();
     registry.Register(new HelpCommand());
     registry.Register(new HelpCommand(), "h");
     // Only finds the alias, because the prefix and the name of the
     // command are the same in this case.
     Assert.AreEqual(1, registry.Find("h").Count);
 }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Load up the options from file.
            string  optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftySolution.xml");
            Options options         = Options.Load(optionsFileName);

            // Create our main plugin facade.
            DTE2 application = GetGlobalService(typeof(DTE)) as DTE2;
            IVsProfferCommands3   profferCommands3      = base.GetService(typeof(SVsProfferCommands)) as IVsProfferCommands3;
            OleMenuCommandService oleMenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            ImageList icons = new ImageList();

            icons.Images.AddStrip(Properties.Resources.Icons);
            m_plugin = new Plugin(application, profferCommands3, icons, oleMenuCommandService, "NiftySolution", "Aurora.NiftySolution.Connect", options);

            // Every plugin needs a command bar.
            CommandBar commandBar = m_plugin.AddCommandBar("NiftySolution", MsoBarPosition.msoBarTop);

            m_commandRegistry = new CommandRegistry(m_plugin, commandBar, new Guid(PackageGuidString), new Guid(PackageGuidGroup));

            // Initialize the logging system.
            if (Log.HandlerCount == 0)
            {
                                #if DEBUG
                Log.AddHandler(new DebugLogHandler());
                                #endif

                Log.AddHandler(new VisualStudioLogHandler(m_plugin));
                Log.Prefix = "NiftySolution";
            }

            // Now we can take care of registering ourselves and all our commands and hooks.
            Log.Debug("Booting up...");
            Log.IncIndent();


            bool doBindings = options.EnableBindings;

            m_commandRegistry.RegisterCommand(doBindings, new QuickOpen(m_plugin, "NiftyOpen"));
            m_commandRegistry.RegisterCommand(doBindings, new ToggleFile(m_plugin, "NiftyToggle"));
            m_commandRegistry.RegisterCommand(doBindings, new CloseToolWindow(m_plugin, "NiftyClose"));
            m_commandRegistry.RegisterCommand(doBindings, new Configure(m_plugin, "NiftyConfigure"));

            if (options.SilentDebuggerExceptions || options.IgnoreDebuggerExceptions)
            {
                m_debuggerEvents = application.Events.DebuggerEvents;
                m_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled);
            }

            m_timings = new SolutionBuildTimings(m_plugin);

            Log.DecIndent();
            Log.Debug("Initialized...");
        }
 public override void RegisterCommands(CommandRegistry commandRegistry)
 {
     commandRegistry.RegisterCommand("fm-radio-presets", "Show the FM-radio presets.", ShowFMRadioPresets);
     commandRegistry.RegisterCommand("set-fm-radio-preset", $"[1-5] [{87.50F:0.00}-{107.99F:0.00}]", "Set an FM-radio preset to a frequency.", SetFMRadioPreset);
     commandRegistry.RegisterCommand("fm-radio", "Show the FM-radio state.", ShowFMRadioState);
     commandRegistry.RegisterCommand("enable-fm-radio", "Enable the FM-radion.", EnableFMRadio);
     commandRegistry.RegisterCommand("enable-fm-radio-preset", "[1-5]", "Enable an FM-radio preset.", EnableFMRadioPreset);
     commandRegistry.RegisterCommand("seek-fm-radio-station", "[up/down]", "Seek a next FM-radio station.", SeekFMRadioStation);
 }
Ejemplo n.º 29
0
 public void RegisterBothCommandAndAlias()
 {
     var registry = new CommandRegistry();
     registry.Register(new HelpCommand());
     registry.Register(new HelpCommand(), "h");
     Assert.AreEqual(2, registry.Commands.Count);
     Assert.IsTrue(registry.Contains("help"));
     Assert.IsTrue(registry.Contains("h"));
 }
Ejemplo n.º 30
0
 public void AmbiguousMatchCommand()
 {
     var registry = new CommandRegistry();
     registry.Register(new BarCommand());
     registry.Register(new BazCommand());
     var factory = new CommandFactory(registry);
     var command = factory.Create(new[] {"ba"});
     Assert.That(command, Is.InstanceOf(typeof(AmbiguousMatchCommand)));
 }
Ejemplo n.º 31
0
        /// <summary>
        ///     Main entry-point.
        /// </summary>
        public static void Main()
        {
            // Register command information
            CommandRegistry.LoadCommandEntries();

            // Start up the bot
            BotStartup.StartBotAsync()
            .GetAwaiter()
            .GetResult();
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Generates a new parser that uses the given registry, args, metadata, context, and ID to run
 /// </summary>
 /// <param name="registry">Registry from which the parser will obtain <see cref="IObjectConverter"/>s</param>
 /// <param name="input">The original input string</param>
 /// <param name="additionalArgs">Any additional arguments to be added to the end of the argument list</param>
 /// <param name="metadata">CommandMetadata containing information used to parse and execute</param>
 /// <param name="exeData"><see cref="CommandExecutorData"/> containing the data required for execution</param>
 /// <param name="ctx">Context object passed to the executed command, and an <see cref="IObjectConverter"/>s that are used</param>
 /// <param name="callback">Reference to a method used as a callback when processing completes</param>
 public Parser(CommandRegistry registry,
               string input,
               IEnumerable <object> additionalArgs,
               CommandMetadata metadata,
               CommandExecutorData exeData,
               IContextObject ctx,
               InputResultDelegate callback)
     : base(registry, input, additionalArgs, metadata, exeData, ctx, callback)
 {
 }
Ejemplo n.º 33
0
        public void GetDescriptor_ReturnsRegisteredCommand()
        {
            CommandRegistry commandRegistry = new CommandRegistry();

            commandRegistry.Register(typeof(TestCommand));

            CommandDescriptor descriptor = commandRegistry.GetDescriptor("test", null);

            Assert.That(descriptor.Name, Is.EqualTo("test"));
        }
Ejemplo n.º 34
0
        public void GetDescriptor_ReturnsRegisteredCommandUsingCommandAttribute()
        {
            CommandRegistry commandRegistry = new CommandRegistry();

            commandRegistry.Register(typeof(TestAttributedCommand));

            CommandDescriptor descriptor = commandRegistry.GetDescriptor("overridden", null);

            Assert.That(descriptor.Name, Is.EqualTo("overridden"));
        }
Ejemplo n.º 35
0
        public static void RegisterAllCommands()
        {
            //CommandRegistry.RegisterCommand(new Command("Console.WriteLine({contents});", "Output:WriteLn[{contents}]", new string[] { "contents" }));
            //CommandRegistry.RegisterCommand(new Command("using {namespace};", "Use {namespace}", new string[] { "namespace" }));
            //CommandRegistry.RegisterCommand(new Command("{type} {name};", "InitializeVar {type} {name}", new string[] { "type", "name" }));
            //CommandRegistry.RegisterCommand(new Command("{name} = Console.ReadLine();", "{name}=Input:ReadLn[]", new string[] { "name" }));

            CommandRegistry.RegisterKeyword(new Keyword("class", "DefClass"));
            CommandRegistry.RegisterKeyword(new Keyword("public", "Visibility:Public"));
            CommandRegistry.RegisterKeyword(new Keyword("private", "Visibility:Private"));
            CommandRegistry.RegisterKeyword(new Keyword("protected", "Visibility:Protected"));
            CommandRegistry.RegisterKeyword(new Keyword("static", "StaticObj"));

            CommandRegistry.RegisterKeyword(new Keyword("void", "Void"));
            CommandRegistry.RegisterKeyword(new Keyword("string", "String"));
            CommandRegistry.RegisterKeyword(new Keyword("int", "Int32"));
            CommandRegistry.RegisterKeyword(new Keyword("short", "Int16"));
            CommandRegistry.RegisterKeyword(new Keyword("long", "Long"));
            CommandRegistry.RegisterKeyword(new Keyword("char", "Character"));
            CommandRegistry.RegisterKeyword(new Keyword("object", "Object"));
            CommandRegistry.RegisterKeyword(new Keyword("var", "Variable"));

            CommandRegistry.RegisterKeyword(new Keyword("sealed", "NonInheritable"));
            CommandRegistry.RegisterKeyword(new Keyword("abstract", "Abstract"));

            CommandRegistry.RegisterKeyword(new Keyword("using", "Use"));
            CommandRegistry.RegisterKeyword(new Keyword("namespace", "Namespace"));

            CommandRegistry.RegisterKeyword(new Keyword("delegate", "Delegate"));
            CommandRegistry.RegisterKeyword(new Keyword("enum", "Enumeration"));

            CommandRegistry.RegisterKeyword(new Keyword("if", "[IF]"));
            CommandRegistry.RegisterKeyword(new Keyword("else if", "[ELSE_IF]"));
            CommandRegistry.RegisterKeyword(new Keyword("else", "[ELSE]"));

            CommandRegistry.RegisterKeyword(new Keyword("for", "For"));
            CommandRegistry.RegisterKeyword(new Keyword("foreach", "ForEach"));
            CommandRegistry.RegisterKeyword(new Keyword("while", "DoWhile"));

            CommandRegistry.RegisterKeyword(new Keyword("try", "TryDo"));
            CommandRegistry.RegisterKeyword(new Keyword("catch", "CatchException"));
            CommandRegistry.RegisterKeyword(new Keyword("finally", "DoFinally"));

            CommandRegistry.RegisterKeyword(new Keyword("interface", "DefInterface"));

            CommandRegistry.RegisterKeyword(new Keyword("switch", "Switch"));
            CommandRegistry.RegisterKeyword(new Keyword("case", "Case"));
            CommandRegistry.RegisterKeyword(new Keyword("break", "BreakConstruction"));
            CommandRegistry.RegisterKeyword(new Keyword("default", "DefaultCase"));
            CommandRegistry.RegisterKeyword(new Keyword("continue", "Continue"));

            CommandRegistry.RegisterKeyword(new Keyword("return", "Return"));
            CommandRegistry.RegisterKeyword(new Keyword("event", "Event"));
            CommandRegistry.RegisterKeyword(new Keyword("null", "NullValue"));
        }
Ejemplo n.º 36
0
            public void OnConnection(object application_, ext_ConnectMode connectMode, object addInInst, ref Array custom)
            {
                if (null != m_plugin)
                {
                    return;
                }

                // Load up the options from file.
                string  optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftySolution.xml");
                Options options         = Options.Load(optionsFileName);

                // Create our main plugin facade.
                DTE2 application = (DTE2)application_;

                m_plugin = new Plugin(application, (AddIn)addInInst, "NiftySolution", "Aurora.NiftySolution.Connect", options);

                // Every plugin needs a command bar.
                CommandBar commandBar = m_plugin.AddCommandBar("NiftySolution", MsoBarPosition.msoBarTop);

                m_commandRegistry = new CommandRegistry(m_plugin, commandBar);

                // Initialize the logging system.
                if (Log.HandlerCount == 0)
                {
                                        #if DEBUG
                    Log.AddHandler(new DebugLogHandler());
                                        #endif

                    Log.AddHandler(new VisualStudioLogHandler(m_plugin.OutputPane));
                    Log.Prefix = "NiftySolution";
                }

                // Now we can take care of registering ourselves and all our commands and hooks.
                Log.Debug("Booting up...");
                Log.IncIndent();


                bool doBindings = options.EnableBindings;

                m_commandRegistry.RegisterCommand("NiftyOpen", doBindings, new QuickOpen(m_plugin));
                m_commandRegistry.RegisterCommand("NiftyToggle", doBindings, new ToggleFile(m_plugin));
                m_commandRegistry.RegisterCommand("NiftyClose", doBindings, new CloseToolWindow(m_plugin));
                m_commandRegistry.RegisterCommand("NiftyConfigure", doBindings, new Configure(m_plugin));

                if (options.SilentDebuggerExceptions || options.IgnoreDebuggerExceptions)
                {
                    m_debuggerEvents = application.Events.DebuggerEvents;
                    m_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled);
                }

                m_timings = new SolutionBuildTimings(m_plugin);

                Log.DecIndent();
                Log.Debug("Initialized...");
            }
Ejemplo n.º 37
0
 public void OutputForAmbiguousMatchCommand()
 {
     var registry = new CommandRegistry();
     registry.Register(new BarCommand());
     registry.Register(new BazCommand());
     var factory = new CommandFactory(registry);
     var command = factory.Create(new[] {"ba"});
     var output = OutputFor(command);
     Assert.That(output, Is.StringContaining("Multiple commands start with 'ba':"));
     Assert.That(output, Is.StringContaining("  bar"));
     Assert.That(output, Is.StringContaining("  baz"));
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Initialises a new instance of the ServerCommands class.
 /// </summary>
 /// <param name="server">The instance of the Server running.</param>
 /// <param name="registry">A CommandRegistry to register commands to.</param>
 public ServerCommands(Server server, CommandRegistry<ServerCommand> registry)
 {
     _server = server;
     _registry = registry;
     _registry.Register(new ServerCommand("broadcast", false, Broadcast, "Broadcasts a message to every connected client."));
     _registry.Register(new ServerCommand("help", false, Help, "Provides help for the command utility."));
     _registry.Register(new ServerCommand("ban", true, BanUser, "Bans a user from the server, never to return!"));
     _registry.Register(new ServerCommand("kick", true, KickUser, "Kicks a user from their session. They may reconnect, but their sessions will be read-only until the server is restarted."));
     _registry.Register(new ServerCommand("restart", true, Restart, "Restarts the server, notifying clients that it's happening."));
     _registry.Register(new ServerCommand("privileged", false, ListPrivileged, "Gives a list of all the privileged users."));
     _registry.Register(new ServerCommand("banned", false, ListBanned, "Gives a list of all the banned users."));
 }
			public void OnConnection(object application_, ext_ConnectMode connectMode, object addInInst, ref Array custom)
			{
				if(null != m_plugin)
					return;

				// Load up the options from file.
				string optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftySolution.xml");
				Options options = Options.Load(optionsFileName);

				// Create our main plugin facade.
				DTE2 application = (DTE2)application_;
				m_plugin = new Plugin(application, (AddIn)addInInst, "NiftySolution", "Aurora.NiftySolution.Connect", options);
				
				// Every plugin needs a command bar.
				CommandBar commandBar = m_plugin.AddCommandBar("NiftySolution", MsoBarPosition.msoBarTop);
				m_commandRegistry = new CommandRegistry(m_plugin, commandBar);

				// Initialize the logging system.
				if(Log.HandlerCount == 0)
				{
					#if DEBUG
					Log.AddHandler(new DebugLogHandler());
					#endif

					Log.AddHandler(new VisualStudioLogHandler(m_plugin.OutputPane));
					Log.Prefix = "NiftySolution";
				}

				// Now we can take care of registering ourselves and all our commands and hooks.
				Log.Debug("Booting up...");
				Log.IncIndent();


				bool doBindings = options.EnableBindings;

				m_commandRegistry.RegisterCommand("NiftyOpen", doBindings, new QuickOpen(m_plugin));
				m_commandRegistry.RegisterCommand("NiftyToggle", doBindings, new ToggleFile(m_plugin));
				m_commandRegistry.RegisterCommand("NiftyClose", doBindings, new CloseToolWindow(m_plugin));
				m_commandRegistry.RegisterCommand("NiftyConfigure", doBindings, new Configure(m_plugin));

                if (options.SilentDebuggerExceptions || options.IgnoreDebuggerExceptions)
                {
                    m_debuggerEvents = application.Events.DebuggerEvents;
                    m_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled);
                }

				m_timings = new SolutionBuildTimings(m_plugin);

				Log.DecIndent();
				Log.Debug("Initialized...");
			}
Ejemplo n.º 40
0
		public void CommandRegistryTests()
		{
			var command = new FakeCommand { Identifier = Guid.NewGuid() };
			var registry = new CommandRegistry(
				new InMemoryRecordMapper<CommandPublicationRecord>(), new InMemoryBlobStorage(), new JsonMessageSerializer());

			var record = registry.PublishMessage(command);
			Assert.NotNull(record);

			var retrieved = registry.GetMessage(record.MessageLocation, record.MessageType);
			Assert.NotNull(retrieved);
			Assert.AreEqual(command.Identifier, retrieved.Identifier);

			Assert.NotNull(retrieved as FakeCommand);
		}
Ejemplo n.º 41
0
 /// <summary>
 /// Initialises a new instance of the ServerWindow class and sets up the required values and
 /// objects for use.
 /// </summary>
 public ServerWindow(bool crashRecovery)
 {
     InitializeComponent();
     _logger = new Logger();
     _logger.IsEnabled = true;
     Overlay.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#44FFFFFF"));
     this.Log("Loading Messenger::Server modules");
     this.Log("Creating Server instance...");
     RunningServer = new Server(this, this.GetPort());
     this.Log("Server instance {0} on port {1}", RunningServer, RunningServer.Port);
     this.Log("Log location: {0}", _logger.LogDirectory + "\\" + _logger.LogFile);
     new Thread(FinishLoadingThread).Start();
     RunningServer.Start();
     _commands = new CommandRegistry<ServerCommand>();
     new ServerCommands(RunningServer, _commands);
 }
Ejemplo n.º 42
0
        static void Main(string[] args)
        {
            ICommandRegistry commandRegistry = new CommandRegistry();
            commandRegistry.Register<SayHelloQuery, SayHelloQueryHandler>();
            commandRegistry.Register<SayHelloCommand, SayHelloCommandHandler>();

            ContainerBuilder container = new ContainerBuilder();
            RegisterHandlers(container);

            AutofacCommandHandlerFactory autofacCommandHandlerFactory = new AutofacCommandHandlerFactory(container.Build());

            _commandProcessor = new CommandProcessor(commandRegistry, autofacCommandHandlerFactory);

            ExecuteCommand(_commandProcessor);
            ExecuteCommand(_commandProcessor);
            ExecuteQuery(_commandProcessor);

            Console.ReadLine();
        }
Ejemplo n.º 43
0
 public HelpCommand(CommandRegistry registry, string name)
 {
     this.registry = registry;
     this.name = name;
 }
Ejemplo n.º 44
0
 public HelpCommand(CommandRegistry registry)
 {
     this.registry = registry;
 }
Ejemplo n.º 45
0
 public DefaultFrontController(CommandRegistry command_registry)
 {
     this.command_registry = command_registry;
 }
 public DefaultFrontController(CommandRegistry registry)
 {
     //this represents new functionality
     this.command_registry = registry;
 }
 public FrontControllerImplementation(CommandRegistry command_registry)
 {
     this.command_registry = command_registry;
 }
 public DefaultFrontController(CommandRegistry registry)
 {
     this.registry = registry;
 }
Ejemplo n.º 49
0
 public ConsoleApplication(CommandRegistry registry)
 {
     this.registry = registry;
 }
			public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst_, ref Array custom)
			{
				if(null != m_plugin)
					return;

				// Load up the options from file.
				string optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftyPerforce.xml");
				Config options = Config.Load(optionsFileName);

				// Every plugin needs a command bar.
				m_plugin = new Plugin((DTE2)application, (AddIn)addInInst_, "NiftyPerforce", "Aurora.NiftyPerforce.Connect", options);
				CommandBar commandBar = m_plugin.AddCommandBar("NiftyPerforce", MsoBarPosition.msoBarTop);
				m_commandRegistry = new CommandRegistry(m_plugin, commandBar);


				// Initialize the logging system.
				if(Log.HandlerCount == 0)
				{
#if DEBUG
					Log.AddHandler(new DebugLogHandler());
#endif

					Log.AddHandler(new VisualStudioLogHandler(m_plugin.OutputPane));
					Log.Prefix = "NiftyPerforce";
				}

				// Now we can take care of registering ourselves and all our commands and hooks.
				Log.Debug("Booting up...");
				Log.IncIndent();

				bool doContextCommands = true;

				bool doBindings = options.EnableBindings;
				m_commandRegistry.RegisterCommand("NiftyConfig", doBindings, new NiftyConfigure(m_plugin), true);

				m_commandRegistry.RegisterCommand("NiftyEditModified", doBindings, new P4EditModified(m_plugin), true);

				m_commandRegistry.RegisterCommand("NiftyEdit", doBindings, new P4EditItem(m_plugin), true);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyEditItem", doBindings, new P4EditItem(m_plugin), false);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyEditSolution", doBindings, new P4EditSolution(m_plugin), false);

				m_commandRegistry.RegisterCommand("NiftyDiff", doBindings, new P4DiffItem(m_plugin));
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyDiffItem", doBindings, new P4DiffItem(m_plugin), false);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyDiffSolution", doBindings, new P4DiffSolution(m_plugin), false);

				m_commandRegistry.RegisterCommand("NiftyHistory", doBindings, new P4RevisionHistoryItem(m_plugin, false), true);
				m_commandRegistry.RegisterCommand("NiftyHistoryMain", doBindings, new P4RevisionHistoryItem(m_plugin, true), true);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyHistoryItem", doBindings, new P4RevisionHistoryItem(m_plugin, false), false);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyHistoryItemMain", doBindings, new P4RevisionHistoryItem(m_plugin, true), false);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyHistorySolution", doBindings, new P4RevisionHistorySolution(m_plugin), false);

				m_commandRegistry.RegisterCommand("NiftyTimeLapse", doBindings, new P4TimeLapseItem(m_plugin, false), true);
				m_commandRegistry.RegisterCommand("NiftyTimeLapseMain", doBindings, new P4TimeLapseItem(m_plugin, true), true);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyTimeLapseItem", doBindings, new P4TimeLapseItem(m_plugin, false), false);
				if (doContextCommands) m_commandRegistry.RegisterCommand("NiftyTimeLapseItemMain", doBindings, new P4TimeLapseItem(m_plugin, true), false);

				m_commandRegistry.RegisterCommand("NiftyRevisionGraph", doBindings, new P4RevisionGraphItem(m_plugin, false), true);
				m_commandRegistry.RegisterCommand("NiftyRevisionGraphMain", doBindings, new P4RevisionGraphItem(m_plugin, true), true);
				if (doContextCommands) m_commandRegistry.RegisterCommand("NiftyRevisionGraphItem", doBindings, new P4RevisionGraphItem(m_plugin, false), false);
				if (doContextCommands) m_commandRegistry.RegisterCommand("NiftyRevisionGraphItemMain", doBindings, new P4RevisionGraphItem(m_plugin, true), false);

				m_commandRegistry.RegisterCommand("NiftyRevert", doBindings, new P4RevertItem(m_plugin), true);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyRevertItem", doBindings, new P4RevertItem(m_plugin), false);

				m_commandRegistry.RegisterCommand("NiftyShow", doBindings, new P4ShowItem(m_plugin), true);
				if(doContextCommands) m_commandRegistry.RegisterCommand("NiftyShowItem", doBindings, new P4ShowItem(m_plugin), false);

				m_plugin.AddFeature(new AutoAddDelete(m_plugin));
				m_plugin.AddFeature(new AutoCheckoutProject(m_plugin));
				m_plugin.AddFeature(new AutoCheckoutOnBuild(m_plugin));
				m_plugin.AddFeature(new AutoCheckoutTextEdit(m_plugin));
				m_plugin.AddFeature(new AutoCheckoutOnSave(m_plugin));

#if DEBUG
				// Use this to track down event GUIDs.
				//m_plugin.AddFeature(new FindEvents(m_plugin));
#endif

				P4Operations.CheckInstalledFiles();

				AsyncProcess.Init();

				Log.DecIndent();
				Log.Debug("Initialized...");

#if DEBUG
				Log.Info("NiftyPerforce (Debug)");
#else
				//Log.Info("NiftyPerforce (Release)");
#endif
				// Show where we are and when we were compiled...
				Log.Info("I'm running {0} compiled on {1}", Assembly.GetExecutingAssembly().Location, System.IO.File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location));
			}