public IContract CreateSessionContractInstance(ISession session) { SessionContract sessionContract = null; lock (syncObj) { try { currentSession = session; object[] remoteServiceInstances = new object[this.remoteServiceInterfaceTypes.Count]; object[] localServiceInstances = new object[this.localSessionServiceInterfaceTypes.Count]; sessionContract = new SessionContract(this, session, localServiceInstances, remoteServiceInstances); currentContract = sessionContract; for (int i = 0; i < this.remoteServiceInterfaceTypes.Count; i++) { // get instance of service proxy implementation (remote call) Type remoteProxyType = this.remoteServiceProxyTypes[i]; try { remoteServiceInstances[i] = this.GetExport(remoteProxyType); } catch (Exception exportException) { throw new TypeLoadException($"Unable to export instance of remote proxy type {remoteProxyType}!", exportException); } } for (int i = 0; i < this.localSessionServiceInterfaceTypes.Count; i++) { // get instance of local service implementation Type localType = this.localSessionServiceInterfaceTypes[i]; try { localServiceInstances[i] = this.GetExport(localType); } catch (Exception exportException) { throw new TypeLoadException($"Unable to export instance of local type {localType}!", exportException); } } sessionIdContractMapping.Add(session.SessionId, sessionContract); } finally { currentSession = null; currentContract = null; } } return(sessionContract); }
internal bool TryRaiseInMemorySessionCreated(Type serviceType, object serviceInstance, TalkCompositionHost host, IGenericCommunicationService communicationService) { SessionChangeSubscription subscr; if (sessionCreatedSubscriptions.TryGetValue(serviceType, out subscr)) { if (inMemorySession == null) { inMemorySession = new Session(communicationService, 0, "In-Memory Session"); inMemorySessionContract = new SessionContract(host, inMemorySession, new object[0], new object[0]); } subscr.Invoke(serviceInstance, inMemorySessionContract, inMemorySession); return(true); } else { return(false); } }