public RequestHandler(string path, RequestHandlerCallback callback) { if (path == null) throw new ArgumentNullException("path"); if (callback == null) throw new ArgumentNullException("callback"); Path = path; Callback = callback; }
private void RequestListener() { while (true) { RequestHandlerCallback d = new RequestHandlerCallback(RequestHandler); d.Invoke(); Thread.Sleep(request_check_speed); } }
public RequestHandler(string path, RequestHandlerCallback callback) { if (path == null) { throw new ArgumentNullException("path"); } if (callback == null) { throw new ArgumentNullException("callback"); } Path = path; Callback = callback; }
protected void RegisterHandler(string path, RequestHandlerCallback callback) { RegisterHandler(new RequestHandler(path, callback)); }
/// <summary> /// Initializes a new instance of the <see cref="ActionModule"/> class. /// </summary> /// <param name="handler">The handler.</param> public ActionModule(RequestHandlerCallback handler) : this("/", HttpVerb.Any, handler) { }
/// <summary> /// Initializes a new instance of the <see cref="ActionModule" /> class. /// </summary> /// <param name="baseRoute">The base route.</param> /// <param name="verb">The HTTP verb that will be served by this module.</param> /// <param name="handler">The callback used to handle requests.</param> /// <exception cref="ArgumentNullException"><paramref name="handler"/> is <see langword="null"/>.</exception> /// <seealso cref="WebModuleBase(string)"/> public ActionModule(string baseRoute, HttpVerb verb, RequestHandlerCallback handler) : base(baseRoute) { _verb = verb; _handler = Validate.NotNull(nameof(handler), handler); }
internal static extern int SetRequestHandler(IntPtr resource, RequestHandlerCallback cb, IntPtr userData);
internal static extern int Create(string uriPath, IntPtr resTypes, IntPtr ifaces, int properties, RequestHandlerCallback cb, IntPtr userData, out IntPtr resourceHandle);
/// <summary> /// Creates an instance of <see cref="ActionModule"/> that intercepts all <c>DELETE</c>requests /// under the specified <paramref name="baseRoute"/> and adds it to a module container. /// </summary> /// <typeparam name="TContainer">The type of the module container.</typeparam> /// <param name="this">The <typeparamref name="TContainer"/> on which this method is called.</param> /// <param name="baseRoute">The base route of the module.</param> /// <param name="handler">The callback used to handle requests.</param> /// <returns><paramref name="this"/> with a <see cref="ActionModule"/> added.</returns> /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception> /// <seealso cref="ActionModule"/> /// <seealso cref="IWebModuleContainer.Modules"/> /// <seealso cref="IComponentCollection{T}.Add"/> public static TContainer OnDelete <TContainer>(this TContainer @this, string baseRoute, RequestHandlerCallback handler) where TContainer : class, IWebModuleContainer => WithAction(@this, baseRoute, HttpVerbs.Delete, handler);
/// <summary> /// Creates an instance of <see cref="ActionModule"/> that intercepts all requests /// and adds it to a module container. /// </summary> /// <typeparam name="TContainer">The type of the module container.</typeparam> /// <param name="this">The <typeparamref name="TContainer"/> on which this method is called.</param> /// <param name="handler">The callback used to handle requests.</param> /// <returns><paramref name="this"/> with a <see cref="ActionModule"/> added.</returns> /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception> /// <seealso cref="ActionModule"/> /// <seealso cref="IWebModuleContainer.Modules"/> /// <seealso cref="IComponentCollection{T}.Add"/> public static TContainer OnAny <TContainer>(this TContainer @this, RequestHandlerCallback handler) where TContainer : class, IWebModuleContainer => WithAction(@this, UrlPath.Root, HttpVerbs.Any, handler);
/// <summary> /// Creates an instance of <see cref="ActionModule"/> and adds it to a module container. /// </summary> /// <typeparam name="TContainer">The type of the module container.</typeparam> /// <param name="this">The <typeparamref name="TContainer"/> on which this method is called.</param> /// <param name="baseRoute">The base route of the module.</param> /// <param name="verb">The HTTP verb that will be served by <paramref name="handler"/>.</param> /// <param name="handler">The callback used to handle requests.</param> /// <returns><paramref name="this"/> with a <see cref="ActionModule"/> added.</returns> /// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception> /// <seealso cref="ActionModule"/> /// <seealso cref="IWebModuleContainer.Modules"/> /// <seealso cref="IComponentCollection{T}.Add"/> public static TContainer WithAction <TContainer>(this TContainer @this, string baseRoute, HttpVerbs verb, RequestHandlerCallback handler) where TContainer : class, IWebModuleContainer { @this.Modules.Add(new ActionModule(baseRoute, verb, handler)); return(@this); }