internal static object CreateProxyWithType <TChannel>(MessageDirection direction, ServiceChannel serviceChannel) { if (!typeof(TChannel).GetTypeInfo().IsInterface) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxChannelFactoryTypeMustBeInterface)); } return(ServiceChannelProxy.CreateProxy <TChannel>(direction, serviceChannel)); }
internal static ServiceChannel GetServiceChannel(object transparentProxy) { ServiceChannelProxy proxy = transparentProxy as ServiceChannelProxy; if (proxy != null) { return(proxy.GetServiceChannel()); } else { return(null); } }
// ServiceChannelProxy serves 2 roles. It is the TChannel proxy called by the client, // and it is also the handler of those calls that dispatches them to the appropriate service channel. // In .Net Remoting terms, it is conceptually the same as a RealProxy and a TransparentProxy combined. internal static TChannel CreateProxy <TChannel>(MessageDirection direction, ServiceChannel serviceChannel) { TChannel proxy = Create <TChannel, ServiceChannelProxy>(); if (proxy == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.FailedToCreateTypedProxy, typeof(TChannel)))); } ServiceChannelProxy channelProxy = (ServiceChannelProxy)(object)proxy; channelProxy._proxiedType = typeof(TChannel); channelProxy._serviceChannel = serviceChannel; channelProxy._proxyRuntime = serviceChannel.ClientRuntime.GetRuntime(); channelProxy._methodDataCache = new MethodDataCache(); return(proxy); }