public Multiply(string greeting, int value, ResultDelegate callback) { this.greeting = greeting; this.value = value; this.callback = callback; this.Value = "I am the original value..."; }
public OAuthContext(AppDelegate next, IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { m_next = next; m_env = env; m_result = result; m_fault = fault; }
public void ExecuteRequest(IDictionary <string, object> env, ResultDelegate result, Action <Exception> fault) { if (_latched) { return; } var request = new Request(env); var response = new Response(result); if (Verbose) { Console.WriteLine("Received " + request.Path); } var context = new GateHttpContext(request); var routeData = RouteTable.Routes.GetRouteData(context); if (routeData == null) { // TODO -- try to do it by mapping the files write404(response); } else { executeRoute(request, routeData, response, fault); } // TODO -- return 404 if the route is not found if (Verbose) { Console.WriteLine(" ({0})", response.Status); } }
/// <summary> /// Gets the result of the last called made. /// </summary> /// <typeparam name="T">The result type.</typeparam> /// <param name="ignored"></param> /// <param name="callback">The callback.</param> /// <param name="state">The async state.</param> /// <returns>The result handle.</returns> public static Result <T> Of <T>(T ignored, ResultDelegate <T> callback, object state) { var result = Result.Of(ignored); result.SetCallbackInfo((IAsyncResult cb) => callback(result), state); return(result); }
static ResultDelegate WrapResultDelegate(ExecutionContext context, ResultDelegate result) { return (status, headers, body) => result( status, headers, WrapBodyDelegate(context, body)); }
public void Invoke(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { pathInfo = env[OwinConstants.RequestPath].ToString(); if (pathInfo.StartsWith("/")) { pathInfo = pathInfo.Substring(1); } if (pathInfo.Contains("..")) { Fail(Forbidden, "Forbidden").Invoke(env, result, fault); return; } path = Path.Combine(root ?? string.Empty, pathInfo); if (!File.Exists(path)) { Fail(NotFound, "File not found: " + pathInfo).Invoke(env, result, fault); return; } try { Serve(env).Invoke(env, result, fault); } catch (UnauthorizedAccessException) { Fail(Forbidden, "Forbidden").Invoke(env, result, fault); } }
static void App(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { try { var requestPath = (string)env[OwinConstants.RequestPath]; switch (requestPath) { case "/baseline": Baseline(env, result, fault); break; case "/favicon.ico": Baseline(env, result, fault); break; case "/": Welcome(env, result, fault); break; default: NotFound(env, result, fault); break; } } catch (Exception ex) { try { fault(ex); } catch { Console.WriteLine(ex.Message); } } }
public void ExecuteRequest(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { if (_latched) return; var request = new Request(env); var response = new Response(result); if (Verbose) Console.WriteLine("Received " + request.Path); var context = new GateHttpContext(request); var routeData = RouteTable.Routes.GetRouteData(context); if (routeData == null) { // TODO -- try to do it by mapping the files write404(response); } else { executeRoute(request, routeData, response, fault); } // TODO -- return 404 if the route is not found if (Verbose) Console.WriteLine(" ({0})", response.Status); }
public dlgInputBox(string question, ResultDelegate callback) { InitializeComponent(); _callback = callback; lbl_Question.Content = question; txt_Input.Focus(); }
/// <summary> /// Gets the result of the last called made. /// </summary> /// <param name="action">The action to execute.</param> /// <param name="callback">The callback.</param> /// <param name="state">The async state.</param> /// <returns>The result handle.</returns> public static Result Of(Action action, ResultDelegate callback, object state) { var result = Result.Of(action); result.SetCallbackInfo((IAsyncResult cb) => callback(result), state); return(result); }
public OwinResponse(ResultDelegate responseCallback) { _responseCallback = responseCallback; _cookies = new CookieManager(); IsClientConnected = true; }
public static Promise Load <T>(ResultDelegate <T> resultCallback) { var thread = new System.Threading.Thread(new ThreadStart(() => { try { var json = File.ReadAllText(getPath <T>()); resultCallback(JsonUtility.FromJson <T>(json)); } catch (Exception) { try { var json = File.ReadAllText(getBackupPath <T>()); resultCallback(JsonUtility.FromJson <T>(json)); } catch (Exception) { resultCallback(default(T)); } } })); thread.Start(); return(new Promise(thread)); }
static void SendNancyResponseToResult(Response response, ResultDelegate result) { if (!response.Headers.ContainsKey("Content-Type") && !string.IsNullOrWhiteSpace(response.ContentType)) { response.Headers["Content-Type"] = response.ContentType; } result( string.Format("{0:000} UNK", (int)response.StatusCode), response.Headers, (next, error, complete) => { using (var stream = new OutputStream(next, complete)) { try { response.Contents(stream); } catch (Exception ex) { error(ex); } } return(() => { }); }); }
public void ExecuteRequest(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { var environment = new Environment(env); var response = new Response(result); if (Verbose) Console.WriteLine("Received {0} - {1}", environment.Method, environment.Path); var routeData = determineRouteData(environment); if (routeData == null) { // TODO -- try to do it by mapping the files write404(response); } else { var request = new OwinRequestBody(environment); var bodyDelegate = environment["owin.RequestBody"] as BodyDelegate; if (bodyDelegate == null) { executeRoute(routeData, response, request); } else { var bodyBuilder = request.GetRequestBodyBuilder(); bodyDelegate(bodyBuilder, fault, () => executeRoute(routeData, response, request)); } } if (Verbose) Console.WriteLine(" ({0})", response.Status); }
public dlgCraftKeyConfig(ResultDelegate callback) { InitializeComponent(); _callback = callback; //lst_Key.ItemsSource = Enum.GetValues(typeof(Keys)).Cast<Keys>(); lst_Key.Items.Add("D1"); lst_Key.Items.Add("D2"); lst_Key.Items.Add("D3"); lst_Key.Items.Add("D4"); lst_Key.Items.Add("D5"); lst_Key.Items.Add("D6"); lst_Key.Items.Add("D7"); lst_Key.Items.Add("D8"); lst_Key.Items.Add("D9"); lst_Key.Items.Add("D0"); lst_Key.Items.Add("Dash"); lst_Condition.Items.Add("Poor"); lst_Condition.Items.Add("Normal"); lst_Condition.Items.Add("Good"); lst_Condition.Items.Add("Excellent"); lst_Condition.SelectedIndex = 3; lst_Key.SelectedIndex = 0; }
public Response(ResultDelegate result) { _result = result; Status = "200 OK"; Headers = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); Encoding = Encoding.UTF8; }
// DETAIL SUBMISSION public static void RunDetailSubmission(string addresses, ResultDelegate callback) { var parts = addresses.Split(':'); var tournamentAddress = parts[0]; var submissionAddress = parts[1]; queue(MtxExplorerDetailSubmission(new RoutineContext(new object[] { tournamentAddress, submissionAddress }, callback))); }
public OwinResponse(ResultDelegate responseCallback, string origin) { _responseCallback = responseCallback; _cookies = new CookieManager(); _origin = origin; IsClientConnected = true; }
public Response(ResultDelegate result) { _result = result; Status = "200 OK"; Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); Encoding = Encoding.UTF8; }
public Response(ResultDelegate result) { _result = result; SetStatus(HttpStatusCode.OK, "OK"); Headers = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); Encoding = Encoding.UTF8; }
public CallbackWrapper(ResultDelegate cbTarget) { if (cbTarget == null) { throw new ArgumentNullException("cbTarget"); } this._callbackDelegate = cbTarget; }
public Task App(IDictionary<string, object> env, Stream body, ResultDelegate result, Action<Exception> fault) { var headers = new Dictionary<string, IEnumerable<string>> { {"Content-Type", new[] {"text/html"}}, {"Content-Length", new[] {Output.Length.ToString(CultureInfo.InvariantCulture)}} }; return result("200 OK", headers, (stream, token) => stream.WriteAsync(Output, 0, Output.Length)); }
public void ActiveRewardEffect(ResultDelegate obj, object data) { TsAudioManager.Instance.AudioContainer.RequestAudioClip("UI_SFX", "EXPLOERE", "BOX_OPEN", new PostProcPerItem(NrAudioClipDownloaded.OnEventAudioClipDownloadedImmedatePlay)); NrTSingleton <FormsManager> .Instance.RequestAttachUIEffect("ui/mythicraid/fx_myth_raid_treasure_chest_mobile", this.m_dtInBox, this.m_dtInBox.GetSize()); this.m_bIsPlayAni = true; this.m_ResultDelegate = obj; this.m_ResultObject = data; }
public void Call( IDictionary <string, object> env, Action <Exception> fault, ResultDelegate result) { var nancyRequest = CreateNancyRequestFromEnvironment(env); var nancyContext = _engine.HandleRequest(nancyRequest); SendNancyResponseToResult(nancyContext.Response, result); }
public void Invoke(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { try { transform(env as Environment ?? new Environment(env), env0 => wrapped(env0, result, fault), fault); } catch (Exception e) { fault(e); } }
private void CreateResult() { if (operation is OptionalOperation) { result = GetOptionalResult; } else { result = GetTreeResult; } }
public Response(ResultDelegate result, int statusCode, IDictionary<string, string[]> headers) { _result = result; _responseWrite = EarlyResponseWrite; _responseEnd = EarlyResponseEnd; StatusCode = statusCode; Headers = headers; Encoding = Encoding.UTF8; }
public void Call(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { CallCount++; CallEnv = env; CallResult = result; CallFault = fault; if (CallResultSynchronously) { result(ResultStatus, ResultHeaders, ResultBody); } }
public static void SendFailureResult(IContext context, ResultDelegate result, Task<object> task) { var ctx = context as ContextWrapper; if (AccessedByNonLocalUrl(ctx)) { WritePublicSafeError(result); } else { WriteDetailedError(ctx, result, task); } }
void Raw(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { result( "200 OK", new Dictionary<string, string[]> { { "Content-Type", new[] { "text/plain" } } }, (write, end, cancel) => { write(new ArraySegment<byte>(Encoding.UTF8.GetBytes("Hello from lowest-level code")), null); end(null); }); }
public void Call(IDictionary <string, object> env, ResultDelegate result, Action <Exception> fault) { CallCount++; CallEnv = env; CallResult = result; CallFault = fault; if (CallResultSynchronously) { result(ResultStatus, ResultHeaders, ResultBody); } }
private void SendText(ResultDelegate result, IDictionary <string, object> env, string text) { var requestString = (string)env[OwinConstants.RequestPath]; var response = new Response(result) { ContentType = requestString.MimeType() }; response.Write(text); response.End(); }
public ConversationSentence.OnConsequenceDelegate NewResult(ResultDelegate action) { if (null != action) { return(new ConversationSentence.OnConsequenceDelegate(action)); } else { return(null); } }
public Response(ResultDelegate result, string status, IDictionary<string, IEnumerable<string>> headers) { _result = result; _responseWrite = EarlyResponseWrite; _responseFlush = EarlyResponseFlush; _responseEnd = EarlyResponseEnd; Status = status; Headers = headers; Encoding = Encoding.UTF8; }
private void Normalize() { if (operation is ElementaryBrackets) { ObjectFormulaTree tr = children[0]; children = tr.children; operation = tr.Operation; y = tr.y; result = tr.result; tag = tr.tag; } }
public static void Call(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { result( "404 Not Found", new Dictionary<string, string> { { "Content-Type", "text/html" } }, (next, error, complete) => { next(Body, null); complete(); return () => { }; }); }
static void PrintSingleResult(ResultDelegate method, string prompt = null) { var stopwatch = new Stopwatch(); stopwatch.Start(); string result = method(); stopwatch.Stop(); string print = prompt == null ? "" : $"Day: {prompt} |"; Console.WriteLine($"{print} MS: {stopwatch.ElapsedMilliseconds} | Awnser: {result}"); }
public OAuthMiddleware( AppDelegate next, OAuthConfiguration config, IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { m_config = config; m_env = env; m_result = result; m_ctx = new OAuthContext(next, m_env, m_result, fault); }
private void SendData(ResultDelegate result, IDictionary <string, object> env, byte[] data) { var requestString = (string)env[OwinConstants.RequestPath]; var response = new Response(result) { ContentType = requestString.MimeType() }; response.Headers["Content-Range"] = new[] { string.Format("bytes 0-{0}", (data.Length - 1)) }; response.Headers["Content-Length"] = new[] { data.Length.ToString(CultureInfo.InvariantCulture) }; response.Write(new ArraySegment <byte>(data)); response.End(); }
public static void Call(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { result( "404 Not Found", new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase) { {"Content-Type", new[] {"text/html"}} }, (write, end, cancellationToken) => { write(Body, null); end(null); }); }
public void Invoke(IDictionary<string, object> envDict, ResultDelegate result, Action<Exception> error) { var env = (envDict as Environment ?? new Environment(envDict)); var theScheduler = scheduler ?? (IScheduler)env["kayak.Scheduler"]; var oldBody = env.Body; if (oldBody != null) env.Body = (onNext, onError, onComplete) => { theScheduler.Post(() => { oldBody( (data, ack) => onNext(data, ack == null ? (Action)ack : () => theScheduler.Post(ack)), onError, onComplete); }); // XXX could properly provide this if the scheduler post above was hot. // or could wait/block. return () => { }; }; wrapped(env, (status, headers, body) => { theScheduler.Post(() => result(status, headers, (onNext, onError, onComplete) => { return body( (data, _) => { // if the writer is async (continuation non-null) // then we could keep track of the number of outstanding // buffers and apply back pressure if it's > 0. invoke // continuation when drained. // XXX pool buffers var buf = new byte[data.Count]; Buffer.BlockCopy(data.Array, data.Offset, buf, 0, buf.Length); theScheduler.Post(() => onNext(new ArraySegment<byte>(buf), null)); return false; }, bodyError => theScheduler.Post(() => onError(bodyError)), () => theScheduler.Post(() => onComplete())); })); }, e => { theScheduler.Post(() => error(e)); }); }
private static void App(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { result( "200 OK", new Dictionary<string, IEnumerable<string>>(StringComparer.OrdinalIgnoreCase) { {"Content-Type", new[] {"text/plain"}} }, (write, flush, end, cancel) => { var bytes = Encoding.Default.GetBytes("Hello world!"); write(new ArraySegment<byte>(bytes)); end(null); }); }
public void Run( string path, bool commitValue, List <Rule> rulesValue, ResultDelegate resultDelegate, ProgressDelegate progressDelegate, SignalEndDelegate signalEndDelegate) { commit = commitValue; rules = rulesValue; resultCallback = resultDelegate; progressCallback = progressDelegate; signalEndCallback = signalEndDelegate; this.scanFolder(path); signalEndCallback(); }
public void SubscribeMsg(string topic, ResultDelegate <bool> resultDelegate) { string[] topics = { topic }; byte[] qosLevels = { 0 }; ushort messageId = mqttClient.Subscribe(topics, qosLevels); SubscribeBean bean = new SubscribeBean(); bean.topic = topic; bean.msgId = messageId; bean.resultDelegate = resultDelegate; lock (SubscribeingQueueLock) { subscribeingQueue.Add(bean); } }
private static void App(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { result( "200 OK", new Dictionary<string, IEnumerable<string>>(StringComparer.OrdinalIgnoreCase) { {"Content-Type", new[] {"application/json;charset=utf-8"}}, {"Server", new [] {"Hello"}} }, (write, flush, end, cancel) => { var bytes = Encoding.Default.GetBytes("{\"responses\":{\"message\":\"hello world\"}}"); write(new ArraySegment<byte>(bytes)); end(null); }); }
public static void SendSuccessResult(ResultDelegate result, ResponseWrapper response) { result( // Status: response.StatusCode + " " + response.StatusDescription, // Headers: response.Headers.Set("Content-Type",response.ContentType ?? ""), // Output (write, flush, end, cancel) => { var bytes = response.Buffer.ToArray(); if (bytes.LongLength > 0) { write(new ArraySegment<byte>(bytes)); } end(null); }); }
private void App(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { var data = new ArraySegment<byte>(Encoding.UTF8.GetBytes(string.Format( "You did a {0} at {1}", env["owin.RequestMethod"], env["owin.RequestPath"]))); result( "200 OK", new Dictionary<string, IEnumerable<string>> { {"Content-Type", new[] {"text/plain"}} }, (write, flush, end, cancellationToken) => { write(data); end(null); }); }
public JankenForm(ShowConfigFormDelegate show_config, IPAddress address) { InitializeComponent(); this.show_config = show_config; lbl_result.Text = ""; lbl_player1.Text = ""; lbl_player2.Text = ""; ResultDelegate result_delegate = new ResultDelegate(JankenResponse); this.bt = new LibJanken(result_delegate); this.random = new Random(1000); network = new LibUDP(); peer_address = address; listener_result_delegate = new ListenerResponseDelegate(ListenerResponse); listener_exception_delegate = new ListenerExceptionDelegate(ShowExceptionMessage); network.ListenMessage(GAME_PORT, listener_result_delegate, listener_exception_delegate); }
public void Invoke(IDictionary<string, object> env, ResultDelegate result, Action<Exception> error) { var request = new RequestEnvironment(env); var theScheduler = scheduler ?? request.Scheduler; var oldBody = request.BodyDelegate; if (oldBody != null) { request.BodyDelegate = RescheduleBody(theScheduler, request.BodyDelegate); } wrapped( env, (status, headers, body) => theScheduler.Post(() => result(status, headers, RescheduleBody(theScheduler, body))), e => theScheduler.Post(() => error(e))); }
public void Call(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault) { CallCount += 1; Env = env; ResultCallback = result; FaultCallback = fault; RequestHeaders = (IDictionary<string, IEnumerable<string>>)env["owin.RequestHeaders"]; RequestBody = new FakeRequestBody((BodyDelegate)env["owin.RequestBody"]); if (OptionCallResultImmediately) { if (OptionReadRequestBody) { // read request body to nowhere, then call back result RequestBody.Subscribe( _ => false, _ => false, _ => result(ResponseStatus, ResponseHeaders, ResponseBody.Subscribe), CancellationToken.None); } else if (OptionCallResultImmediately) { // just then call back result, request unconsumed result(ResponseStatus, ResponseHeaders, ResponseBody.Subscribe); } } else { if (OptionReadRequestBody) { // read request body to nowhere, and leave everything hanging RequestBody.Subscribe( _ => false, _ => false, _ => { }, CancellationToken.None); } } }
public void BuildExecuteChildrenDelegate() { if (_strategyDelegate != null) { return; } var executeMethodInfo = typeof(ProxyDelegate <TSearch, TResult>).GetMethod("Execute"); var callChildrenExpressions = Children.Select(Expression.Constant) .Select(childExpr => Expression.Call(childExpr, executeMethodInfo, _strategy.ParamArray)) .ToArray(); _strategyDelegate = _strategy.GetStrategyExpression(callChildrenExpressions, IsRoot).Compile(); for (var i = 0; i < Children.Length; ++i) { Children[i].BuildExecuteChildrenDelegate(); } }
public void ExecuteRequest(IDictionary <string, object> env, ResultDelegate result, Action <Exception> fault) { var environment = new Environment(env); var response = new Response(result); if (Verbose) { Console.WriteLine("Received {0} - {1}", environment.Method, environment.Path); } var routeData = determineRouteData(environment); if (routeData == null) { // TODO -- try to do it by mapping the files write404(response); } else { var request = new OwinRequestBody(environment); var bodyDelegate = environment["owin.RequestBody"] as BodyDelegate; if (bodyDelegate == null) { executeRoute(routeData, response, request); } else { var bodyBuilder = request.GetRequestBodyBuilder(); bodyDelegate(bodyBuilder, fault, () => executeRoute(routeData, response, request)); } } if (Verbose) { Console.WriteLine(" ({0})", response.Status); } }
private void ResultUpdate(bool success) { if (FlashProgrammingProgressBar.InvokeRequired) { var d = new ResultDelegate(ResultUpdate); FlashProgrammingProgressBar.Invoke(d, new object[] { success }); } else { FlashProgrammingProgressBar.Minimum = 0; FlashProgrammingProgressBar.Maximum = 0; FlashProgrammingProgressBar.Value = 0; if (success) { MessageBox.Show("Programming succesfull"); } else { MessageBox.Show("Programming failed"); } } }
private void ServerCallback(IDictionary <string, object> env, ResultDelegate result, Action <Exception> fault) { var requestString = (string)env[OwinConstants.RequestPath]; Tracing.Info(requestString); if (!content.IsAvailable(requestString)) { SendText(result, env, "Page not found: " + requestString); return; } if (requestString.MimeType().IsBinaryMime()) { var fileContents = content.GetBinaryContent(requestString); SendData(result, env, fileContents); } else { var fileContents = content.GetContent(requestString); SendText(result, env, fileContents); } }
public ConversationSentence.OnConsequenceDelegate Result(ResultDelegate action) { return(new ConversationSentence.OnConsequenceDelegate(action)); }
private PrintingManager() { resultDelegate += new ResultDelegate(resultValue); }