Beispiel #1
0
        bool CheckMethod(MethodInfo method, RequestHandlerAttribute attr)
        {
            if ((method.ReturnType != typeof(void)) &&
                !method.ReturnType.Equals(typeof(Task)))
            {
                return(false);
            }

            var pinfo = method.GetParameters();

            if (pinfo.Length != 1)
            {
                return(false);
            }

            if (!pinfo [0].ParameterType.Equals(typeof(ServerContext)))
            {
                return(false);
            }

            var handler = new RequestHandler(method, attr);

            handlerByName.Add(handler.Name, handler);
            handlerByMethod.Add(method, handler);
            return(true);
        }
Beispiel #2
0
            public RequestHandler(MethodInfo method, RequestHandlerAttribute attr)
            {
                Attribute = attr;
                if (method.ReturnType == typeof(void))
                {
                    Handler = (RequestHandlerDelegate)Delegate.CreateDelegate(
                        typeof(RequestHandlerDelegate), method);
                }
                else
                {
                    IsAsync      = true;
                    AsyncHandler = (AsyncRequestHandlerDelegate)Delegate.CreateDelegate(
                        typeof(AsyncRequestHandlerDelegate), method);
                }

                Name = method.DeclaringType.FullName.Replace('.', '/') + '/' + method.Name;
            }
Beispiel #3
0
			public RequestHandler (MethodInfo method, RequestHandlerAttribute attr)
			{
				Attribute = attr;
				if (method.ReturnType == typeof (void)) {
					Handler = (RequestHandlerDelegate)Delegate.CreateDelegate (
						typeof (RequestHandlerDelegate), method);
				} else {
					IsAsync = true;
					AsyncHandler = (AsyncRequestHandlerDelegate)Delegate.CreateDelegate (
						typeof (AsyncRequestHandlerDelegate), method);
				}

				Name = method.DeclaringType.FullName.Replace ('.', '/') + '/' + method.Name;
			}
Beispiel #4
0
		bool CheckMethod (MethodInfo method, RequestHandlerAttribute attr)
		{
			if ((method.ReturnType != typeof (void)) &&
			    !method.ReturnType.Equals (typeof (Task)))
				return false;

			var pinfo = method.GetParameters ();
			if (pinfo.Length != 1)
				return false;

			if (!pinfo [0].ParameterType.Equals (typeof(ServerContext)))
				return false;

			var handler = new RequestHandler (method, attr);
			handlerByName.Add (handler.Name, handler);
			handlerByMethod.Add (method, handler);
			return true;
		}