/// <summary> /// Create a <see cref="Channel"/>. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public Channel CreateChannel(RpcConfigurationContext context) { if (Options == null || Options.Length == 0) { return(new Channel(Host, Port, CreateChannelCredentials(context))); } else { return(new Channel(Host, Port, CreateChannelCredentials(context), CreateChannelOptions())); } }
/// <summary> /// Create a <see cref="ChannelCredentials"/>. /// </summary> /// <param name="context">The context.</param> /// <exception cref="RpcConfigurationException"> /// The specified name is not found. /// </exception> /// <returns></returns> private ChannelCredentials CreateChannelCredentials(RpcConfigurationContext context) { if (string.IsNullOrEmpty(CredentialsName)) { return(ChannelCredentials.Insecure); } if (context.TryGetChannelCredentials(CredentialsName, out ChannelCredentials credentials)) { return(credentials); } throw new RpcConfigurationException(string.Format("The specified name is not found. The name is '{0}'", CredentialsName)); }
/// <summary> /// Intercept the service. /// </summary> /// <param name="service">The service.</param> /// <param name="context">The context.</param> /// <returns></returns> public ServerServiceDefinition Intercept(ServerServiceDefinition service, RpcConfigurationContext context) { Interceptor[] interceptors = RpcConfigurationUtility.CreateInterceptors(context, Interceptors, ExtraInterceptors); if (interceptors.Length > 0) { return(service.Intercept(interceptors)); } else { return(service); } }
/// <summary> /// Create a <see cref="CallInvoker"/>. /// </summary> /// <param name="channel">The channel.</param> /// <param name="context">The context.</param> /// <returns></returns> public CallInvoker CreateCallInvoker(Channel channel, RpcConfigurationContext context) { Interceptor[] interceptors = RpcConfigurationUtility.CreateInterceptors(context, Interceptors, ExtraInterceptors); if (interceptors.Length > 0) { return(CreateRootCallInvoker(channel, context).Intercept(interceptors)); } else { return(CreateRootCallInvoker(channel, context)); } }
/// <summary> /// Create interceptors. /// </summary> /// <param name="context">The context.</param> /// <param name="interceptorConfigs">The interceptor configs.</param> /// <returns></returns> internal static Interceptor[] CreateInterceptors(RpcConfigurationContext context, params RpcInterceptorConfigBase[][] interceptorConfigs) { List <RpcInterceptorConfigBase> configs = new List <RpcInterceptorConfigBase>(); foreach (RpcInterceptorConfigBase[] config in interceptorConfigs) { if (config != null) { configs.AddRange(config); } } configs.Sort(RpcInterceptorConfigBase.CompareByOrder); Interceptor[] interceptors = new Interceptor[configs.Count]; for (int i = 0; i < configs.Count; ++i) { interceptors[i] = configs[i].CreateInterceptor(context); } return(interceptors); }
/// <summary> /// Create a <see cref="ServerCredentials"/>. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public abstract ServerCredentials CreateServerCredentials(RpcConfigurationContext context);
/// <summary> /// Create a <see cref="ChannelCredentials"/>. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public abstract ChannelCredentials CreateChannelCredentials(RpcConfigurationContext context);
/// <summary> /// Create a <see cref="ServerPort"/>. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public ServerPort CreateServerPort(RpcConfigurationContext context) { return(new ServerPort(Host, Port, CreateServerCredentials(context))); }
/// <summary> /// Create a <see cref="Interceptor"/>. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public abstract Interceptor CreateInterceptor(RpcConfigurationContext context);
/// <summary> /// Create a KeyCertificatePair. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public KeyCertificatePair CreateKeyCertificatePair(RpcConfigurationContext context) { return(new KeyCertificatePair(context.GetCertificateChain(CertificateChain), context.GetPrivateKey(PrivateKey))); }
/// <summary> /// Create a new server credentials. /// </summary> /// <param name="config">The credentials config.</param> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="ObjectDisposedException"> /// This instance has already been disposed. /// </exception> protected virtual ServerCredentials CreateServerCredentials(RpcCredentialsConfigBase config, RpcConfigurationContext context) { ThrowExceptionIfDisposed(); return(config.CreateServerCredentials(context)); }
/// <summary> /// Create a new interceptor. /// </summary> /// <param name="config">The interceptor config.</param> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="ObjectDisposedException"> /// This instance has already been disposed. /// </exception> protected virtual Interceptor CreateInterceptor(RpcInterceptorConfigBase config, RpcConfigurationContext context) { ThrowExceptionIfDisposed(); return(config.CreateInterceptor(context)); }
/// <summary> /// Create a new callInvoker. /// </summary> /// <param name="config">The callInvoker config.</param> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="ObjectDisposedException"> /// This instance has already been disposed. /// </exception> protected virtual CallInvoker CreateCallInvoker(RpcCallInvokerConfigBase config, RpcConfigurationContext context) { ThrowExceptionIfDisposed(); return(config.CreateCallInvoker(context.GetChannel(config.ChannelName), context)); }
/// <summary> /// Create a new serverPort. /// </summary> /// <param name="config">The channel config.</param> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="ObjectDisposedException"> /// This instance has already been disposed. /// </exception> protected virtual ServerPort CreateServerPort(RpcChannelConfig config, RpcConfigurationContext context) { ThrowExceptionIfDisposed(); return(config.CreateServerPort(context)); }
/// <summary> /// Create a new channel. /// </summary> /// <param name="config">The channel config.</param> /// <param name="context">The context.</param> /// <returns></returns> /// <exception cref="ObjectDisposedException"> /// This instance has already been disposed. /// </exception> protected virtual Channel CreateChannel(RpcChannelConfig config, RpcConfigurationContext context) { ThrowExceptionIfDisposed(); return(config.CreateChannel(context)); }
/// <summary> /// Create a <see cref="CallInvoker"/>. /// </summary> /// <param name="channel">The channel.</param> /// <param name="context">The context.</param> /// <returns></returns> public abstract CallInvoker CreateRootCallInvoker(Channel channel, RpcConfigurationContext context);