public void GetHandlerReturnsCorrectOperationHandlerType(ODataPathKind pathKind, OperationType operationType, Type handlerType) { // Arrange OperationHandlerProvider provider = new OperationHandlerProvider(); // Act IOperationHandler hander = provider.GetHandler(pathKind, operationType); // Assert Assert.Same(handlerType, hander.GetType()); }
/// <summary> /// Sets <see cref="P:Photon.SocketServer.Rpc.Peer.CurrentOperationHandler"/>. /// </summary> /// <param name="operationHandler"> The new operation handler.</param> public void SetCurrentOperationHandler(IOperationHandler operationHandler) { if (operationHandler == null) { operationHandler = OperationHandlerDisabled.Instance; } if (log.IsDebugEnabled) { string str = (this.CurrentOperationHandler == null) ? "{null}" : this.CurrentOperationHandler.GetType().ToString(); string str2 = (operationHandler == null) ? "{null}" : operationHandler.GetType().ToString(); log.DebugFormat("set operation handler to {0}, was {1} - peer id {2}", new object[] { str2, str, base.ConnectionId }); } this.CurrentOperationHandler = operationHandler; }
/// <summary> /// The create delegates. /// </summary> /// <param name="cache">The cache.</param> /// <param name="handler">The handler.</param> private void CreateDelegates(OperationMethodInfoCache cache, IOperationHandler handler) { Dictionary <byte, MethodInfo> operationMethodInfos = cache.OperationMethodInfos; Type type = handler.GetType(); foreach (KeyValuePair <byte, MethodInfo> pair in operationMethodInfos) { MethodInfo method = pair.Value; if (method.ReflectedType != type) { throw new ArgumentException(string.Format("Type {0} does not support method {1}.{2}", type.Name, method.ReflectedType, method.Name)); } Func <PeerBase, OperationRequest, SendParameters, OperationResponse> func = (Func <PeerBase, OperationRequest, SendParameters, OperationResponse>)Delegate.CreateDelegate(OperationMethodInfoCache.OperationDelegateType, handler, method); this.operations.Add(pair.Key, func); } }