/// <summary>
        ///		Creates new instance from the specified service type.
        /// </summary>
        /// <param name="serviceType">The concrete type which implements given service contract.</param>
        /// <returns>
        ///		<see cref="ServiceDescription"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="serviceType"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///		<paramref name="serviceType"/> is abstract class or interface.
        ///		Or, <paramref name="serviceType"/> does not have service contract, that is, it is not marked by <see cref="MessagePackRpcServiceContractAttribute"/>.
        ///		Or, <paramref name="serviceType"/> does not have publicly visible default constructor.
        ///		Or, any <see cref="MessagePackRpcServiceContractAttribute"/> property of <paramref name="serviceType"/> is invalid.
        /// </exception>
        public static ServiceDescription FromServiceType(Type serviceType)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }

            if (serviceType.IsAbstract)
            {
                throw new ArgumentException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "Service type '{0}' is not concrete type.",
                              serviceType.AssemblyQualifiedName
                              ),
                          "serviceType"
                          );
            }

            Contract.EndContractBlock();

            var serviceContract = Attribute.GetCustomAttribute(serviceType, typeof(MessagePackRpcServiceContractAttribute), true) as MessagePackRpcServiceContractAttribute;

            if (serviceContract == null)
            {
                throw new ArgumentException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "Service type '{0}' does not have service contract.",
                              serviceType.AssemblyQualifiedName
                              ),
                          "serviceType"
                          );
            }

            var serviceName = String.IsNullOrWhiteSpace(serviceContract.Name) ? ServiceIdentifier.TruncateGenericsSuffix(serviceType.Name) : serviceContract.Name;

            var ctor = serviceType.GetConstructor(Type.EmptyTypes);

            if (ctor == null)
            {
                throw new ArgumentException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "Service type '{0}' does not have public default constructor.",
                              serviceType.AssemblyQualifiedName
                              ),
                          "serviceType"
                          );
            }

            return
                (new ServiceDescription(serviceName, Expression.Lambda <Func <object> >(Expression.New(ctor)).Compile())
            {
                Version = serviceContract.Version,
                _serviceType = serviceType
            });
        }
        /// <summary>
        ///		Initializes a new instance of the <see cref="AsyncServiceInvoker&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="runtime">The <see cref="RpcServerRuntime"/> which provides runtime services.</param>
        /// <param name="serviceDescription">The service description which defines target operation.</param>
        /// <param name="targetOperation">The target operation to be invoked.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="runtime"/> is <c>null</c>.
        ///		Or, <paramref name="serviceDescription"/> is <c>null</c>.
        ///		Or, <paramref name="targetOperation"/> is <c>null</c>.
        /// </exception>
        internal AsyncServiceInvoker(RpcServerRuntime runtime, ServiceDescription serviceDescription, MethodInfo targetOperation)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime");
            }

            if (serviceDescription == null)
            {
                throw new ArgumentNullException("serviceDescription");
            }

            if (targetOperation == null)
            {
                throw new ArgumentNullException("targetOperation");
            }

            Contract.EndContractBlock();

            this._runtime            = runtime;
            this._serviceDescription = serviceDescription;
            this._targetOperation    = targetOperation;
            this._operationId        = ServiceIdentifier.TruncateGenericsSuffix(targetOperation.Name);
        }