コード例 #1
0
ファイル: BridgeTrigger.cs プロジェクト: vebin/LINQBridgeVs
 public ExecuteParams(CommandAction action, string projectName, string solutionName, string assemblyName, string projectOutput)
 {
     _action = action;
     _projectName = projectName;
     _solutionName = solutionName;
     _assemblyName = assemblyName;
     _projectOutput = projectOutput;
 }
コード例 #2
0
 public CommandResponse(CommandAction botAction)
 {
     Action = botAction;
 }
コード例 #3
0
ファイル: DataTableAdapter.cs プロジェクト: Kjubo/xms.core
		private DbCommand SetCommandInternal(CommandAction cmdAction, CommandType cmdType, string cmdText, DbParameter[] cmdParameters, bool autoPrepareCommand)
		{
			DbCommand command = this.GetCommand(cmdAction);

			command.Parameters.Clear();
			command.CommandType = cmdType;

			command.CommandText = this.PretreatmentCommandText(cmdText);

			switch (cmdAction)
			{
				case CommandAction.Select:
					_selectCommandParameters = cmdParameters;
					if (this._adapter != null)
					{
						this._adapter.Dispose();
						this._adapter = null;
					}
					if (this._builder != null)
					{
						this._builder.Dispose();
						this._builder = null;
					}
					break;
				case CommandAction.Insert:
					_insertCommandParameters = cmdParameters;
					if (this._adapter != null)
					{
						this._adapter.InsertCommand = command;
					}
					break;
				case CommandAction.Update:
					_updateCommandParameters = cmdParameters;
					if (this._adapter != null)
					{
						this._adapter.UpdateCommand = command;
					}
					break;
				case CommandAction.Delete:
					_deleteCommandParameters = cmdParameters;
					if (this._adapter != null)
					{
						this._adapter.DeleteCommand = command;
					}
					break;
				default:
					break;
			}
			if (cmdParameters != null)
			{
				for (int i = 0; i < cmdParameters.Length; i++)
				{
					command.Parameters.Add(cmdParameters[i]);
				}
			}
			if (autoPrepareCommand)
			{
				command.Prepare();
			}
			return command;
		}
コード例 #4
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommand(string name, CommandAction<CCommand, bool[]> action)
 {
     CRegistery.RegisterDelegate(name, action);
 }
コード例 #5
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommand(CommandAction<Vector4> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #6
0
 public void UpdateCommand(MenuCommand cmd, CommandAction action)
 {
     var states = GetStatus(action);
     cmd.Visible = (CommandStates.Visible & states) != 0;
     cmd.Enabled = (CommandStates.Enabled & states) != 0;
 }
コード例 #7
0
        public void IgnoresGuardIfGuardDoesNotReturnBool()
        {
            var cmd = new CommandAction(this.subject, null, "DoSomethingWithBadGuard", ActionUnavailableBehaviour.Throw, ActionUnavailableBehaviour.Throw);

            Assert.True(cmd.CanExecute(true));
        }
コード例 #8
0
ファイル: Signal.cs プロジェクト: jpennell/miranda
 public void AddOnce(CommandAction action)
 {
     onceMethods.Add(action);
 }
コード例 #9
0
 protected OrchestratorCommand(CommandAction action, UserDocument user, TPayload payload) : base(action, user, payload)
 {
 }
コード例 #10
0
 public void AddCommand(string keyword, CommandAction action)
 {
     _commands.TryAdd(keyword, action);
 }
コード例 #11
0
 /// <summary>
 /// 获取命令名称。
 /// </summary>
 /// <param name="action">命令动作。</param>
 /// <param name="name">命令名称。</param>
 /// <returns>命令名称。</returns>
 public static string GetCommandName(CommandAction action, string name)
 {
     return((action == CommandAction.None ? name : string.Format("{0}-{1}", action, name)).Trim());
 }
コード例 #12
0
        public static void ShowFormDialog(string content, int formitems, bool yes = true, bool no = true, bool cancel = true, CommandAction ya = null, CommandAction na = null)
        {
            Grid          cont        = App.Current.FindResource(content) as Grid;
            YT_FormDialog _ExitDialog = new YT_FormDialog();

            _ExitDialog.YseButtonVisibility    = yes ? Visibility.Visible : Visibility.Collapsed;
            _ExitDialog.NoButtonVisibility     = no ? Visibility.Visible : Visibility.Collapsed;
            _ExitDialog.CancelButtonVisibility = cancel ? Visibility.Visible : Visibility.Collapsed;
            _ExitDialog.ContentWidth           = 320;
            _ExitDialog.ContentHeight          = 140;
            _ExitDialog.Content        = cont;
            _ExitDialog.FormItemCounts = formitems;
            cont.DataContext           = _ExitDialog;

            _ExitDialog.YesAction += ya;
            _ExitDialog.NoAction  += na;

            _ExitDialog.ShowDialog(App.Current.MainWindow);
        }
コード例 #13
0
        public static void ShowSimpleStringDialog(string content, bool yes = true, bool no = true, bool cancel = true, CommandAction ya = null, CommandAction na = null)
        {
            Grid             cont        = App.Current.FindResource("WarningDialog") as Grid;
            YT_GeneralDialog _ExitDialog = new YT_GeneralDialog();

            _ExitDialog.YseButtonVisibility    = yes ? Visibility.Visible : Visibility.Collapsed;
            _ExitDialog.NoButtonVisibility     = no ? Visibility.Visible : Visibility.Collapsed;
            _ExitDialog.CancelButtonVisibility = cancel ? Visibility.Visible : Visibility.Collapsed;
            _ExitDialog.ContentWidth           = 280;
            _ExitDialog.ContentHeight          = 120;
            _ExitDialog.Content     = cont;
            cont.DataContext        = _ExitDialog;
            _ExitDialog.ContentText = content;

            _ExitDialog.YesAction += ya;
            _ExitDialog.NoAction  += na;

            _ExitDialog.ShowDialog(App.Current.MainWindow);
        }
コード例 #14
0
 public CommandResponse(CommandAction botAction, string responseData)
 {
     Action = botAction;
     ResponseData = responseData;
 }
コード例 #15
0
 /// <summary>
 /// 获取命令名称。
 /// </summary>
 /// <param name="action">命令动作。</param>
 /// <param name="name">命令名称。</param>
 /// <returns>命令名称。</returns>
 public static string GetCommandName(CommandAction action, string name)
 {
     return (action == CommandAction.None ? name : string.Format("{0}-{1}", action, name)).Trim();
 }
コード例 #16
0
ファイル: Console.cs プロジェクト: lancelot2112/XerUtilities
 public CommandInfo(string commandTag, string description, CommandAction action)
 {
     this.Command = commandTag;
     this.Description = description;
     this.Callback = action;
 }
コード例 #17
0
 // Notify of a new action request
 private void Target(ActionRequest request) {
     var command = new CommandAction() {
         Entities = Selected.ToArray(),
         Request = request,
     };
     SceneManager.QueueCommand(command);
 }
コード例 #18
0
        public void Execute(CommandAction action)
        {
            if (SelectedProject == null)
                return;

            BridgeTrigger.Execute(new BridgeTrigger.ExecuteParams(action, SelectedProject.FullName, SolutionName, SelectedAssemblyName, SelectedProjectOutputPath));
        }
コード例 #19
0
 public CommandActionControl(CommandAction action) : this()
 {
     this.command = action;
 }
コード例 #20
0
        public void EnablesIfTargetAndActionExistAndNoGuardMethod()
        {
            var cmd = new CommandAction(this.subject, null, "DoSomething", ActionUnavailableBehaviour.Throw, ActionUnavailableBehaviour.Throw);

            Assert.True(cmd.CanExecute(null));
        }
コード例 #21
0
 private void DoShowTaskCommand()
 {
     CommandAction?.Invoke();
     // do other stuff here...
 }
コード例 #22
0
 private CommandStates GetStatus(CommandAction action)
 {
     return GetCommandStatus(GetMultiStatus(), action);
 }
コード例 #23
0
        public PathEditor(GUISystem guiSystem)
        {
            m_GUISystem = guiSystem;

            var m_PointControl = new GenericControl("Point")
            {
                count    = GetPointCount,
                distance = (guiState, i) =>
                {
                    var position = GetPoint(i).position;
                    return(guiState.DistanceToCircle(position, guiState.GetHandleSize(position) * 10f));
                },
                position  = (i) => { return(GetPoint(i).position); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = DrawPoint
            };

            var m_EdgeControl = new GenericControl("Edge")
            {
                count     = GetEdgeCount,
                distance  = DistanceToEdge,
                position  = (i) => { return(GetPoint(i).position); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = DrawEdge
            };

            m_EdgeControl.onEndLayout = (guiState) => { controller.AddClosestPath(m_EdgeControl.layoutData.distance); };

            var m_LeftTangentControl = new GenericControl("LeftTangent")
            {
                count = () =>
                {
                    if (GetShapeType() != ShapeType.Spline)
                    {
                        return(0);
                    }

                    return(GetPointCount());
                },
                distance = (guiState, i) =>
                {
                    if (linearTangentIsZero && GetPoint(i).tangentMode == TangentMode.Linear)
                    {
                        return(float.MaxValue);
                    }

                    if (!IsSelected(i) || IsOpenEnded() && i == 0)
                    {
                        return(float.MaxValue);
                    }

                    var position = GetLeftTangent(i);
                    return(guiState.DistanceToCircle(position, guiState.GetHandleSize(position) * 10f));
                },
                position  = (i) => { return(GetLeftTangent(i)); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = (guiState, control, i) =>
                {
                    if (!IsSelected(i) || IsOpenEnded() && i == 0)
                    {
                        return;
                    }

                    var point = GetPoint(i);

                    if (linearTangentIsZero && point.tangentMode == TangentMode.Linear)
                    {
                        return;
                    }

                    var position    = point.position;
                    var leftTangent = GetLeftTangent(i);

                    drawer.DrawTangent(position, leftTangent);
                }
            };

            var m_RightTangentControl = new GenericControl("RightTangent")
            {
                count = () =>
                {
                    if (GetShapeType() != ShapeType.Spline)
                    {
                        return(0);
                    }

                    return(GetPointCount());
                },
                distance = (guiState, i) =>
                {
                    if (linearTangentIsZero && GetPoint(i).tangentMode == TangentMode.Linear)
                    {
                        return(float.MaxValue);
                    }

                    if (!IsSelected(i) || IsOpenEnded() && i == GetPointCount() - 1)
                    {
                        return(float.MaxValue);
                    }

                    var position = GetRightTangent(i);
                    return(guiState.DistanceToCircle(position, guiState.GetHandleSize(position) * 10f));
                },
                position  = (i) => { return(GetRightTangent(i)); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = (guiState, control, i) =>
                {
                    if (!IsSelected(i) || IsOpenEnded() && i == GetPointCount() - 1)
                    {
                        return;
                    }

                    var point = GetPoint(i);

                    if (linearTangentIsZero && point.tangentMode == TangentMode.Linear)
                    {
                        return;
                    }

                    var position     = point.position;
                    var rightTangent = GetRightTangent(i);

                    drawer.DrawTangent(position, rightTangent);
                }
            };

            var m_CreatePointAction = new CreatePointAction(m_PointControl, m_EdgeControl)
            {
                enable             = (guiState, action) => !IsAltDown(guiState) && !guiState.isActionKeyDown && controller.closestEditablePath == controller.editablePath,
                enableRepaint      = (guiState, action) => EnableCreatePointRepaint(guiState, m_PointControl, m_LeftTangentControl, m_RightTangentControl),
                repaintOnMouseMove = (guiState, action) => true,
                guiToWorld         = GUIToWorld,
                onCreatePoint      = (index, position) =>
                {
                    controller.RegisterUndo("Create Point");
                    controller.CreatePoint(index, position);
                },
                onPreRepaint = (guiState, action) =>
                {
                    if (GetPointCount() > 0)
                    {
                        var position = ClosestPointInEdge(guiState, guiState.mousePosition, m_EdgeControl.layoutData.index);
                        drawer.DrawCreatePointPreview(position);
                    }
                }
            };

            Action <IGUIState> removePoints = (guiState) =>
            {
                controller.RegisterUndo("Remove Point");
                controller.RemoveSelectedPoints();
                guiState.changed = true;
            };

            var m_RemovePointAction1 = new CommandAction(kDeleteCommandName)
            {
                enable    = (guiState, action) => { return(GetSelectedPointCount() > 0); },
                onCommand = removePoints
            };

            var m_RemovePointAction2 = new CommandAction(kSoftDeleteCommandName)
            {
                enable    = (guiState, action) => { return(GetSelectedPointCount() > 0); },
                onCommand = removePoints
            };

            var dragged           = false;
            var m_MovePointAction = new SliderAction(m_PointControl)
            {
                enable  = (guiState, action) => !IsAltDown(guiState),
                onClick = (guiState, control) =>
                {
                    dragged = false;
                    var index = control.layoutData.index;

                    if (!IsSelected(index))
                    {
                        controller.RegisterUndo("Selection");

                        if (!guiState.isActionKeyDown)
                        {
                            controller.ClearSelection();
                        }

                        controller.SelectPoint(index, true);
                        guiState.changed = true;
                    }
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index = control.hotLayoutData.index;
                    var delta = SnapIfNeeded(position) - GetPoint(index).position;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Point");
                        dragged = true;
                    }

                    controller.MoveSelectedPoints(delta);
                }
            };

            var m_MoveEdgeAction = new SliderAction(m_EdgeControl)
            {
                enable        = (guiState, action) => !IsAltDown(guiState) && guiState.isActionKeyDown,
                onSliderBegin = (guiState, control, position) =>
                {
                    dragged = false;
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index = control.hotLayoutData.index;
                    var delta = position - GetPoint(index).position;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Edge");
                        dragged = true;
                    }

                    controller.MoveEdge(index, delta);
                }
            };

            var cachedRightTangent = Vector3.zero;
            var cachedLeftTangent  = Vector3.zero;
            var cachedTangentMode  = TangentMode.Linear;

            var m_MoveLeftTangentAction = new SliderAction(m_LeftTangentControl)
            {
                enable        = (guiState, action) => !IsAltDown(guiState),
                onSliderBegin = (guiState, control, position) =>
                {
                    dragged = false;
                    var point = GetPoint(control.hotLayoutData.index);
                    cachedRightTangent = point.rightTangent;
                    cachedTangentMode  = point.tangentMode;
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index       = control.hotLayoutData.index;
                    var setToLinear = m_PointControl.distance(guiState, index) <= DefaultControl.kPickDistance;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Tangent");
                        dragged = true;
                    }

                    position = SnapIfNeeded(position);
                    controller.SetLeftTangent(index, position, setToLinear, guiState.isShiftDown, cachedRightTangent, cachedTangentMode);
                }
            };

            var m_MoveRightTangentAction = new SliderAction(m_RightTangentControl)
            {
                enable        = (guiState, action) => !IsAltDown(guiState),
                onSliderBegin = (guiState, control, position) =>
                {
                    dragged = false;
                    var point = GetPoint(control.hotLayoutData.index);
                    cachedLeftTangent = point.leftTangent;
                    cachedTangentMode = point.tangentMode;
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index       = control.hotLayoutData.index;
                    var setToLinear = m_PointControl.distance(guiState, index) <= DefaultControl.kPickDistance;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Tangent");
                        dragged = true;
                    }

                    position = SnapIfNeeded(position);
                    controller.SetRightTangent(index, position, setToLinear, guiState.isShiftDown, cachedLeftTangent, cachedTangentMode);
                }
            };

            m_GUISystem.AddControl(m_EdgeControl);
            m_GUISystem.AddControl(m_PointControl);
            m_GUISystem.AddControl(m_LeftTangentControl);
            m_GUISystem.AddControl(m_RightTangentControl);
            m_GUISystem.AddAction(m_CreatePointAction);
            m_GUISystem.AddAction(m_RemovePointAction1);
            m_GUISystem.AddAction(m_RemovePointAction2);
            m_GUISystem.AddAction(m_MovePointAction);
            m_GUISystem.AddAction(m_MoveEdgeAction);
            m_GUISystem.AddAction(m_MoveLeftTangentAction);
            m_GUISystem.AddAction(m_MoveRightTangentAction);
        }
コード例 #24
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommand(CommandAction<CCommand, int[]> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #25
0
 public CommandActionWithStringAndAction(CommandAction commandAction, string commandLineArgument, Action <string[]> action)
 {
     this.commandAction       = commandAction;
     this.commandLineArgument = commandLineArgument;
     this.action = action;
 }
コード例 #26
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommand(CommandAction<float, float> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #27
0
        static void Main(string[] args)
        {
            // Check if we need to print help by checking for -h or --help at the first or second index
            // Also, when fewer arguments are available, print the help
            int shortIndex = Array.IndexOf(args, "-h");
            int longIndex  = Array.IndexOf(args, "--help");

            if (args.Length < 2 || shortIndex == 0 || shortIndex == 1 || longIndex == 0 || longIndex == 1)
            {
                PrintHelp();
                return;
            }

            int  commandIndex = 1;
            byte runOnDays    = 0;

            if (args[1] == "--days")
            {
                commandIndex += 2;
                string[] splitDays = args[2].Split(",");

                for (int i = 0; i < splitDays.Length; i++)
                {
                    if (splitDays[i].Length == 1)
                    {
                        // Attempt to parse it as an integer
                        int dayIndex;
                        if (int.TryParse(splitDays[i], out dayIndex))
                        {
                            Day?foundIntDay = DayUtils.FindDay(dayIndex);
                            if (foundIntDay.HasValue)
                            {
                                runOnDays |= (byte)foundIntDay.Value;
                                continue;
                            }
                        }
                    }
                    // Attempt to find the day as valid string
                    Day?foundStrDay = DayUtils.FindDay(splitDays[i]);
                    if (!foundStrDay.HasValue)
                    {
                        Console.Error.WriteLine($"Invalid day: {splitDays[i]}");
                        Environment.Exit(1);
                    }
                    runOnDays |= (byte)foundStrDay.Value;
                }
            }

            string commandFileName  = args[commandIndex++];
            string commandArguments = CommandAction.BuildArguments(args, commandIndex);

            IntervalRange[] intervals = IntervalRange.GetIntervals(args[0], Console.Error);
            if (intervals == null)
            {
                Environment.Exit(1);
            }

            IntervalScheduler intervalScheduler = new IntervalScheduler(
                new CommandAction(commandFileName, commandArguments), intervals);

            if (runOnDays != 0)
            {
                intervalScheduler.SetDayFlags(runOnDays);
            }

            intervalScheduler.RunScheduler(CancellationToken.None);
        }
コード例 #28
0
ファイル: BounceRunner.cs プロジェクト: svoruganti/bounce
        private void BuildTarget(Dictionary<string, ITask> targets, string targetName, CommandAction commandAction)
        {
            ITask task = FindTarget(targets, targetName);

            using (ITaskScope targetScope = _bounce.TaskScope(task, commandAction.Command, targetName)) {
                commandAction.Action(task);
                targetScope.TaskSucceeded();
            }
        }
コード例 #29
0
 public ResCommand()
 {
     action = new CommandAction();
 }
コード例 #30
0
 public CommandLineParseException(string parserMessage, CommandAction action)
 {
     _parserMessage = parserMessage;
     _action        = action;
 }
コード例 #31
0
 public TwitchCommand(CommandAction action, float defaultCooldown = 0)
 {
     this.action = action;
     enabled     = true;
     cooldown    = defaultCooldown;
 }
コード例 #32
0
ファイル: Console.cs プロジェクト: lancelot2112/XerUtilities
        public void RegisterCommand(string commandTag, string description, CommandAction callback)
        {
            string lowerCommand = commandTag.ToLower();
            if (commandTable.ContainsKey(lowerCommand))
            {
                throw new InvalidOperationException(
                    String.Format("Command \"{0}\" is already registered.", commandTag));
            }

            commandTable.Add(lowerCommand, new CommandInfo(commandTag, description, callback));
        }
コード例 #33
0
 public static void Subscribe_OnMessageEvent(CommandAction nonCommandMessageAction)
 {
     instance.onmessage += nonCommandMessageAction;
 }
コード例 #34
0
        private void SetFieldValuesFromShortcut()
        {
            eventBlock                         = true;
            ShortcutNameField.Text             = Shortcut.Name;
            ShortcutTitleName.Text             = Shortcut.Name;
            eventBlock                         = true;
            ShortcutTypeComboBox.SelectedIndex = (int)ShortcutType;
            if (!string.IsNullOrEmpty(Shortcut.IconPath))
            {
                if (!File.Exists(Shortcut.IconPath))
                {
                    Shortcut.IconPath    = string.Empty;
                    ShotcutNameText.Text = "No icon selected.";
                }
                else
                {
                    ShotcutNameText.Text = Path.GetFileName(Shortcut.IconPath);
                }
            }
            else
            {
                ShotcutNameText.Text = "No icon selected.";
            }

            switch (ShortcutType)
            {
            case ShortcutType.Web:
                WebsiteAction webaction = (WebsiteAction)Shortcut.Actions[0];
                eventBlock           = true;
                WebsiteUriField.Text = webaction.Url;
                eventBlock           = true;
                break;

            case ShortcutType.File:
                FileAction fileAction = (FileAction)Shortcut.Actions[0];
                eventBlock       = true;
                FileUi_Path.Text = fileAction.Path;
                break;

            case ShortcutType.Folder:
                FolderAction folderAction = (FolderAction)Shortcut.Actions[0];
                eventBlock         = true;
                FolderUi_Path.Text = folderAction.Path;
                break;

            case ShortcutType.Software:
                SoftwareAction softwareAction = (SoftwareAction)Shortcut.Actions[0];
                eventBlock           = true;
                SoftwareUi_Path.Text = softwareAction.Path;
                break;

            case ShortcutType.Command:
                CommandAction comaction = (CommandAction)Shortcut.Actions[0];
                eventBlock                   = true;
                CommandUi_Comand.Text        = comaction.Command;
                eventBlock                   = true;
                CommandUi_KeepOpen.IsChecked = comaction.KeepOpen;
                break;

            case ShortcutType.Multi:
                break;
            }

            eventBlock = false;
        }
コード例 #35
0
 public CommandProcessor(ScenarioContext scenarioContext)
 {
     _scenarioContext     = scenarioContext;
     DefaultCommandAction = CommandAction.Default;
 }
コード例 #36
0
 public Command(string name, string help, CommandAction action)
 {
     Name   = name;
     Help   = help;
     Action = action;
 }
コード例 #37
0
 public void Execute(object parameter)
 {
     CommandAction?.Invoke(parameter);
 }
コード例 #38
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connStr"></param>
 /// <param name="action"></param>
 public Cloud2DeviceListener(string connStr, CommandAction action) : this(connStr)
 {
     this.Action = action;
 }
コード例 #39
0
 public CommandActionControl(ActionContainerControl containerControl, CommandAction action) : this(containerControl) { this.command = action; }
コード例 #40
0
        public void ThrowsIfTargetNullBehaviourIsThrowAndTargetBecomesNull()
        {
            var cmd = new CommandAction(this.subject, null, "DoSomething", ActionUnavailableBehaviour.Throw, ActionUnavailableBehaviour.Disable);

            Assert.Throws <ActionTargetNullException>(() => View.SetActionTarget(this.subject, null));
        }
コード例 #41
0
        /// <summary>
        /// Adds a command to the template.
        /// </summary>
        /// <param name="nameTemplate">A '|' separated list of valid names for this option.</param>
        /// <param name="description">A description of the command</param>
        /// <param name="validOptions">A '|' separated list of valid options for this command. Using CommandLineTemplate.IgnoreOptions will accept any option</param>
        /// <param name="action">The action to invoke for this command (may be null).</param>
        /// <returns>This.</returns>
        public CommandLineTemplate AddCommand(string nameTemplate, string description, string validOptions, CommandAction action)
        {
            string[] names = nameTemplate.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            CommandTemplate commandTemplate = new CommandTemplate(description, validOptions, (action != null ? action : (O) => { }));

            foreach (string name in names)
            {
                CommandTemplates.Add(name, commandTemplate);
            }

            return(this);
        }
コード例 #42
0
        public void Execute(CommandAction action)
        {
            if (SelectedProject == null)
                return;

            var allProjectReferences = Crawler.FindProjectDependencies(SelectedProject.FullName, SolutionName);
            var foundProjects = allProjectReferences as IList<Dependency.Project> ?? allProjectReferences.ToList();
            var projectReferences = foundProjects.Where(project => project.DependencyType == DependencyType.ProjectReference);
            // var assemblyReferences = allProjectReferences.Where(project => project.DependencyType == DependencyType.AssemblyReference);

            var references = projectReferences as IList<Dependency.Project> ?? projectReferences.ToList();
            switch (action)
            {
                case CommandAction.Enable:
                    const string enableMessage = "Following project dependencies have been found...LINQBridge them? (Recommended)";
                    PackageConfigurator.EnableProject(SelectedProjectOutputPath, SelectedAssemblyName, SolutionName);
                    var enabledDependencies = new List<string>();
                    enabledDependencies.Insert(0, SelectedAssemblyName);

                    if (references.Any(project => PackageConfigurator.IsBridgeDisabled(project.AssemblyName, SolutionName)))
                    {
                        var projectDependencies = new ProjectDependencies(references, enableMessage);
                        var dependencies = projectDependencies.ShowDependencies(PackageConfigurator.EnableProject);
                        enabledDependencies.AddRange(dependencies.Select(project => project.AssemblyName));
                    }

                    MessageBox.Show(string.Format("LINQBridge on {0} has been Enabled...", string.Join(", ", enabledDependencies)), "Success", MessageBoxButtons.OK);

                    break;
                case CommandAction.Disable:
                    const string disableMessage = "Following project dependencies have been found...Un-LINQBridge them? (Recommended)";

                    PackageConfigurator.DisableProject(SelectedProjectOutputPath, SelectedAssemblyName, SolutionName);
                    var disableDependencies = new List<string>();
                    disableDependencies.Insert(0, SelectedAssemblyName);

                    if (references.Any(project => PackageConfigurator.IsBridgeEnabled(project.AssemblyName, SolutionName)))
                    {
                        var projectDependencies = new ProjectDependencies(references, disableMessage);
                        var dependencies = projectDependencies.ShowDependencies(PackageConfigurator.DisableProject);
                        disableDependencies.AddRange(dependencies.Select(project => project.AssemblyName));
                    }

                    MessageBox.Show(string.Format("LINQBridge on {0} has been Disabled...", string.Join(", ", disableDependencies)), "Success", MessageBoxButtons.OK);

                    break;
                default:
                    throw new ArgumentOutOfRangeException("action");
            }
        }
コード例 #43
0
ファイル: Program.cs プロジェクト: jgowdy/AsterNET
        private static void checkManagerAPI()
        {
            manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD);

            // Register user event class
            manager.RegisterUserEventClass(typeof(UserAgentLoginEvent));

            // Add or Remove events
            manager.UserEvents += new UserEventHandler(dam_UserEvents);

            // Dont't display this event
            //manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent);
            manager.NewExten += new NewExtenEventHandler(manager_HandleNewExtentEvent);

            // Display all other
            manager.UnhandledEvent += new ManagerEventHandler(dam_Events);

            // Handle the response from AGI Exec
            manager.AGIExec += new AGIExecHandler(manager_AgiEvent);

            // +++ Only to debug purpose
            manager.FireAllEvents = true;
            // manager.DefaultEventTimeout = 0;
            // manager.DefaultResponseTimeout = 0;
            manager.PingInterval = 0;
            // +++
            try
            {
                manager.Login();                                        // Login only (fast)

                Console.WriteLine("Asterisk version : " + manager.Version);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
                manager.Logoff();
                return;
            }

            {
                Console.WriteLine("\nGetConfig action");
                ManagerResponse response = manager.SendAction(new GetConfigAction("manager.conf"));
                if (response.IsSuccess())
                {
                    GetConfigResponse responseConfig = (GetConfigResponse)response;
                    foreach (int key in responseConfig.Categories.Keys)
                    {
                        Console.WriteLine(string.Format("{0}:{1}", key, responseConfig.Categories[key]));
                        foreach (int keyLine in responseConfig.Lines(key).Keys)
                        {
                            Console.WriteLine(string.Format("\t{0}:{1}", keyLine, responseConfig.Lines(key)[keyLine]));
                        }
                    }
                }
                else
                {
                    Console.WriteLine(response);
                }
            }

            {
                Console.WriteLine("\nUpdateConfig action");
                UpdateConfigAction config = new UpdateConfigAction("manager.conf", "manager.conf");
                config.AddCommand(UpdateConfigAction.ACTION_NEWCAT, "testadmin");
                config.AddCommand(UpdateConfigAction.ACTION_APPEND, "testadmin", "secret", "blabla");
                ManagerResponse response = manager.SendAction(config);
                Console.WriteLine(response);
            }

            // Originate call example
            Console.WriteLine("\nPress ENTER key to originate call.\n"
                              + "Start phone (or connect) or make a call to see events.\n"
                              + "After all events press a key to originate call.");
            Console.ReadLine();

            OriginateAction oc = new OriginateAction();

            oc.Context  = ORIGINATE_CONTEXT;
            oc.Priority = "1";             // can be int in quotes or also be a label specified in the dial plan
            oc.Channel  = ORIGINATE_CHANNEL;
            oc.CallerId = ORIGINATE_CALLERID;
            oc.Exten    = ORIGINATE_EXTEN;
            oc.Timeout  = ORIGINATE_TIMEOUT;
            // oc.Variable = "VAR1=abc|VAR2=def";
            // oc.SetVariable("VAR3", "ghi");
            ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout);

            Console.WriteLine("Response:");
            Console.WriteLine(originateResponse);

            Console.WriteLine("Press ENTER key to next test.");
            Console.ReadLine();

            //
            // Display result of Show Queues command
            //
            {
                CommandAction   command  = new CommandAction();
                CommandResponse response = new CommandResponse();
                if (manager.AsteriskVersion == AsteriskVersion.ASTERISK_1_6)
                {
                    command.Command = "queue show";
                }
                else
                {
                    command.Command = "show queues";
                }
                try
                {
                    response = (CommandResponse)manager.SendAction(command);
                    Console.WriteLine("Result of " + command.Command);
                    foreach (string str in response.Result)
                    {
                        Console.WriteLine("\t" + str);
                    }
                }
                catch (Exception err)
                {
                    Console.WriteLine("Response error: " + err);
                }
                Console.WriteLine("Press ENTER to next test or CTRL-C to exit.");
                Console.ReadLine();
            }
            //
            // Display Queues and Members
            //
            ResponseEvents re;

            try
            {
                re = manager.SendEventGeneratingAction(new QueueStatusAction());
            }
            catch (EventTimeoutException e)
            {
                // this happens with Asterisk 1.0.x as it doesn't send a QueueStatusCompleteEvent
                re = e.PartialResult;
            }

            foreach (ManagerEvent e in re.Events)
            {
                if (e is QueueParamsEvent)
                {
                    QueueParamsEvent qe = (QueueParamsEvent)e;
                    Console.WriteLine("QueueParamsEvent" + "\n\tQueue:\t\t" + qe.Queue + "\n\tServiceLevel:\t" + qe.ServiceLevel);
                }
                else if (e is QueueMemberEvent)
                {
                    QueueMemberEvent qme = (QueueMemberEvent)e;
                    Console.WriteLine("QueueMemberEvent" + "\n\tQueue:\t\t" + qme.Queue + "\n\tLocation:\t" + qme.Location);
                }
                else if (e is QueueEntryEvent)
                {
                    QueueEntryEvent qee = (QueueEntryEvent)e;
                    Console.WriteLine("QueueEntryEvent" + "\n\tQueue:\t\t" + qee.Queue + "\n\tChannel:\t" + qee.Channel + "\n\tPosition:\t" + qee.Position);
                }
            }

            Console.WriteLine("Press ENTER to next test or CTRL-C to exit.");
            Console.ReadLine();

            //
            //	To test create 3 extensions:
            //	1 - SIP/4012 w/o voicemail (with eyeBeam softphone)
            //	2 - IAX2/4008 w/o voicemail (with iaxComm softphone)
            //	3 - SIP/4010 w/ voicemal but no phone connect

            //	RedirectCall: call from IAX2/4008 to SIP/4012
            //	Don't answer on SIP/4012 and call must redirect to SIP/4010 (to voicemail really)
            //	Dial event used to define redirect channel

            Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC.");
            // Wait for Dial Event from ORIGINATE_CHANNEL
            DialEventHandler de = new DialEventHandler(dam_Dial);

            manager.Dial += de;
            while (transferChannel == null)
            {
                System.Threading.Thread.Sleep(100);
                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                {
                    break;
                }
            }
            manager.Dial -= de;

            // Now send Redirect action
            RedirectAction ra = new RedirectAction();

            ra.Channel      = transferChannel;
            ra.ExtraChannel = ORIGINATE_EXTRA_CHANNEL;
            ra.Context      = ORIGINATE_CONTEXT;
            ra.Exten        = ORIGINATE_EXTRA_EXTEN;
            ra.Priority     = 1;
            try
            {
                ManagerResponse mr = manager.SendAction(ra, 10000);
                Console.WriteLine("Transfer Call"
                                  + "\n\tResponse:" + mr.Response
                                  + "\n\tMessage:" + mr.Message
                                  );
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            //	Monitor call.
            //	Call from IA2/4008 to SIP/4012
            //	Link event used to define monitor channel
            Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC.");
            // Wait for Link event
            LinkEventHandler le = new LinkEventHandler(dam_Link);

            manager.Link += le;
            while (monitorChannel == null)
            {
                System.Threading.Thread.Sleep(100);
                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                {
                    break;
                }
            }
            manager.Link -= le;
            // Now send Monitor action
            MonitorAction ma = new MonitorAction();

            ma.Channel = monitorChannel;
            ma.File    = "voicefile";
            ma.Format  = "gsm";
            ma.Mix     = true;
            try
            {
                ManagerResponse mr = manager.SendAction(ma, 10000);
                Console.WriteLine("Monitor Call"
                                  + "\n\tResponse:" + mr.Response);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            manager.Logoff();
        }
コード例 #44
0
        private static CommandStates GetCommandStatus(int status, CommandAction action)
        {
            if (status == 0)
                return CommandStates.None;

            var result = ((action == CommandAction.Disable ? status >> 1 : status) & 1) != 0;

            if (result)
                return CommandStates.Enabled | CommandStates.Visible;

            return CommandStates.None;
        }
コード例 #45
0
ファイル: QueryService.cs プロジェクト: erisonliang/sql-d
 public QueryService(ConfigService configService, RegistryService registryService, ClientFactory clientFactory, UnknownAction unknownAction, DescribeAction describeAction, CommandAction commandAction, QueryAction queryAction)
 {
     this.config         = configService ?? throw new ArgumentNullException(nameof(configService));
     this.registry       = registryService ?? throw new ArgumentNullException(nameof(registryService));
     this.clients        = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));
     this.unknownAction  = unknownAction ?? throw new ArgumentNullException(nameof(unknownAction));
     this.describeAction = describeAction ?? throw new ArgumentNullException(nameof(describeAction));
     this.commandAction  = commandAction ?? throw new ArgumentNullException(nameof(commandAction));
     this.queryAction    = queryAction ?? throw new ArgumentNullException(nameof(queryAction));
 }
コード例 #46
0
 public CommandLineParseException(string parserMessage, CommandAction action)
 {
     _parserMessage = parserMessage;
     _action = action;
 }
コード例 #47
0
        // Contect data

        public LecturerCommand(LecturerReceiver receiver, CommandAction action)
        {
            this._lecturerReceiver = receiver;
            this._lecturerAction   = action;
        }
コード例 #48
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommand(CommandAction<CCommand, string, string, string> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #49
0
 static void AddCommand(string comm, CommandAction action)
 {
     commandList.Add(new LogCommand(comm, action));
 }
コード例 #50
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommand(string name, CommandAction<Vector4> action)
 {
     CRegistery.RegisterDelegate(name, action);
 }
コード例 #51
0
 public LogCommand(string command, CommandAction action)
 {
     this.command = command.Split(' ');
     this.action  = action;
 }
コード例 #52
0
ファイル: Lunar.cs プロジェクト: mswf/game-a-week
 public static void RegisterCommand(CommandAction<bool, bool, bool> action)
 {
     CRegistery.RegisterDelegate(action);
 }
コード例 #53
0
ファイル: Command.cs プロジェクト: stinby/Innovator.Client
 /// <summary>
 /// <a href="https://en.wikipedia.org/wiki/Fluent_interface">Fluent</a> interface used to
 /// specify the SOAP action to use with the AML
 /// </summary>
 /// <param name="action">The SOAP action to send with the AML</param>
 /// <returns>The current command for chaining additional method calls</returns>
 public Command WithAction(CommandAction action)
 {
     this.Action = action;
     return(this);
 }
コード例 #54
0
ファイル: DataTableAdapter.cs プロジェクト: Kjubo/xms.core
		private DbCommand GetCommand(CommandAction commandAction)
		{
			switch (commandAction)
			{
				case CommandAction.Insert:
					if (this._insertCommand == null)
					{
						this._insertCommand = this.CreateCommand();
					}
					return this._insertCommand;
				case CommandAction.Update:
					if (this._updateCommand == null)
					{
						this._updateCommand = this.CreateCommand();
					}
					return this._updateCommand;
				case CommandAction.Delete:
					if (this._deleteCommand == null)
					{
						this._deleteCommand = this.CreateCommand();
					}
					return this._deleteCommand;
				case CommandAction.Select:
					if (this._selectCommand == null)
					{
						this._selectCommand = this.CreateCommand();
					}
					return this._selectCommand;
				default:
					return this.CreateCommand();
			}
		}
コード例 #55
0
 // Queue a command to be invoked as soon as possible
 public static void QueueCommand(CommandAction command) {
     if (Instance != null) Instance.Commands.Add(command);
 }
コード例 #56
0
ファイル: DataTableAdapter.cs プロジェクト: Kjubo/xms.core
		private DataTableAdapter SetCommand(CommandAction cmdAction, CommandType cmdType, string cmdText, DbParameter[] cmdParameters, bool autoPrepareCommand)
		{
			this.SetCommandInternal(cmdAction, cmdType, cmdText, cmdParameters, autoPrepareCommand);

			return this;
		}
コード例 #57
0
 /// <summary>
 /// 初始化一个新的命令标记。
 /// </summary>
 /// <param name="commandAction">命令动作。</param>
 /// <param name="commandName">命令名称。</param>
 public CommandAttribute(CommandAction commandAction, string commandName)
 {
     Action = commandAction;
     CommandName = commandName.NotEmptyOrWhiteSpace("commandName");
 }
コード例 #58
0
ファイル: Command.cs プロジェクト: DmitryZyr/CVARC
 public static Command Act(CommandAction action)
 {
     return new Command { Action = action, Time = 1 };
 }
コード例 #59
0
 /// <summary>
 /// 初始化一个新的命令标记。
 /// </summary>
 /// <param name="commandAction">命令动作。</param>
 /// <param name="commandName">命令名称。</param>
 /// <param name="description">命令说明。</param>
 public CommandAttribute(CommandAction commandAction, string commandName, string description)
     : this(commandName)
 {
     Action = commandAction;
     Description = description.NotEmptyOrWhiteSpace("description");
 }