Esempio n. 1
0
        /// <summary>
        /// Wywołuje wykonanie akcji
        /// </summary>
        /// <param name="requestData">Dane wejściowe</param>
        /// <returns>Odpowiedź od akcji</returns>
        public JObject Invoke(ClientConnection conn, JObject requestData)
        {
            BaseSerializer requestSerializer = (BaseSerializer)Activator.CreateInstance(RequestSerializerType);

            requestSerializer.SetData(requestData);
            requestSerializer.Validate();

            // Wywołanie wydarzenia
            var argsInvk = new ActionInvokeEventArgs()
            {
                RequestData = requestSerializer
            };

            InvokedThis?.Invoke(this, argsInvk);
            Invoked?.Invoke(this, argsInvk);

            // Główna metoda wykonująca akcję
            BaseSerializer responseSerializer = PerformAction(conn, requestSerializer);

            // Wywołanie wydarzenia
            var argsFnshd = new ActionFinishEventArgs()
            {
                RequestData  = requestSerializer,
                ResponseData = responseSerializer
            };

            FinishedThis?.Invoke(this, argsFnshd);
            Finished?.Invoke(this, argsFnshd);

            // Zwrócenie odpowiedzi
            return(responseSerializer.GetApiObject());
        }
Esempio n. 2
0
        public void Invoke()
        {
            command.Invoke(parameters);
            lastStart = DateTime.Now;

            Invoked?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 3
0
 void TrayIcon_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         Invoked.Invoke();
     }
 }
Esempio n. 4
0
 public virtual object Validate(ParseInfo parseInfo, IExpression value, DocRange valueRange, object additionalData)
 {
     // If the type of the parameter is a lambda, then resolve the expression.
     if (_type is PortableLambdaType lambdaType && lambdaType.LambdaKind == LambdaKind.Constant)
     {
         ConstantExpressionResolver.Resolve(value, expr =>
         {
             // If the expression is a lambda...
             if (expr is Lambda.LambdaAction lambda)
             {
                 // ...then if this parameter is invoked, apply the restricted calls and recursion info.
                 Invoked.OnInvoke(() =>
                 {
                     LambdaInvoke.LambdaInvokeApply(parseInfo, lambda, valueRange);
                 });
             }
             // Otherwise, if the expression resolves to an IBridgeInvocable...
             else if (LambdaInvoke.ParameterInvocableBridge(value, out IBridgeInvocable invocable))
             {
                 // ...then this lambda parameter is invoked, invoke the resolved invocable.
                 Invoked.OnInvoke(() => invocable.WasInvoked());
             }
         });
     }
     return(null);
 }
 private void IgnoreFocusKeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs e)
 {
     if (FocusManager.GetFocusedElement().GetType() != typeof(TextBox))
     {
         Invoked?.Invoke(sender, e);
     }
 }
        private bool OnInvoked()
        {
            var args = new GooeyButtonInvokedEventArgs();

            Invoked.Invoke(this, args);
            return(args.Cancel);
        }
Esempio n. 7
0
 public void Invoke(Gwen.Control.ControlBase sender, IDictionary parameters)
 {
     Invoked?.Invoke(sender, new LuaEventArgs()
     {
         Parameters = parameters
     });
 }
Esempio n. 8
0
        public void AbstractClassWithBasicProperty()
        {
            var testScript = LoadAssembly <AAbstractClassWithBasicProperty>();
            var context    = testScript.Context;
            var mock       = testScript.MockObject;

            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 5678));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet));

            context.Arrange(f => f.OnlyGet).Returns(1234);
            Assert.Equal(1234, mock.OnlyGet);

            context.ArrangeProperty(f => f.GetAndSet);
            mock.GetAndSet = 5678;
            Assert.Equal(5678, mock.GetAndSet);
            context.AssertSet_When(f => f.GetAndSet = 5678);
            context.AssertGet(f => f.GetAndSet);

            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 1234));

            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 5678, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet, Invoked.Never));

            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet, Invoked.Exactly(2)));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 5678, Invoked.Exactly(2)));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet, Invoked.Exactly(2)));

            Assert.Equal(KExpected, testScript.DoRun());
        }
Esempio n. 9
0
        public void GenericAbstractClass()
        {
            var testScript = LoadAssembly <AGenericAbstractClass <int> >();
            var context    = testScript.Context;
            var mock       = testScript.MockObject;

            mock.DoSomething(1234);
            context.Assert(f => f.DoSomething(1234));

            context.Arrange(f => f.GetSomething()).Returns(5678);
            Assert.Equal(5678, mock.GetSomething());

            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet));
            context.Arrange(f => f.OnlyGet).Returns(9012);
            Assert.Equal(9012, mock.OnlyGet);
            context.AssertGet(f => f.OnlyGet);
            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet, Invoked.Exactly(2)));

            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 3456));
            context.ArrangeProperty(f => f.GetAndSet);
            mock.GetAndSet = 3456;
            Assert.Equal(3456, mock.GetAndSet);
            context.AssertGet(f => f.GetAndSet);
            context.AssertSet_When(f => f.GetAndSet = 3456);
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 1234));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 3456, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet, Invoked.Exactly(2)));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 3456, Invoked.Exactly(2)));

            Assert.Equal(KExpected, testScript.DoRun());
        }
Esempio n. 10
0
        public virtual CfrV8Value Invoke(CfrV8HandlerExecuteEventArgs args, JsBinding binding, HtmlTextureWrapper wrapper)
        {
            var res = Function(args, binding, wrapper);

            Invoked?.Invoke(this, wrapper);
            InvokeCount++;
            return(res);
        }
Esempio n. 11
0
 public void AssertSet(Action <T> expression, Invoked times, [CallerFilePath] string uidPart1 = "", [CallerLineNumber] int uidPart2 = 0)
 {
     if (string.IsNullOrWhiteSpace(uidPart1))
     {
         throw new ArgumentException(KUidExceptionMessage, nameof(uidPart1));
     }
     propertiesContext.AssertInternal(exchangeForExpression(uidPart2 + uidPart1), times);
 }
Esempio n. 12
0
        private void OnTick(object sender, object e)
        {
            _timer.Stop();

            Invoked?.Invoke(_lastSender, _lastArgs);

            _lastSender = null;
            _lastArgs   = default;
        }
Esempio n. 13
0
        public void OnInvoked()
        {
            if (Command != null && Command.CanExecute(CommandParameter))
            {
                Command.Execute(CommandParameter);
            }

            Invoked?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 14
0
        public void Assert_ExpectedExactly3TimesAnd2TimesInvoked_ThrowsException()
        {
            var mockContext = new MockContext <IFoo>();
            var fooMock     = new FooMock(mockContext);

            fooMock.Execute("SomeValue");
            fooMock.Execute("SomeValue");
            mockContext.Assert(f => f.Execute("SomeValue"), Invoked.Exactly(3));
        }
Esempio n. 15
0
 public static void Cleanup()
 {
     if (Invoked != null)
     {
         foreach (Delegate d in Invoked.GetInvocationList())
         {
             Invoked -= (EventHandler <DotNetifyHubContext>)d;
         }
     }
 }
Esempio n. 16
0
        object[] GetAssertArgs(Invoked invoked)
        {
            const int offset = 2;
            var       args   = new object[@params.Length + offset];

            args[0] = propertiesContext;
            args[1] = invoked;
            Array.Copy(@params, 0, args, offset, @params.Length);
            return(args);
        }
Esempio n. 17
0
        void Maui.ISwipeItem.OnInvoked()
        {
            if (Command != null && Command.CanExecute(CommandParameter))
            {
                Command.Execute(CommandParameter);
            }

            OnClicked();
            Invoked?.Invoke(this, EventArgs.Empty);
        }
        public void Assert_ExpectedAtLeast3TimesAnd3TimesInvoked_IsVerified()
        {
            var mockContext = new MockContext <IFoo>();
            var fooMock     = new FooMock(mockContext);

            fooMock.Execute("SomeValue");
            fooMock.Execute("SomeValue");
            fooMock.Execute("SomeValue");
            mockContext.Assert(f => f.Execute("SomeValue"), Invoked.AtLeast(3));
        }
Esempio n. 19
0
 public static void Cleanup()
 {
     if (Invoked != null)
     {
         foreach (Delegate d in Invoked.GetInvocationList())
         {
             Invoked -= (EventHandler <Tuple <CustomFilter2Attribute, VMContext> >)d;
         }
     }
 }
Esempio n. 20
0
 public static void OnInvoked(ApiInvokedArgs args)
 {
     try
     {
         Invoked?.Invoke(null, args);
     }
     catch (Exception ex)
     {
         throw new ApiInvocationException("Handling Api Invoked event failed.", ex);
     }
 }
Esempio n. 21
0
 protected virtual Task OnInvokedAsync(
     Message message,
     CancellationToken?cancellationToken = default)
 {
     return(Invoked.PassiveInvokeAsync(
                this,
                new MessageInvokedAsyncEventArgs(message, cancellationToken: cancellationToken),
                onFailure: failure => OnDiagnosticsEmittedAsync(
                    Level.Warning,
                    cancellationToken: cancellationToken,
                    cause: failure,
                    message: BusOnInvokedAsyncFailure)));
 }
Esempio n. 22
0
        public Task <bool> Invoke(string code = "", string install = "")
        {
            var args = new OAuthAcceptanceEventArgs()
            {
                Code    = code,
                Install = install
            };

            Invoked?.Invoke(this, args);


            return(Task.FromResult(true));
        }
Esempio n. 23
0
            public Task Invoke(CustomFilter2Attribute attribute, VMContext context, NextFilterDelegate next)
            {
                if (context.HubContext.CallType == "Response_VM")
                {
                    var data = JsonConvert.DeserializeObject <IDictionary <string, object> >(context.HubContext.Data.ToString());
                    foreach (var key in data.Keys.ToList())
                    {
                        data[key] = data[key].ToString().ToUpper();
                    }
                    context.HubContext.Data = JsonConvert.SerializeObject(data);
                }

                Invoked?.Invoke(this, Tuple.Create(attribute, context));
                return(next.Invoke(context));
            }
Esempio n. 24
0
 void TrayIcon_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         Invoked.Invoke();
     }
     else if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         var cm = BuildContextMenu(true);
         cm.Placement = PlacementMode.Mouse;
         cm.IsOpen    = true;
     }
     else if (e.Button == System.Windows.Forms.MouseButtons.Middle)
     {
     }
 }
Esempio n. 25
0
        public override void Handle(HandleContext context)
        {
            var packet  = context.Packet;
            var session = context.Session;

            var response = packet as IResponse;

            if (response != null)
            {
                Console.WriteLine("调用回复");

                Invoked?.Invoke(response);
            }

            var e = packet as EventInfo;

            if (e != null)
            {
                Console.WriteLine("事件");

                Raised?.Invoke(e);
            }
        }
Esempio n. 26
0
        public void GenericMockAndGenericInterface()
        {
            const string resource   = "GenericMockAndGenericInterface";
            const string className  = resource + "`1";
            var          testScript = LoadAssembly <IGenericMockAndGenericInterface <int> >(resource, className);
            var          context    = testScript.Context;
            var          mock       = testScript.MockObject;

            mock.DoSomething(1234);
            context.Assert(f => f.DoSomething(1234));

            context.Arrange(f => f.GetSomething()).Returns(5678);
            Assert.Equal(5678, mock.GetSomething());

            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet));
            context.Arrange(f => f.OnlyGet).Returns(9012);
            Assert.Equal(9012, mock.OnlyGet);
            context.AssertGet(f => f.OnlyGet);
            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.OnlyGet, Invoked.Exactly(2)));

            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 3456));
            context.ArrangeProperty(f => f.GetAndSet);
            mock.GetAndSet = 3456;
            Assert.Equal(3456, mock.GetAndSet);
            context.AssertGet(f => f.GetAndSet);
            context.AssertSet_When(f => f.GetAndSet = 3456);
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 1234));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 3456, Invoked.Never));
            Assert.Throws <MockException>(() => context.AssertGet(f => f.GetAndSet, Invoked.Exactly(2)));
            Assert.Throws <MockException>(() => context.AssertSet_When(f => f.GetAndSet = 3456, Invoked.Exactly(2)));

            Assert.Equal(KExpected, testScript.DoRun());
        }
Esempio n. 27
0
        public async Task <ExecutionContext> InvokeAsync <TResult>(AbstractRequestContext requestContext)
        {
            Stopwatch stopwatch        = null;
            Guid      operationId      = Guid.Empty;
            var       executionContext = new ExecutionContext
            {
                Request        = requestContext,
                SmartSqlConfig = SmartSqlConfig,
                DbSession      = this,
            };

            try
            {
                if (_logger.IsEnabled(LogLevel.Debug))
                {
                    stopwatch = Stopwatch.StartNew();
                }
                operationId = _diagnosticListener.WriteDbSessionInvokeBefore(executionContext);
                #region Impl
                switch (executionContext.Type)
                {
                case ExecutionType.Execute:
                case ExecutionType.ExecuteScalar:
                case ExecutionType.QuerySingle:
                case ExecutionType.GetDataSet:
                case ExecutionType.GetDataTable:
                {
                    executionContext.Result = new SingleResultContext <TResult>();
                    break;
                }

                case ExecutionType.Query:
                {
                    executionContext.Result = new ListResultContext <TResult>();
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException();
                }
                requestContext.ExecutionContext = executionContext;
                await Pipeline.InvokeAsync <TResult>(executionContext);

                Invoked?.Invoke(this, new DbSessionInvokedEventArgs {
                    ExecutionContext = executionContext
                });
                #endregion
                _diagnosticListener.WriteDbSessionInvokeAfter(operationId, executionContext);
                return(executionContext);
            }
            catch (Exception ex)
            {
                _diagnosticListener.WriteDbSessionInvokeError(operationId, executionContext, ex);
                throw;
            }
            finally
            {
                if (_logger.IsEnabled(LogLevel.Debug))
                {
                    _logger.LogDebug(
                        $"Statement.Id:{requestContext.FullSqlId} Invoke Taken:{stopwatch?.ElapsedMilliseconds}.");
                }
            }
        }
Esempio n. 28
0
 public Task Invoke(CustomFilter1Attribute attribute, VMContext context, NextFilterDelegate next)
 {
     Invoked?.Invoke(this, Tuple.Create(attribute, context));
     return(next.Invoke(context));
 }
Esempio n. 29
0
			public InvocatingInterceptor(Invoked invoked)
			{
				this.invoked = invoked;
			}
        public void Assert_ExpectedAtLeast3TimesAnd2TimesInvoked_ThrowsException()
        {
            var mockContext = new MockContext <IFoo>();
            var fooMock     = new FooMock(mockContext);

            fooMock.Execute("SomeValue");
            fooMock.Execute("SomeValue");
            Assert.Throws <MockException>(() => mockContext.Assert(f => f.Execute("SomeValue"), Invoked.AtLeast(3)));
        }
Esempio n. 31
0
 /// <summary>
 /// Raises the <see cref="E:Invoked"/> event.
 /// </summary>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void OnInvoked(RoutedEventArgs e)
 {
     Invoked?.Invoke(this, e);
 }