internal Promise <RunResult> Capture(Promise <RunResult> runTask) { if (runTask == null) { throw new ArgumentNullException("runTask"); } if (this.captureOutput == false) { return(runTask); } return(runTask.ContinueWith(t => { var result = t.GetResult(); if (this.Target == TARGET_STANDARD_OUTPUT) { this.capturedOutput = result.GetOutputData(); } else if (this.Target == TARGET_STANDARD_ERROR) { this.capturedOutput = result.GetErrorData(); } return result; })); }
internal Promise <RunResult> StickWith(Promise <RunResult> runTask) { if (runTask == null) { throw new ArgumentNullException("runTask"); } runTask.ContinueWith(t => { this.Dispose(); }); return(runTask); }
public static void Update() { if (checkRequirements == null) { checkRequirements = CharonCli.CheckRequirementsAsync(); } if (checkRequirements.IsCompleted == false) { return; } if (checkRequirements.HasErrors) { editorVersion = checkRequirements.Error.Unwrap().Message; return; } var result = checkRequirements.GetResult(); // ReSharper disable once SwitchStatementMissingSomeCases REASON: Other cases are irrelevant for display purposes switch (result) { case RequirementsCheckResult.MissingRuntime: editorVersion = Resources.UI_UNITYPLUGIN_WINDOW_CHECK_RESULT_MISSING_MONO_OR_DOTNET; break; case RequirementsCheckResult.MissingExecutable: editorVersion = Resources.UI_UNITYPLUGIN_WINDOWCHECK_RESULT_MISSING_TOOLS; break; case RequirementsCheckResult.Ok: if (checkToolsVersion == null) { editorVersion = Resources.UI_UNITYPLUGIN_WINDOW_CHECKING_VERSION; checkToolsVersion = CharonCli.GetVersionAsync(); checkToolsVersion.ContinueWith(r => { if (r.HasErrors) { editorVersion = r.Error.Unwrap().Message; } else { editorVersion = r.GetResult().ToString(); } }); } break; } }
private static bool OnOpenAsset(int instanceID, int exceptionId) { var gameDataPath = AssetDatabase.GetAssetPath(instanceID); if (GameDataTracker.IsGameDataFile(gameDataPath) == false) { return(false); } var reference = ValidationException.GetReference(exceptionId); loadEditorTask = new Coroutine <bool>(LoadEditor(gameDataPath, reference, loadEditorTask)); loadEditorTask.ContinueWith(t => EditorUtility.ClearProgressBar()); return(true); }
public void rejected_chain_continues_after_ContinueWith_returning_non_value_promise() { var promise = new Promise(); var callback = 0; promise.ContinueWith(() => { ++callback; return(Promise.Resolved()); }) .Then(() => ++ callback); promise.Reject(new Exception()); Assert.Equal(2, callback); }
public void rejected_chain_continues_after_ContinueWith_returning_value_promise() { var promise = new Promise(); var callback = 0; const string expectedValue = "foo"; promise.ContinueWith(() => { ++callback; return(Promise <string> .Resolved("foo")); }) .Then(x => { Assert.Equal(expectedValue, x); ++callback; }); promise.Reject(new Exception()); Assert.Equal(2, callback); }
public void can_chain_promise_after_ContinueWith() { var promise = new Promise(); const int expectedValue = 5; var callback = 0; promise.ContinueWith(() => { ++callback; return(Promise <int> .Resolved(expectedValue)); }) .Then(x => { Assert.Equal(expectedValue, x); ++callback; }); promise.Resolve(); Assert.Equal(2, callback); }
public void exception_in_ContinueWith_callback_returning_value_promise_is_caught_by_chained_catch() { //NOTE: Also tests that the new exception is passed through promise chain var promise = new Promise(); var callback = 0; var expectedException = new Exception("Expected"); promise.ContinueWith(new Func <IPromise <int> >(() => { ++callback; throw expectedException; })) .Catch(ex => { Assert.Equal(expectedException, ex); ++callback; }); promise.Reject(new Exception()); Assert.Equal(2, callback); }
private static bool OnOpenAsset(int instanceID, int exceptionId) { var gameDataPath = AssetDatabase.GetAssetPath(instanceID); if (Array.IndexOf(Settings.Current.GameDataPaths, gameDataPath) == -1) return false; var reference = ValidationException.GetReference(exceptionId); loadEditorTask = new Coroutine<bool>(LoadEditor(gameDataPath, reference, loadEditorTask)); loadEditorTask.ContinueWith(t => EditorUtility.ClearProgressBar()); return true; }