public void Create_IfMultipleOutputParameters_SetsOutputArguments(bool isInstance) { // Arrange MethodInfo method = GetMethodInfo(isInstance, "TestOutIntStringObjectArray"); int expectedA = 1; string expectedB = "B"; object[] expectedC = new object[] { new object() }; // Act IMethodInvoker <MethodInvokerFactoryTests> invoker = MethodInvokerFactory.Create <MethodInvokerFactoryTests>(method); // Assert Assert.NotNull(invoker); bool callbackCalled = false; OutAction callback = delegate(out int a, out string b, out object[] c) { callbackCalled = true; a = expectedA; b = expectedB; c = expectedC; }; MethodInvokerFactoryTests instance = GetInstance(isInstance); object[] arguments = new object[] { default(int), null, null, callback }; invoker.InvokeAsync(instance, arguments).GetAwaiter().GetResult(); Assert.True(callbackCalled); Assert.Equal(expectedA, arguments[0]); Assert.Same(expectedB, arguments[1]); Assert.Same(expectedC, arguments[2]); }
void OutAction(out Action action, string locality) { Expression exp = null; action = new OutAction(); action.Locality = locality; Expect(17); Expect(14); OutParam(out exp); action.AddExpression(exp); while (la.kind == 8) { Get(); OutParam(out exp); action.AddExpression(exp); } Expect(15); Expect(18); if (la.kind == 1) { Get(); action.At = new PLRString(t.val); } else if (la.kind == 2) { Get(); action.At = new Variable(t.val); } else { SynErr(29); } }
IEnumerator Closed() { yield return(new WaitForSeconds(DisappearTime)); animator.SetInteger("state", (int)UIDisplayState.Disable); OutAction.OnCompleteMethod(); }
public ImageFetcher(FetcherOptions Options, OutAction <string, int, List <string> > Parse = null, OutAction <string, int> PageParser = null) { this.Options = Options; this.Parse = Parse; this.PageParser = PageParser; }
/// <summary> /// Registers all needed actions /// </summary> /// <param name="getFromDatabaseById"></param> /// <param name="getFromDatabase"> </param> /// <param name="getByIdFromList"> </param> public void RegisterActions( OutAction <object, ResolveFieldContext <object>, T> getFromDatabaseById, OutAction <ResolveFieldContext <object>, List <T> > getFromDatabase, OutAction <List <T>, object, T> getByIdFromList) { this.GetFromDatabaseById = getFromDatabaseById; this.GetFromDatabase = getFromDatabase; this.GetByIdFromList = getByIdFromList; }
static void Main(string[] args) { OutAction <int, int> action = OutFunc; int a = 3, b = 5; Console.WriteLine("{0}/{1}", a, b); OutFunc(out a, out b); Console.WriteLine("{0}/{1}", a, b); Console.ReadKey(); }
private void animatorOut() { OutAction.OnStartMethod(); if (animator != null) { animator.speed = 1f / DisappearTime; animator.Play(k_ClosedStateName); StartCoroutine(Closed(animator)); } }
public override void Visit(OutAction act) { List <string> children = PopChildren(); string text = act.Name; if (children.Count > 0) { text += "(" + Join(", ", children) + ")"; } Return(@"\overline{" + text + "}"); }
public override void Visit(OutAction act) { List <string> children = PopChildren(); string text = act.Name; if (children.Count > 0) { text += "(" + Join(", ", children) + ")"; } Return("<span style=\"text-decoration:overline;\">" + text + "</span>"); }
private void noAnimationOut() { if (OutAction.OnStartMethod != null) { OutAction.OnStartMethod(); } if (OutAction.OnCompleteMethod != null) { OutAction.OnCompleteMethod(); } }
private void Map(OutAction <int> action) { for (int x = 0; x < this.width; x++) { for (int y = 0; y < this.height; y++) { for (int z = 0; z < this.depth; z++) { action(ref this.nodes[GetIndex(x, y, z)]); } } } }
public override void Visit(OutAction act) { List <string> children = PopChildren(); if (children.Count == 0) { Return("_" + act.Name + "_"); } else { Return("_" + act.Name + "_(" + Join(", ", children) + ")"); } }
void Action(out Action act) { act = null; Expression exp = null; Variable v = null; if (la.kind == 3) { Get(); InAction inAct = new InAction(t.val); if (la.kind == 10) { Get(); Expect(3); v = new Variable(t.val); SetPos(v, t); inAct.AddVariable(v); while (la.kind == 11) { Get(); Expect(3); v = new Variable(t.val); SetPos(v, t); inAct.AddVariable(v); } Expect(12); } act = inAct; } else if (la.kind == 5) { Get(); OutAction outAct = new OutAction(t.val); if (la.kind == 10) { Get(); ArithmeticExpression(out exp); outAct.AddExpression(exp); while (la.kind == 11) { Get(); ArithmeticExpression(out exp); outAct.AddExpression(exp); } Expect(12); } act = outAct; } else if (la.kind == 6) { MethodCall(out exp, true); act = new Call((MethodCallExpression)exp); } else { SynErr(43); } }
private void animatorOut() { OutAction.OnStartMethod(); if (animator != null) { animator.speed = 1f / DisappearTime; animator.SetInteger("state", (int)UIDisplayState.Showouting); DelayAction delay = new DelayAction(AppearTime, null, () => { animator.SetInteger("state", (int)UIDisplayState.Disable); OutAction.OnCompleteMethod(); }); delay.Play(); // StartCoroutine (Closed ()); } }
IEnumerator Closed(Animator anim) { if (anim != null) { bool closedStateReached = anim.GetCurrentAnimatorStateInfo(layer_Index).IsName(k_ClosedEndStateName); while (!closedStateReached) { if (!anim.IsInTransition(layer_Index)) { closedStateReached = anim.GetCurrentAnimatorStateInfo(layer_Index).IsName(k_ClosedEndStateName); } yield return(new WaitForEndOfFrame()); } } OutAction.OnCompleteMethod(); }
private void setQuitAction() { if (DestoryOnQuit) { OutAction.AddCompleteMethod(() => { Destroy(gameObject); } ); } else { OutAction.AddCompleteMethod(() => { gameObject.SetActive(false); } ); } }
/// <summary> /// Sets a callback delegate for requesting the private data. /// </summary> /// <privilege> /// http://tizen.org/privilege/recorder /// </privilege> /// <feature> /// http://tizen.org/feature/speech.recognition /// http://tizen.org/feature/microphone /// </feature> /// <param name="callback">callback function /// Called when Stt engine provides the engine service user with the private data. /// This callback function is called when the engine service user gets the private data from Stt engine. /// Out Parameters: /// a = Key -- The key field of private data /// b = data -- The data field of private data /// Following Error Codes can be returned /// 1. None /// 2. InvalidParameter /// 3. OperationFailed /// </param> /// <exception cref="ArgumentException">Thrown in case of Invalid Parameter</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case of Permission denied</exception> /// <exception cref="NotSupportedException">Thrown in case of Not supported</exception> /// <exception cref="InvalidOperationException">thrown in case of Operation failure</exception> /// <precondition> /// Main function should be invoked before this function is called. /// </precondition> /// <since_tizen> 4 </since_tizen> public void SetPrivateDataRequestedDelegate(OutAction <string> callback) { if (null == callback) { Log.Error(LogTag, "callback is null"); throw ExceptionFactory.CreateException(ErrorCode.InvalidParameter); } _privateDataRequestedCallback = callback; _privateDataRequestedCb = (string key, out string data) => { return(_privateDataRequestedCallback.Invoke(key, out data)); }; Error error = STTESetPrivateDataRequestedCb(_privateDataRequestedCb); if (error != Error.None) { Log.Error(LogTag, "SetPrivateDataRequestedDelegate Failed with error " + error); throw ExceptionFactory.CreateException((ErrorCode)error); } }
private async void StartHost() { try { _trayIcon.ShowBalloonTip(2000, Globals.ApplicationTitle, "Server is starting...", ToolTipIcon.Info); _debugLogger.WriteLine("Starting Server.."); OutAction <int> action = RunAsyncHostStart; int result = 0; Task t1 = new Task(() => action(ref result), _ct); t1.Start(); _tokenSource = new CancellationTokenSource(); _ct = _tokenSource.Token; await t1; switch (result) { case 0: _trayIcon.ShowBalloonTip(2000, Globals.ApplicationTitle, "Server is running", ToolTipIcon.Info); break; case 1: case 2: _trayIcon.ShowBalloonTip(2000, Globals.ApplicationTitle, "Server started with errors", ToolTipIcon.Warning); break; default: _trayIcon.ShowBalloonTip(2000, Globals.ApplicationTitle, "Server failed to start", ToolTipIcon.Error); break; } _tokenSource = null; } catch (Exception ex) { _debugLogger.WriteLine("Starting Server error: " + ex.Message); } }
/// <summary> /// Converts an action taking an "out" parameter to an action taking a "ref" parameter. /// </summary> /// <param name="act">The action to be converted.</param> /// <returns>The converted action.</returns> public static RefAction<T> OutToRefAction<T>(OutAction<T> act) { return (RefAction<T>)Delegate.CreateDelegate(TypeOf<RefAction<T>>.TypeID, act.Target, act.Method); }
public static ICallbackResult OutCallback <T1, TOut>(this ICallback mock, OutAction <T1, TOut> action) { return(OutCallbackInternal(mock, action)); }
public static IReturnsResult <TMock> OutCallback <TOut, TParam1, TMock>(this ICallback mock, OutAction <TOut, TParam1> action) where TMock : class { mock.GetType().Assembly .GetType("Moq.MethodCall") .InvokeMember("SetCallbackWithArguments", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, mock, new object[] { action }); return(mock as IReturnsResult <TMock>); }
private void InstanceTestOutIntStringObjectArray(out int a, out string b, out object[] c, OutAction callback) { callback.Invoke(out a, out b, out c); }
public override void Visit(OutAction act) { _outActions.Add(act); }
public static IReturnsThrows <TMock, TReturn> OutCallback <TMock, TReturn, T1, T2, TOut>(this ICallback <TMock, TReturn> mock, OutAction <T1, T2, TOut> action) where TMock : class { return(OutCallbackInternal(mock, action)); }
public virtual void Visit(OutAction act) { }
public virtual string Format(OutAction act) { return("_" + act.Name + "_"); }
public static IReturnsThrows <TMock, TReturn> OutCallback <TMock, TReturn, TIn, TOut>(this ICallback <TMock, TReturn> mock, OutAction <TIn, TOut> action) where TMock : class { mock.GetType() .Assembly.GetType("Moq.MethodCall") .InvokeMember("SetCallbackWithArguments", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, mock, new object[] { action }); return(mock as IReturnsThrows <TMock, TReturn>); }
/// <summary> /// Pins an "out" reference, so its internal address doesn't change. /// </summary> /// <param name="variable">The reference.</param> /// <param name="act">The action to receive the pinned reference.</param> public static void Pin<T>(out T variable, OutAction<T> act) { CacheHelper<T>.Pin(out variable, OutToRefAction(act)); }
public UsingStaticsTestable() { _getInput = UserInputGetInput; _logger = LogToScreen; }
public UsingStaticsTestable(OutAction <string> getInput, Action <string> logger) : base() { _getInput = getInput; _logger = logger; }