private void handleRequest(HttpListenerContext context)
        {
            var eventArgs = new HttpEventArgs(context.Request, context.Response);
            var method    = context.Request.HttpMethod;

            try
            {
                if (method == HttpMethod.Get.Method)
                {
                    OnGet?.Invoke(this, eventArgs);
                }
                else if (method == HttpMethod.Post.Method)
                {
                    OnPost?.Invoke(this, eventArgs);
                }
                else if (method == HttpMethod.Put.Method)
                {
                    OnPut?.Invoke(this, eventArgs);
                }
            }
            catch (NotImplementedException)
            {
                context.Response.Abort();
            }
        }
Example #2
0
 public void Post(string host, string path, string json, Action <string, FizzException> callback)
 {
     if (OnPost != null)
     {
         OnPost.Invoke(host, path, json);
     }
 }
Example #3
0
        public void Post(string title, string summary, IEnumerable <NamedAction> tasks)
        {
            var post = new EventPost(title, summary, tasks);

            Items.Add(post);
            OnPost.InvokeIfExists(post);
        }
Example #4
0
        public override void HandleEvent(NodeEvent eventValue)
        {
            if (eventValue is ViewActionEvent)
            {
                switch (((ViewActionEvent)eventValue).Action)
                {
                case (SourceActions.Post):
                    if (OnPost != null)
                    {
                        OnPost.Execute();
                    }
                    break;

                case (SourceActions.Cancel):
                    if (OnCancel != null)
                    {
                        OnCancel.Execute();
                    }
                    break;
                }
            }
            base.HandleEvent(eventValue);
        }
Example #5
0
 protected virtual void OnPostAction(PostEventArgs <string> e)
 {
     OnPost?.Invoke(this, e);
 }
Example #6
0
        private void onRequest(HttpListenerContext context)
        {
            var req       = context.Request;
            var res       = context.Response;
            var eventArgs = new HttpRequestEventArgs(context);

            if (req.HttpMethod == "GET" && !OnGet.IsNull())
            {
                OnGet(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "HEAD" && !OnHead.IsNull())
            {
                OnHead(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "POST" && !OnPost.IsNull())
            {
                OnPost(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "PUT" && !OnPut.IsNull())
            {
                OnPut(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "DELETE" && !OnDelete.IsNull())
            {
                OnDelete(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "OPTIONS" && !OnOptions.IsNull())
            {
                OnOptions(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "TRACE" && !OnTrace.IsNull())
            {
                OnTrace(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "CONNECT" && !OnConnect.IsNull())
            {
                OnConnect(this, eventArgs);
                return;
            }

            if (req.HttpMethod == "PATCH" && !OnPatch.IsNull())
            {
                OnPatch(this, eventArgs);
                return;
            }

            res.StatusCode = (int)HttpStatusCode.NotImplemented;
        }
Example #7
0
 void Post(string path, System.Collections.Specialized.NameValueCollection query)
 {
     OnPost?.Invoke(path, query);
 }
Example #8
0
    public void UpdateData <T>(string path, T data, OnPost callback)
    {
        string url = String.Format("{0}{1}.json", databaseRoot, path);

        RestClient.Put <T>(url, data).Then(response => { callback(); });
    }
Example #9
0
 protected void OnPostAction(PostEventArgs <Dictionary <string, object> > e)
 {
     OnPost?.Invoke(this, e);
 }
Example #10
0
 protected virtual void OnPostAction(PostEventArgs <ObjectType> e)
 {
     OnPost?.Invoke(this, e);
 }