#region Copyright notice and license
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion
using System;
using Grpc.Core.Internal;
using Grpc.Core.Utils;
namespace Grpc.Core
{
///
/// Details about a client-side call to be invoked.
///
/// Request message type for the call.
/// Response message type for the call.
public struct CallInvocationDetails
{
readonly Channel channel;
readonly string method;
readonly string host;
readonly Marshaller requestMarshaller;
readonly Marshaller responseMarshaller;
CallOptions options;
///
/// Initializes a new instance of the struct.
///
/// Channel to use for this call.
/// Method to call.
/// Call options.
public CallInvocationDetails(Channel channel, Method method, CallOptions options) :
this(channel, method, null, options)
{
}
///
/// Initializes a new instance of the struct.
///
/// Channel to use for this call.
/// Method to call.
/// Host that contains the method. if null, default host will be used.
/// Call options.
public CallInvocationDetails(Channel channel, Method method, string host, CallOptions options) :
this(channel, method.FullName, host, method.RequestMarshaller, method.ResponseMarshaller, options)
{
}
///
/// Initializes a new instance of the struct.
///
/// Channel to use for this call.
/// Qualified method name.
/// Host that contains the method.
/// Request marshaller.
/// Response marshaller.
/// Call options.
public CallInvocationDetails(Channel channel, string method, string host, Marshaller requestMarshaller, Marshaller responseMarshaller, CallOptions options)
{
this.channel = GrpcPreconditions.CheckNotNull(channel, "channel");
this.method = GrpcPreconditions.CheckNotNull(method, "method");
this.host = host;
this.requestMarshaller = GrpcPreconditions.CheckNotNull(requestMarshaller, "requestMarshaller");
this.responseMarshaller = GrpcPreconditions.CheckNotNull(responseMarshaller, "responseMarshaller");
this.options = options;
}
///
/// Get channel associated with this call.
///
public Channel Channel
{
get
{
return this.channel;
}
}
///
/// Gets name of method to be called.
///
public string Method
{
get
{
return this.method;
}
}
///
/// Get name of host.
///
public string Host
{
get
{
return this.host;
}
}
///
/// Gets marshaller used to serialize requests.
///
public Marshaller RequestMarshaller
{
get
{
return this.requestMarshaller;
}
}
///
/// Gets marshaller used to deserialized responses.
///
public Marshaller ResponseMarshaller
{
get
{
return this.responseMarshaller;
}
}
///
/// Gets the call options.
///
public CallOptions Options
{
get
{
return options;
}
}
///
/// Returns new instance of with
/// Options set to the value provided. Values of all other fields are preserved.
///
public CallInvocationDetails WithOptions(CallOptions options)
{
var newDetails = this;
newDetails.options = options;
return newDetails;
}
}
}