public IAsyncResult BeginInvoke(RestHandler endPoint, object[] parameters, AsyncCallback callback, object context) { object[] destinationArray = null; int length = 0; if (parameters != null) { length = parameters.Length; } if (length != 0) { destinationArray = new object[length + 2]; Array.Copy(parameters, destinationArray, length); } else { destinationArray = new object[2]; } destinationArray[length] = callback; destinationArray[length + 1] = context; return (IAsyncResult)this._beginMethodInfo.Invoke(endPoint, destinationArray); }
public static RestEndPoint GetEndPoint(RestHandler endPointHandler) { Type key = endPointHandler.GetType(); RestEndPoint point = null; if (!_endPointMap.TryGetValue(key, out point)) { bool isAsync = endPointHandler is IHttpAsyncHandler; point = new RestEndPoint(key, isAsync); BindingFlags bindingAttr = BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance; MethodInfo[] methods = key.GetMethods(bindingAttr); if ((methods != null) && (methods.Length != 0)) { foreach (MethodInfo info in methods) { object[] customAttributes = info.GetCustomAttributes(typeof(RestMethodAttribute), true); if ((customAttributes != null) && (customAttributes.Length == 1)) { RestMethodAttribute attribute = (RestMethodAttribute)customAttributes[0]; RestOperation operation = null; if (!isAsync) { operation = CreateOperation(key, info, attribute); } else { operation = CreateAsyncOperation(key, info, attribute); } point.AddOperation(operation); } } } _endPointMap[key] = point; } return point; }
public object Invoke(RestHandler endPoint, object[] parameters) { return this._methodInfo.Invoke(endPoint, parameters); }
public object EndInvoke(RestHandler endPoint, IAsyncResult result) { return this._endMethodInfo.Invoke(endPoint, new object[] { result }); }