示例#1
0
 public TextCommand(
     CanExecuteCallback canExecute,
     ExecuteCallback execute)
 {
     this.CanExecute = canExecute;
     this.Execute    = execute;
 }
示例#2
0
        /// <summary>
        ///     Adds component command builder to <see cref="ComponentCommands"/>.
        /// </summary>
        /// <param name="name">Name of the command.</param>
        /// <param name="callback">Command callback to be executed.</param>
        /// <param name="configure"><see cref="ComponentCommandBuilder"/> factory.</param>
        /// <returns>
        ///     The builder instance.
        /// </returns>
        public ModuleBuilder AddComponentCommand(string name, ExecuteCallback callback, Action <ComponentCommandBuilder> configure)
        {
            var command = new ComponentCommandBuilder(this, name, callback);

            configure(command);
            _componentCommands.Add(command);
            return(this);
        }
示例#3
0
        /// <summary>
        ///     Adds autocomplete command builder to <see cref="AutocompleteCommands"/>.
        /// </summary>
        /// <param name="name">Name of the command.</param>
        /// <param name="callback">Command callback to be executed.</param>
        /// <param name="configure"><see cref="AutocompleteCommandBuilder"/> factory.</param>
        /// <returns>
        ///     The builder instance.
        /// </returns>
        public ModuleBuilder AddSlashCommand(string name, ExecuteCallback callback, Action <AutocompleteCommandBuilder> configure)
        {
            var command = new AutocompleteCommandBuilder(this, name, callback);

            configure(command);
            _autocompleteCommands.Add(command);
            return(this);
        }
 public CommandRegistrationBuilder Add <TBag>([NotNull] Identifier id, [NotNull] ExecuteCallback <TBag> execute) where TBag : ICommandParameter, new()
 {
     return(Add <Lambda <TBag> >(r =>
     {
         r.Id = id;
         r.Execute = execute;
     }));
 }
示例#5
0
        public void DropViewModel(string key)
        {
            CommandQueue.Enqueue(new DeleteCachCommand {
                Key = key
            });
            ExecuteCallback pollCallback = ExecuteCommands;

            pollCallback.BeginInvoke(null, null);
        }
示例#6
0
        public void DropViewModelByModel(Guid modelId)
        {
            CommandQueue.Enqueue(new DeleteCachByModelCommand {
                ModelId = modelId
            });
            ExecuteCallback pollCallback = ExecuteCommands;

            pollCallback.BeginInvoke(null, null);
        }
示例#7
0
        public void AddNewViewModel(ICachedViewModel startModel)
        {
            CommandQueue.Enqueue(new AddCachCommand {
                ViewModel = startModel
            });
            ExecuteCallback pollCallback = ExecuteCommands;

            pollCallback.BeginInvoke(null, null);
        }
示例#8
0
        public virtual void ExecuteTableAsync(IDbCommand command, ExecuteCallback <DataTable> callback, object state)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            AsyncExecuteState <DataTable> internalState = new AsyncExecuteState <DataTable> (command, callback, state);

            ThreadPool.QueueUserWorkItem(new WaitCallback(ExecuteTableThreaded), internalState);
        }
示例#9
0
        internal CommandInfo(Builders.ICommandBuilder builder, ModuleInfo module, InteractionService commandService)
        {
            CommandService = commandService;
            Module         = module;

            Name             = builder.Name;
            MethodName       = builder.MethodName;
            IgnoreGroupNames = builder.IgnoreGroupNames;
            RunMode          = builder.RunMode != RunMode.Default ? builder.RunMode : commandService._runMode;
            Attributes       = builder.Attributes.ToImmutableArray();
            Preconditions    = builder.Preconditions.ToImmutableArray();

            _action = builder.Callback;
            _groupedPreconditions = builder.Preconditions.ToLookup(x => x.Group, x => x, StringComparer.Ordinal);
        }
 public ReadEvalPrintLoop(AutoCompleteCallback autoCompleteCallback,
                          ExecuteCallback executeCallback,
                          string prompt      = "$>",
                          string historyFile = null)
 {
     AutoCompleteHook = autoCompleteCallback;
     ExecuteHook      = executeCallback;
     Prompt           = prompt;
     if (historyFile != null)
     {
         History = File.ReadAllText(historyFile)
                   .Split(Environment.NewLine)
                   .ToList();
     }
 }
示例#11
0
        public void ShowProgressBar(ExecuteCallback callback)
        {
            this._executeCallback    = callback;
            this.progressBar.Maximum = 50;
            this.btnCancel.Enabled   = false;

            this._timer          = new System.Windows.Forms.Timer();
            this._timer.Interval = 100;
            this._timer.Tick    += new EventHandler(timer_Tick);

            this._thread      = new Thread(ExecuteOnce);
            this._thread.Name = "ProgressForm ExecuteOnce Thread";

            this.ShowDialog();
            this.CloseThread();
        }
示例#12
0
        public void ClearOldCach()
        {
            var oldDate = DateTime.Now.AddHours(-6);
            var item    = Cach.SingleOrDefault(x => x.Value.CachLastAccess <= oldDate);

            while (item.Key != null)
            {
                CommandQueue.Enqueue(new DeleteCachCommand {
                    Key = item.Key
                });
                item = Cach.SingleOrDefault(x => x.Value.CachLastAccess <= oldDate);
            }

            ExecuteCallback pollCallback = ExecuteCommands;

            pollCallback.BeginInvoke(null, null);
        }
示例#13
0
文件: Core.cs 项目: jdruin/F5Eagle
        ////////////////////////////////////////////////////////////////////////

        #region IExecute Members
        public override ReturnCode Execute(
            Interpreter interpreter,
            IClientData clientData,
            ArgumentList arguments,
            ref Result result
            )
        {
            ExecuteCallback callback = this.Callback;

            if (callback != null)
            {
                return(callback(interpreter, clientData, arguments, ref result));
            }
            else
            {
                return(ReturnCode.Error);
            }
        }
示例#14
0
    public VoxelQuery(Vector3 position, int width, int height, int depth, bool[] mask, ExecuteCallback executeCallback)
    {
        if (width < 1 || height < 1 || depth < 1) {
            throw new Exception ("width < 1 || height < 1 || depth < 1");
        }

        int size = width * height * depth;
        if (mask.Length != size) {
            throw new Exception ("mask.Length != size");
        }

        if (executeCallback == null) {
            throw new Exception ("executeCallback == null");
        }

        _position = position;
        _width = width;
        _height = height;
        _depth = depth;
        _mask = mask;
        _executeCallback = executeCallback;
    }
示例#15
0
 public CLIBase(ExecuteCallback cb)
 {
     Callback = cb;
 }
示例#16
0
 protected CommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback) : this(module)
 {
     Name     = name;
     Callback = callback;
 }
示例#17
0
 /// <summary>
 ///     Initializes a new <see cref="ComponentBuilder"/>.
 /// </summary>
 /// <param name="module">Parent module of this command.</param>
 /// <param name="name">Name of this command.</param>
 /// <param name="callback">Execution callback of this command.</param>
 public ComponentCommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback)
 {
 }
 public virtual void Execute(ExecuteCallback callback)
 {
     this.callback = callback;
     Context.ClientPage.Start(this, "Pipeline");
 }
示例#19
0
文件: Lambda.cs 项目: he-dev/reusable
 public Lambda(CommandServiceProvider <Lambda <TBag> > serviceProvider, [NotNull] Identifier id, [NotNull] ExecuteCallback <TBag> execute)
     : base(serviceProvider, id)
 {
     _execute = execute ?? throw new ArgumentNullException(nameof(execute));
 }
示例#20
0
 public VoxelQuery(int width, int height, int depth, bool[] mask, ExecuteCallback executeCallback)
     : this(Vector3.zero, width, height, depth, mask, executeCallback)
 {
 }
 public CreateItem(ExecuteCallback callback)
 {
     this.callback = callback;
 }
 /// <summary>
 ///     Initializes a new <see cref="AutocompleteCommandBuilder"/>.
 /// </summary>
 /// <param name="module">Parent module of this command.</param>
 /// <param name="name">Name of this command.</param>
 /// <param name="callback">Execution callback of this command.</param>
 public AutocompleteCommandBuilder(ModuleBuilder module, string name, ExecuteCallback callback) : base(module, name, callback)
 {
 }
示例#23
0
 public RelayCommand(ExecuteCallback execute, CanExecuteCallback canExecute)
 {
     this._execute    = execute;
     this._canExecute = canExecute;
 }
示例#24
0
 ///
 ///	 * <param name="_callback"> the ExecuteCallback to set </param>
 ///
 public virtual void setExecuteCallback(ExecuteCallback _callback)
 {
     this.executeCallback = _callback;
 }
示例#25
0
 public RelayCommand(ExecuteCallback execute) : this(execute, RelayCommand.CanExecuteDefault)
 {
 }
示例#26
0
 public RelayCommand(ExecuteCallback execute, CanExecuteCallback canExecute)
 {
     this._execute = execute;
     this._canExecute = canExecute;
 }
示例#27
0
        public void ShowProgressBar(ExecuteCallback callback)
        {
            this._executeCallback = callback;
            this.progressBar.Maximum = 50;
            this.btnCancel.Enabled = false;

            this._timer = new System.Windows.Forms.Timer ();
            this._timer.Interval = 100;
            this._timer.Tick += new EventHandler (timer_Tick);

            this._thread = new Thread (ExecuteOnce);
            this._thread.Name = "ProgressForm ExecuteOnce Thread";

            this.ShowDialog ();
            this.CloseThread ();
        }
示例#28
0
 public RelayCommand(ExecuteCallback execute)
     : this(execute, RelayCommand.CanExecuteDefault)
 {
 }
示例#29
0
 public AsyncExecuteState(IDbCommand command, ExecuteCallback <T> callback, object state)
 {
     Command  = command;
     Callback = callback;
     State    = state;
 }
示例#30
0
 public CallbackAction(String name, ExecuteCallback execute = null)
     : base(name)
 {
     this.executeCallback = execute;
 }
        public static IEnumerable ExecuteQuery(DataServiceContext context, DataServiceRequest query, QueryMode queryMode)
        {
            bool isQuery = (null != (query as DataServiceQuery));

            object result = null;

            switch (queryMode)
            {
            case QueryMode.GetEnumerator:     // IEnumerable.GetEnumerator
            {
                if (isQuery)
                {
                    result = query;
                }
                else
                {
                    goto case QueryMode.ExecuteMethod;
                }
                break;
            }

            case QueryMode.ExecuteMethod:     // DataServiceQuery<T>.Execute
            {
                if (isQuery)
                {
                    result = UnitTestCodeGen.InvokeMethod(query.GetType(), "Execute", null, null, query, null);
                }
                else
                {
                    result = UnitTestCodeGen.InvokeMethod(typeof(DataServiceContext), "Execute", TypesUri, new Type[] { query.ElementType }, context, query.RequestUri);
                }

                break;
            }

            case QueryMode.AsyncExecute:     // DataServiceQuery<T>.BeginExecute and wait
            {
                if (isQuery)
                {
                    IAsyncResult async = (IAsyncResult)UnitTestCodeGen.InvokeMethod(query.GetType(), "BeginExecute", TypesAsyncCallbackObject, null, query, new object[] { null, null });
                    if (!async.CompletedSynchronously)
                    {
                        Assert.IsTrue(async.AsyncWaitHandle.WaitOne(new TimeSpan(0, 0, TestConstants.MaxTestTimeout), false), "BeginExecute timeout");
                    }

                    result = UnitTestCodeGen.InvokeMethod(query.GetType(), "EndExecute", TypesIAsyncResult, null, query, new object[] { async });
                }
                else
                {
                    IAsyncResult async = UnitTestCodeGen.InvokeMethod <DataServiceContext, IAsyncResult>("BeginExecute", TypesUriAsyncCallbackObject, new Type[] { query.ElementType }, context, query.RequestUri, null, null);
                    if (!async.CompletedSynchronously)
                    {
                        Assert.IsTrue(async.AsyncWaitHandle.WaitOne(new TimeSpan(0, 0, TestConstants.MaxTestTimeout), false), "BeginExecute timeout");
                    }

                    result = UnitTestCodeGen.InvokeMethod(typeof(DataServiceContext), "EndExecute", TypesIAsyncResult, new Type[] { query.ElementType }, context, async);
                }

                break;
            }

            case QueryMode.AsyncExecuteWithCallback:     // DataServiceQuery<T>.BeginExecute with callback
            {
                ExecuteCallback callback = new ExecuteCallback();
                IAsyncResult    async;
                if (isQuery)
                {
                    async = (IAsyncResult)UnitTestCodeGen.InvokeMethod(query.GetType(), "BeginExecute", TypesAsyncCallbackObject, null, query, new object[] { (AsyncCallback)callback.CallbackMethod, new object[] { query, context } });
                }
                else
                {
                    async = UnitTestCodeGen.InvokeMethod <DataServiceContext, IAsyncResult>("BeginExecute", TypesUriAsyncCallbackObject, new Type[] { query.ElementType }, context, new object[] { query.RequestUri, (AsyncCallback)callback.CallbackMethod, new object[] { query, context } });
                }

                Assert.IsTrue(callback.Finished.WaitOne(new TimeSpan(0, 0, TestConstants.MaxTestTimeout), false), "Asyncallback timeout");
                Assert.IsTrue(async.IsCompleted);

                if (null != callback.CallbackFailure)
                {
                    Assert.IsNull(callback.CallbackResult, callback.CallbackFailure.ToString());
                    throw new Exception("failure in callback", callback.CallbackFailure);
                }

                result = callback.CallbackResult;
                Assert.IsNotNull(result);
                break;
            }

            case QueryMode.BatchExecute:     // DataServiceContext.ExecuteBatch
            {
                LastUriRequest = query.RequestUri;
                int countBefore = context.Entities.Count + context.Links.Count;
                DataServiceResponse response = context.ExecuteBatch(query);
                int countAfter = context.Entities.Count + context.Links.Count;
                Assert.AreEqual(countBefore, countAfter, "should not materialize during ExecuteBatch");
                result = HandleQueryResponse(response, query, context);
            }
            break;

            case QueryMode.BatchAsyncExecute:     // DataServiceContext.BeginExecuteBatch and wait
            {
                int count = context.Entities.Count + context.Links.Count;
                LastUriRequest = query.RequestUri;
                IAsyncResult async = context.BeginExecuteBatch(null, null, query);
                if (!async.CompletedSynchronously)
                {
                    Assert.IsTrue(async.AsyncWaitHandle.WaitOne(new TimeSpan(0, 0, TestConstants.MaxTestTimeout), false), "BeginExecuteBatch timeout");
                }

                Assert.AreEqual(count, context.Entities.Count + context.Links.Count, "should not materialize until EndExecuteBatch");
                DataServiceResponse response = context.EndExecuteBatch(async);
                result = HandleQueryResponse(response, query, context);
                break;
            }

            case QueryMode.BatchAsyncExecuteWithCallback:     // DataServiceContext.BeginExecuteBatch with callback
            {
                ExecuteBatchCallback callback = new ExecuteBatchCallback();
                LastUriRequest = query.RequestUri;
                IAsyncResult async = context.BeginExecuteBatch(callback.CallbackMethod, new object[] { query, context }, query);

                Assert.IsTrue(callback.Finished.WaitOne(new TimeSpan(0, 0, TestConstants.MaxTestTimeout), false), "Asyncallback timeout {0}", LastUriRequest);
                Assert.IsTrue(async.IsCompleted);

                if (null != callback.CallbackFailure)
                {
                    Assert.IsNull(callback.CallbackResult, callback.CallbackFailure.ToString());
                    throw new Exception("failure in callback", callback.CallbackFailure);
                }

                result = callback.CallbackResult;
                Assert.IsNotNull(result);
                break;
            }

            default:
                Assert.Fail("shouldn't be here");
                break;
            }

            return((IEnumerable)result);
        }
示例#32
0
        private static void Fire <DelegateType>(this Subscriptions collection, Type dataType, ExecuteCallback <DelegateType> runner) where DelegateType : class
        {
            Verify.ArgumentNotNull(collection, "collection");
            Verify.ArgumentNotNull(dataType, "dataType");
            Verify.ArgumentNotNull(runner, "runner");

            if (SuppressEventScope.IsEnabled)
            {
                return;
            }

            List <Type> types = GetTypesToFire(dataType);

            foreach (Type type in types)
            {
                Pair <Delegate, bool>[] subscriptions = null;

                if (collection.ContainsKey(type))
                {
                    lock (_collectionAccesslock)
                    {
                        if (collection.ContainsKey(type))
                        {
                            subscriptions = collection[type].ToArray();
                        }
                    }
                }

                if (subscriptions == null)
                {
                    continue;
                }

                foreach (Pair <Delegate, bool> subscription in subscriptions)
                {
                    var callback = subscription.First as DelegateType;
                    Verify.That(callback != null, "Wrong delegate type");

                    runner(callback);
                }
            }
        }
 //2
 public BotCommand(ExecuteCallback executeMethod, string name)
 {
     Execute     = executeMethod;
     commandName = name;
 }
 public static void YesNoCancelMessage(string message, string width, string height, ExecuteCallback callback)
 {
     new YesNoCancelMessage(message, width, height).Execute(callback);
 }