public T ExpectRpcCall <T>( DrsrRpcInterfaceType interfaceType, TimeSpan timeout, out DrsrServerSessionContext sessionContext) where T : DrsrRequestStub { RpceServerSessionContext rpceSessionContext; ushort opnum; byte[] requestStub = rpceLayerServer.ExpectCall(timeout, out rpceSessionContext, out opnum); if ((interfaceType == DrsrRpcInterfaceType.DSAOP && !Enum.IsDefined(typeof(DsaopMethodOpnums), (ushort)opnum)) || (interfaceType == DrsrRpcInterfaceType.DRSUAPI && !Enum.IsDefined(typeof(DrsuapiMethodOpnums), (ushort)opnum))) { throw new InvalidOperationException("An invalid method is invoked"); } //If there isn't a corresponding Drsr session context, it's a new session if (contextManager.LookupSessionContext(rpceSessionContext, out sessionContext)) { sessionContext.RpceLayerSessionContext = rpceSessionContext; } T t; if (typeof(T) == typeof(DrsrRequestStub)) { t = (T)DrsrUtility.CreateDrsrRequestStub(interfaceType, opnum); } else { t = (T)Activator.CreateInstance(typeof(T)); if ((ushort)t.Opnum != opnum) { throw new InvalidOperationException("An unexpected method call is received"); } } //Decode the request stub t.Decode(sessionContext, requestStub); //Update the session context sessionContext.UpdateSessionContextWithMessageReceived(interfaceType, t); return(t); }
public T ExpectRpcCall <T>(TimeSpan timeout, out LsaServerSessionContext sessionContext) where T : LsaRequestStub { RpceServerSessionContext rpceSessionContext; ushort opnum; byte[] requestStub = rpceLayerServer.ExpectCall(timeout, out rpceSessionContext, out opnum); if (!Enum.IsDefined(typeof(LsaMethodOpnums), (int)opnum)) { throw new InvalidOperationException("An invalid method is invoked"); } //If there isn't a corresponding lsa session context, it's a new session if (contextManager.LookupSessionContext(rpceSessionContext, out sessionContext)) { sessionContext.RpceLayerSessionContext = rpceSessionContext; } T t; if (typeof(T) == typeof(LsaRequestStub)) { t = (T)LsaUtility.CreateLsaRequestStub((LsaMethodOpnums)opnum); } else { t = (T)Activator.CreateInstance(typeof(T)); if ((ushort)t.Opnum != opnum) { throw new InvalidOperationException("An unexpected method call is received"); } } //Decode the request stub t.Decode(sessionContext, requestStub); //Update the session context sessionContext.UpdateSessionContextWithMessageReceived(t); return(t); }