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(); } }
/// <summary> /// Creates a new instance of the object pool and initializes it. /// </summary> /// <param name="maxPoolSize">The maximum amount of objects that should be pooled maximum.</param> public ObjectPool(Constructor constructor, int maxPoolSize = 1000, OnReturn onReturn = null, OnGet onGet = null) { this.constructor = constructor; this.onReturn = onReturn; this.onGet = onGet; this.maxPoolSize = maxPoolSize; }
public BarResponse Get(string id) { OnGet?.Invoke(this, id); return(new BarResponse { Data = _testData }); }
protected void InvokeOnGet(T item) { if (OnGet != null) { OnGet.Invoke(item); } }
public void GetData <T>(string path, OnGet <T> callback) { string url = String.Format("{0}{1}.json", databaseRoot, path); RestClient.Get(url).Then(response => { Debug.Log(String.Format("Response code:{0}", response.StatusCode)); callback(JsonUtility.FromJson <T>(response.Text)); }); }
public void OnPoolGet() { if (lifecycleHandlers != null) { for (var i = 0; i < lifecycleHandlers.Length; i++) { var handler = lifecycleHandlers[i]; handler.OnPoolGet(); } } OnGet?.Invoke(); }
public T Get() { if (unused.Count <= 0) { Expand(); } T item = unused.Pop(); used.Add(item); item.OnGet(this); OnGet?.Invoke(item); return(item); }
public virtual async Task<T> Get<T>(string resource, CancellationToken cancelToken, string taskTitle, string successMsg, params Func<T, object>[] successMsgArgs ) where T : new() { if (!IsLoggedIn) throw Error.BadAct($"‹{this.GetType().Name}› is not logged in."); var req = _auth.Req.GET(resource); try { return await _client.Send<T>(req, cancelToken, taskTitle, successMsg, successMsgArgs); } catch (RestServiceException ex) { OnGet.Err(this, ex); } catch (Exception ex) { OnUnhandled.Err(this, ex); } return default(T); }
public PoolableObject Get(object id) { if (id == null) { Debug.LogError("Get >>> id cannot be null!"); return(null); } Pool pool; if (pools.ContainsKey(id)) { pool = pools[id]; } else { Debug.LogError($"Pool doesn't exist for id {id}!"); return(null); } OnGet?.Invoke(); return(pool.Get()); }
protected virtual void OnGetAction(GetEventArgs e) { OnGet?.Invoke(this, e); }
private void TriggerOnGet(string key, string region, CacheActionEventArgOrigin origin = CacheActionEventArgOrigin.Local) { OnGet?.Invoke(this, new CacheActionEventArgs(key, region, origin)); }
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; }
private void TriggerOnGet(TKey key, CacheActionEventArgOrigin origin = CacheActionEventArgOrigin.Local) { OnGet?.Invoke(this, new CacheActionEventArgs <TKey>(key, origin)); }
public T this[int index] { get { OnGet.Invoke(InternalList[index], index); return(InternalList[index]); } set { OnSet.Invoke(value, index); InternalList[index] = value; } }
public T2 this[T1 index] { get { OnGet.Invoke(index, InternalDict[index]); return(InternalDict[index]); } set { InternalDict[index] = value; OnSet.Invoke(index, value); } }