コード例 #1
0
 /// <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()));
     }
 }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
        /// <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);
            }
        }
コード例 #4
0
        /// <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));
            }
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
 /// <summary>
 /// Create a <see cref="ServerCredentials"/>.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public abstract ServerCredentials CreateServerCredentials(RpcConfigurationContext context);
コード例 #7
0
 /// <summary>
 /// Create a <see cref="ChannelCredentials"/>.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public abstract ChannelCredentials CreateChannelCredentials(RpcConfigurationContext context);
コード例 #8
0
 /// <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)));
 }
コード例 #9
0
 /// <summary>
 /// Create a <see cref="Interceptor"/>.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public abstract Interceptor CreateInterceptor(RpcConfigurationContext context);
コード例 #10
0
 /// <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)));
 }
コード例 #11
0
 /// <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));
 }
コード例 #12
0
 /// <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));
 }
コード例 #13
0
 /// <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));
 }
コード例 #14
0
 /// <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));
 }
コード例 #15
0
 /// <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));
 }
コード例 #16
0
 /// <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);