예제 #1
0
        /// <summary>Конструктор команды.</summary>
        /// <param name="execute">Выполняемый метод команды.</param>
        /// <param name="canExecute">Метод проверяющий состояние команды.</param>
        public RelayCommand(ExecuteHandler execute, CanExecuteHandler canExecute = null)
        {
            this.execute = execute ?? throw new ArgumentNullException(nameof(execute));

            this.canExecute = canExecute ?? CanExecuteTrue;
        }
예제 #2
0
 private WindowAction(string id, ExecuteHandler executeHandler, string menuPath)
 {
     this.id             = id;
     this.executeHandler = executeHandler;
     this.menuPath       = menuPath;
 }
예제 #3
0
 public GenerateQueryPlanCommand()
 {
     EnableCondition = new ConcreteCondition(false);
     ExecuteCommand += new ExecuteHandler(GenerateQueryPlan);
 }
예제 #4
0
 public RelayCommand(ExecuteHandler execute, CanExecuteHandler?canExecute = null)
 {
     _execute    = execute ?? throw new ArgumentNullException(nameof(execute));
     _canExecute = canExecute;
 }
예제 #5
0
 /// <summary>
 /// Creates the behavior from the given delegates.
 /// </summary>
 public AnonymousBehavior(ExecuteHandler behavior, AppliesToHandler?appliesTo = null, string?name = null)
 {
     this.behavior  = behavior;
     this.appliesTo = appliesTo ?? new AppliesToHandler(invocation => true);
     this.name      = name;
 }
예제 #6
0
 /// <summary>
 /// Executes the provided <see cref="ExecuteHandler"/> provided in the constructor.
 /// </summary>
 public IMethodReturn Execute(IMethodInvocation invocation, ExecuteHandler next) => behavior(invocation, next);
예제 #7
0
 public WindowUICommand(string text, string name, Window window, CanExecuteHandler canExecute, ExecuteHandler execute) 
    : this(text, name, window)
 {
    OnCanExecute += canExecute;
    OnExecute += execute;
 }
예제 #8
0
 public IMethodReturn Execute(IMethodInvocation invocation, ExecuteHandler next)
 {
     return(invocation.CreateValueReturn(new object()));
 }
예제 #9
0
파일: Scripts.cs 프로젝트: IllidanS4/AlbLib
 /// <summary>
 /// Executes script.
 /// </summary>
 /// <param name="index">
 /// The script index to execute.
 /// </param>
 /// <param name="handler">
 /// Delegate which is called.
 /// </param>
 /// <returns>
 /// True on success. False on failure.
 /// </returns>
 public static bool RunScript(int index, ExecuteHandler handler)
 {
     return handler(GetScript(index));
 }
예제 #10
0
파일: Scripts.cs 프로젝트: IllidanS4/AlbLib
 /// <summary>
 /// Executes script.
 /// </summary>
 /// <param name="script">
 /// The script text to execute.
 /// </param>
 /// <param name="handler">
 /// Delegate which is called.
 /// </param>
 /// <returns>
 /// True on success. False on failure.
 /// </returns>
 public static bool RunScript(string script, ExecuteHandler handler)
 {
     return handler(script);
 }
예제 #11
0
        /// <summary>
        /// 执行自定义的操作,返回REST结果集
        /// </summary>
        /// <typeparam name="TReturn">REST结果集中代表结果主体的数据类型</typeparam>
        /// <param name="executeFunc">自定义操作,该参数是一个委托</param>
        /// <returns>返回处理后的REST结果集</returns>
        public virtual Result <TReturn> Execute <TReturn>(ExecuteHandler <TContext, TReturn> executeFunc)
        {
            Dictionary <string, object> args = new Dictionary <string, object>();

            return(Execute <TReturn>(executeFunc, args));
        }
예제 #12
0
 public IMethodReturn Execute(IMethodInvocation invocation, ExecuteHandler next)
 => new MethodReturn(invocation, "test", invocation.Arguments);
예제 #13
0
 /// <summary>
 /// Executes script.
 /// </summary>
 /// <param name="script">
 /// The script text to execute.
 /// </param>
 /// <param name="handler">
 /// Delegate which is called.
 /// </param>
 /// <returns>
 /// True on success. False on failure.
 /// </returns>
 public static bool RunScript(string script, ExecuteHandler handler)
 {
     return(handler(script));
 }
예제 #14
0
 public static WindowAction CreateWindowMenuItem(string id, ExecuteHandler executeHandler, string menuPath)
 {
     return(new WindowAction(id, executeHandler, menuPath));
 }
 public DelegateCommand(ExecuteHandler aExecute, CanExecuteHandler aCanExecute)
     : this(aExecute, aCanExecute, null)
 {
 }
예제 #16
0
        /// <summary>
        /// 执行一个自定义的事务处理.
        /// </summary>
        /// <param name="cmMode">连接管理模式.</param>
        /// <param name="handler">事务处理回调函数.</param>
        /// <param name="paramDatas">需要传递给回调函数的参数.</param>
        /// <returns>返回handler函数的返回值.</returns>
        public override object ExecuteTranscation(
			ConnManagementMode cmMode
			, ExecuteHandler handler
			, params object[] paramDatas)
        {
            var conn = (cmMode == ConnManagementMode.Auto)
                ? new SqlConnection(DbConnection.ConnectionString)
                : DbConnection as SqlConnection;

            var cmd = new SqlCommand
            {
                Connection = conn
            };
            object returnValue;
            try
            {
                if (cmMode == ConnManagementMode.Auto)
                    conn.Open();

                cmd.Transaction = conn.BeginTransaction();
                try
                {
                    returnValue = handler(cmd, paramDatas);
                    cmd.Transaction.Commit();
                }
                catch
                {
                    cmd.Transaction.Rollback();
                    throw;
                }
            }
            finally
            {
                if (cmMode == ConnManagementMode.Auto)
                    conn.Close();
            }

            return returnValue;
        }
예제 #17
0
 /// <summary>
 /// Creates a method invocation that has no arguments.
 /// </summary>
 /// <param name="target">The target of the invocation.</param>
 /// <param name="method">The method being invoked.</param>
 /// <param name="implementation">Delegate to invoke the base method implementation for virtual methods.</param>
 public static MethodInvocation Create(object target, MethodBase method, ExecuteHandler implementation) => new MethodInvocation(target, method, implementation, new ArgumentCollection());
예제 #18
0
 /// <summary>
 /// Creates a method invocation with the given typed argument value.
 /// </summary>
 /// <param name="target">The target of the invocation.</param>
 /// <param name="method">The method being invoked.</param>
 /// <param name="implementation">Delegate to invoke the base method implementation for virtual methods.</param>
 /// <param name="arg">The argument value.</param>
 public static MethodInvocation Create <T>(object target, MethodBase method, ExecuteHandler implementation, T arg)
 => new MethodInvocation(target, method, implementation, ArgumentCollection.Create(method.GetParameters(), arg));
예제 #19
0
 public DisconnectCommand()
 {
     ExecuteCommand += new ExecuteHandler(Disconnect);
 }
예제 #20
0
 /// <summary>
 /// Initializes the <see cref="MethodInvocation"/> with the given parameters.
 /// </summary>
 /// <param name="target">The target object where the invocation is being performed.</param>
 /// <param name="method">The method being invoked.</param>
 /// <param name="implementation">Delegate to invoke the method implementation.</param>
 public MethodInvocation(object target, MethodBase method, ExecuteHandler implementation)
     : this(target, method, implementation, new ArgumentCollection())
 {
 }
예제 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand{TParam}"/> class.
 /// </summary>
 /// <param name="executeAction">The logic for <see cref="DelegateCommand{TParam}.OnExecute(TParam)" />.</param>
 /// <param name="canExecutePredicate">The logic for <see cref="DelegateCommand{TParam}.CanExecute(TParam)" />.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="executeAction" /> is <see langword="null" />.
 /// </exception>
 public SimpleCommand(ExecuteHandler executeAction,
                      CanExecutePredicate canExecutePredicate)
     : base(executeAction,
            canExecutePredicate)
 {
 }
예제 #22
0
파일: Kernel.cs 프로젝트: unc0/ICSharpCore
        public void Start()
        {
            // catch CTRL+C as exit command
            Console.CancelKeyPress += (s, e) =>
            {
                e.Cancel = true;
                _exit    = true;
            };

            using (var shell = new RouterSocket(_shellAddress))
                using (var iopub = new PublisherSocket(_iopubAddress))
                    using (var poller = new NetMQPoller())
                    {
                        var iopubSender = new MessageSender(_conn.Key, iopub);
                        var shellSender = new MessageSender(_conn.Key, shell);
                        _kernelInfoHandler = new KernelInfoHandler <KernelInfoRequest>(iopubSender, shellSender);
                        _executeHandler    = new ExecuteHandler <ExecuteRequest>(iopubSender, shellSender, _loggerFactory);

                        // Handler for messages coming in to the frontend
                        shell.ReceiveReady += (s, e) =>
                        {
                            var raw    = e.Socket.ReceiveMultipartMessage();
                            var header = JsonConvert.DeserializeObject <Header>(raw[3].ConvertToString());
                            Console.WriteLine($"{header.MessageType}: [{raw.ToString()}]");

                            switch (header.MessageType)
                            {
                            case "kernel_info_request":
                            {
                                var message = new Message <KernelInfoRequest>(header, raw);
                                iopubSender.Send(message,
                                                 new Status {
                                        ExecutionState = StatusType.Busy
                                    },
                                                 MessageType.Status);
                                _kernelInfoHandler.Process(message);
                            }
                            break;

                            case "execute_request":
                            {
                                var message = new Message <ExecuteRequest>(header, raw);
                                iopubSender.Send(message,
                                                 new Status {
                                        ExecutionState = StatusType.Busy
                                    },
                                                 MessageType.Status);
                                _executeHandler.Process(message);
                            }
                            break;
                            }
                        };

                        poller.Add(shell);
                        poller.RunAsync();

                        // var heartbeat = new HeartBeat(conn);
                        Console.WriteLine($"Listening Shell {_shellAddress}");
                        Console.WriteLine($"Listening IOPub {_iopubAddress}");

                        // hit CRTL+C to stop the while loop
                        while (!_exit)
                        {
                            Thread.Sleep(100);
                        }
                    }
        }
예제 #23
0
 /// <summary>
 /// Adds a behavior to an avatar.
 /// </summary>
 /// <param name="avatar">The avatar to add the behavior to.</param>
 /// <param name="behavior">(invocation, next) => invocation.CreateValueReturn() | invocation.CreateExceptionReturn() | next().Invoke(invocation, next)</param>
 /// <param name="appliesTo">invocation => true|false</param>
 /// <param name="name">Optional friendly name for the behavior.</param>
 public static IAvatar AddBehavior(this IAvatar avatar, ExecuteHandler behavior, AppliesToHandler?appliesTo = null, string?name = null)
 {
     avatar.Behaviors.Add(new AnonymousBehavior(behavior, appliesTo, name));
     return(avatar);
 }
예제 #24
0
 /// <summary>
 /// Creates a method invocation with the given typed argument values.
 /// </summary>
 public static MethodInvocation Create <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(object target, MethodBase method, ExecuteHandler implementation, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
 => new MethodInvocation(target, method, implementation, ArgumentCollection.Create(method.GetParameters(), arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16));
 public DelegateCommand(ExecuteHandler aExecute, CanExecuteHandler aCanExecute, object aOverwriteParameter)
 {
     mExecute = aExecute;
     mCanExecute = aCanExecute;
     mOverwriteParameter = aOverwriteParameter;
 }
예제 #26
0
        /// <summary>
        /// Inserts a behavior into the avatar behavior pipeline at the specified
        /// index.
        /// </summary>
        /// <param name="avatar">The avatar to add the behavior to.</param>
        /// <param name="index">The index to insert the behavior at.</param>
        /// <param name="behavior">(invocation, next) => invocation.CreateValueReturn() | invocation.CreateExceptionReturn() | next().Invoke(invocation, next)</param>
        /// <param name="appliesTo">invocation => true|false</param>
        /// <param name="name">Optional friendly name for the behavior.</param>
        //[EditorBrowsable(EditorBrowsableState.Advanced)]
        public static TAvatar InsertBehavior <TAvatar>(this TAvatar avatar, int index, ExecuteHandler behavior, AppliesToHandler?appliesTo = null, string?name = null)
        {
            if (avatar is IAvatar target)
            {
                target.Behaviors.Insert(index, new AnonymousBehavior(behavior, appliesTo, name));
            }
            else
            {
                throw new ArgumentException(nameof(avatar));
            }

            return(avatar);
        }
예제 #27
0
 /// <summary>
 /// Executes script.
 /// </summary>
 /// <param name="index">
 /// The script index to execute.
 /// </param>
 /// <param name="handler">
 /// Delegate which is called.
 /// </param>
 /// <returns>
 /// True on success. False on failure.
 /// </returns>
 public static bool RunScript(int index, ExecuteHandler handler)
 {
     return(handler(GetScript(index)));
 }
 public DelegateCommand(ExecuteHandler aExecute, object aOverwriteParameter)
     : this(aExecute, null, aOverwriteParameter)
 {
 }
예제 #29
0
 public ShellRelayCommand(ExecuteHandler executeHandler, CanExecuteHandler canExecuteHandler)
 {
     _executeHandler = executeHandler;
     _canExecuteHanlder = canExecuteHandler;
 }
예제 #30
0
 /// <summary>
 /// Creates a method invocation with the given typed argument values.
 /// </summary>
 public static MethodInvocation Create <T1, T2, T3, T4>(object target, MethodBase method, ExecuteHandler implementation, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
 => new MethodInvocation(target, method, implementation, ArgumentCollection.Create(method.GetParameters(), arg1, arg2, arg3, arg4));
예제 #31
0
 /// <summary>
 /// Inserts a behavior into the avatar behavior pipeline at the specified
 /// index.
 /// </summary>
 /// <param name="avatar">The avatar to insert the behavior to.</param>
 /// <param name="index">The index to insert the behavior at.</param>
 /// <param name="behavior">(invocation, next) => invocation.CreateValueReturn() | invocation.CreateExceptionReturn() | next().Invoke(invocation, next)</param>
 /// <param name="appliesTo">invocation => true|false</param>
 /// <param name="name">Optional friendly name for the behavior.</param>
 public static IAvatar InsertBehavior(this IAvatar avatar, int index, ExecuteHandler behavior, AppliesToHandler?appliesTo = null, string?name = null)
 {
     avatar.Behaviors.Insert(index, new AnonymousBehavior(behavior, appliesTo, name));
     return(avatar);
 }
예제 #32
0
 /// <summary>
 /// Creates a method invocation with the given typed argument values.
 /// </summary>
 public static MethodInvocation Create <T1, T2, T3, T4, T5, T6, T7, T8>(object target, MethodBase method, ExecuteHandler implementation, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
 => new MethodInvocation(target, method, implementation, ArgumentCollection.Create(method.GetParameters(), arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8));
예제 #33
0
 public RelayCommand(ExecuteHandler execute)
     : this(execute, null)
 {
 }
예제 #34
0
 public TimerJob(IScheduledItem schedule, IMethodCall method)
 {
     Schedule        = schedule;
     Method          = method;
     _ExecuteHandler = ExecuteInternal;
 }
예제 #35
0
 public SaveSbqlFileCommand()
 {
     EnableCondition = new ConcreteCondition(false);
     ExecuteCommand += new ExecuteHandler(SaveFile);
 }
예제 #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateCommand{TParam}"/> class.
 /// </summary>
 /// <param name="executeAction">The logic for <see cref="DelegateCommand{TParam}.OnExecute(TParam)" />.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="executeAction" /> is <see langword="null" />.
 /// </exception>
 public SimpleCommand(ExecuteHandler executeAction)
     : base(executeAction)
 {
 }
예제 #37
0
 /// <summary>Stops executing the function setup by the corresponding AddListener</summary>
 /// <param name="functionToStopCalling">The local function that you've setup to receive update events</param>
 /// <param name="inputSource">The device you would like to get data from. Any if the action is not device specific.</param>
 public void RemoveOnExecuteListener(ExecuteHandler functionToStopCalling, SteamVR_Input_Sources inputSource)
 {
     sourceMap[inputSource].onExecute -= functionToStopCalling;
 }
예제 #38
0
 /// <summary>
 /// 执行一个自定义的事务处理.
 /// </summary>
 /// <param name="cmMode">连接管理模式.</param>
 /// <param name="handler">事务处理回调函数.</param>
 /// <param name="paramDatas">需要传递给回调函数的参数.</param>
 /// <returns>返回handler函数的返回值.</returns>
 public abstract object ExecuteTranscation(
     ConnManagementMode cmMode
     , ExecuteHandler handler
     , params object[] paramDatas);
예제 #39
0
 /// <summary>Executes a function when the execute method of this action (with the specified inputSource) is called. This happens when the action is bound or unbound</summary>
 /// <param name="functionToCall">A local function that receives the boolean action who's active state changes and the corresponding input source</param>
 /// <param name="inputSource">The device you would like to get data from. Any if the action is not device specific.</param>
 public void AddOnExecuteListener(ExecuteHandler functionToCall, SteamVR_Input_Sources inputSource)
 {
     sourceMap[inputSource].onExecute += functionToCall;
 }
예제 #40
-1
파일: TimerJob.cs 프로젝트: ruslanlyalko/DA
 public TimerJob(IScheduledItem schedule, IMethodCall method, string proFileName)
 {
     Schedule = schedule;
     Method = method;
     _ExecuteHandler = new ExecuteHandler(ExecuteInternal);
        ProfileName = proFileName;
 }
예제 #41
-1
 public TimerJob(IScheduledItem schedule, IMethodCall method)
 {
     Schedule = schedule;
     Method = method;
     _ExecuteHandler = ExecuteInternal;
 }