public void Details()
 {
     ProConsole.WriteLine();
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Audio = '{0}'", ControlSystem.Instance.SupportsAudio);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports BACNet = '{0}'", ControlSystem.Instance.SupportsBACNet);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Bluetooth = '{0}'", ControlSystem.Instance.SupportsBluetooth);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Changing Video Resolution = '{0}'", ControlSystem.Instance.SupportsChangingVideoResolution);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports ComPorts = '{0}'", ControlSystem.Instance.SupportsComPort);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Connect It Devices = '{0}'", ControlSystem.Instance.SupportsConnectItDevices);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Cresnet = '{0}'", ControlSystem.Instance.SupportsCresnet);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Digital Input = '{0}'", ControlSystem.Instance.SupportsDigitalInput);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Display Slot = '{0}'", ControlSystem.Instance.SupportsDisplaySlot);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports ER Radio = '{0}'", ControlSystem.Instance.SupportsERRadio);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Ethernet = '{0}'", ControlSystem.Instance.SupportsEthernet);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Flash Projects = '{0}'", ControlSystem.Instance.SupportsFlashProjects);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Internal AirMedia = '{0}'", ControlSystem.Instance.SupportsInternalAirMedia);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Internal RF Gateway = '{0}'", ControlSystem.Instance.SupportsInternalRFGateway);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Internal Streaming = '{0}'", ControlSystem.Instance.SupportsInternalStreaming);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports IR In = '{0}'", ControlSystem.Instance.SupportsIRIn);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports IR Out = '{0}'", ControlSystem.Instance.SupportsIROut);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Microphones = '{0}'", ControlSystem.Instance.SupportsMicrophones);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Relay = '{0}'", ControlSystem.Instance.SupportsRelay);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports SNMP = '{0}'", ControlSystem.Instance.SupportsSNMP);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Switcher Inputs = '{0}'", ControlSystem.Instance.SupportsSwitcherInputs);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Switcher Outputs = '{0}'", ControlSystem.Instance.SupportsSwitcherOutputs);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports System Monitor = '{0}'", ControlSystem.Instance.SupportsSystemMonitor);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports 3-Series Plug-In Cards = '{0}'", ControlSystem.Instance.SupportsThreeSeriesPlugInCards);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports USB HID = '{0}'", ControlSystem.Instance.SupportsUsbHid);
     Debug.WriteDebugLine(ControlSystem.Instance, "Supports Versiport = '{0}'", ControlSystem.Instance.SupportsVersiport);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to execute a command with the specified argument text.
        /// <para>This text should be the contents of the command line, without this <see cref="GlobalCommand"/>'s command name.</para>
        /// <para>Example: 'sampleCommand verb defaultValue --flag --operand operandValue'</para>
        /// <para>This allows commands to be executed from a source other than the command prompt.</para>
        /// </summary>
        /// <param name="args">The command line arguments, including the command, verb, defaultValue, operands, and flags.</param>
        public void ExecuteCommand(string args)
        {
            try
            {
                var command = commandRegex.Match(args);

                if (command.Success)
                {
                    var cmdName      = command.Groups["name"].Value.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim();
                    var verb         = command.Groups["verb"].Value.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim();
                    var defaultValue = command.Groups["defaultValue"].Value.Trim();

                    var result   = parametersRegex.Matches(command.Groups["parameters"].Value.Trim());
                    var operands = new Dictionary <string, string>();

                    for (var i = 0; i < result.Count; i++)
                    {
                        if (result[i].Success && result[i].Groups["name"].Length > 0)
                        {
                            var val = result[i].Groups["name"].Value.ToLower().Trim();
                            if (!operands.ContainsKey(val))
                            {
                                operands.Add(val, result[i].Groups["value"].Value);
                            }
                            else
                            {
                                WriteErrorMethod(string.Format("The '{0}' operand or flag was used more than once.\r\n", result[i].Groups["name"].Value));
                                WriteErrorMethod(string.Format("Duplicate operand or flag names are not allowed!"));
                                return;
                            }
                        }
                        else if (result[i].Success && result[i].Groups["shortName"].Length > 0)
                        {
                            var values = result[i].Groups["shortName"].Value.ToCharArray();

                            for (var j = 0; j < values.Length; j++)
                            {
                                if (!operands.ContainsKey(values[j].ToString()))
                                {
                                    operands.Add(values[j].ToString(), string.Empty);
                                }
                            }
                        }
                    }

                    ProcessCommand(cmdName, verb, defaultValue, operands);
                }
                else if (args.ToLower().Contains("--help") || args.ToLower().Contains("-h"))
                {
                    PrintGlobalCommandsHelp();
                }
                else
                {
                    WriteErrorMethod("You must enter the name of a command. Enter '--help' for a list of available commands.");
                }
            }
            catch (TerminalCommandException e)
            {
                var cee = CommandExceptionEncountered;
                if (cee != null)
                {
                    cee.Invoke(this, new TerminalCommandExceptionEventArgs(e, args));
                }
                else
                {
                    throw e;
                }
            }
            catch (Exception ex)
            {
                var e   = new TerminalCommandException(ex, string.Format("Exception encountered while executing Terminal Command: '{0}'.", args));
                var cee = CommandExceptionEncountered;
                if (cee != null)
                {
                    cee.Invoke(this, new TerminalCommandExceptionEventArgs(e, args));
                }
                else
                {
                    ProConsole.WriteLine();
                    ProConsole.WriteError("Exception encountered while executing Terminal Command: '{0}'.\r\n{1}", args, ex.ToString());
                }
            }
        }