本文整理汇总了C#中Grpc.Core.Metadata类的典型用法代码示例。如果您正苦于以下问题:C# Metadata类的具体用法?C# Metadata怎么用?C# Metadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Metadata类属于Grpc.Core命名空间,在下文中一共展示了Metadata类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WithMethods
public void WithMethods()
{
var options = new CallOptions();
var metadata = new Metadata();
Assert.AreSame(metadata, options.WithHeaders(metadata).Headers);
var deadline = DateTime.UtcNow;
Assert.AreEqual(deadline, options.WithDeadline(deadline).Deadline.Value);
var cancellationToken = new CancellationTokenSource().Token;
Assert.AreEqual(cancellationToken, options.WithCancellationToken(cancellationToken).CancellationToken);
var writeOptions = new WriteOptions();
Assert.AreSame(writeOptions, options.WithWriteOptions(writeOptions).WriteOptions);
var propagationToken = new ContextPropagationToken(CallSafeHandle.NullInstance, DateTime.UtcNow,
CancellationToken.None, ContextPropagationOptions.Default);
Assert.AreSame(propagationToken, options.WithPropagationToken(propagationToken).PropagationToken);
var credentials = new FakeCallCredentials();
Assert.AreSame(credentials, options.WithCredentials(credentials).Credentials);
// Check that the original instance is unchanged.
Assert.IsNull(options.Headers);
Assert.IsNull(options.Deadline);
Assert.AreEqual(CancellationToken.None, options.CancellationToken);
Assert.IsNull(options.WriteOptions);
Assert.IsNull(options.PropagationToken);
Assert.IsNull(options.Credentials);
}
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:31,代码来源:CallOptionsTest.cs
示例2: CallOptions
/// <summary>
/// Creates a new instance of <c>CallOptions</c>.
/// </summary>
/// <param name="headers">Headers to be sent with the call.</param>
/// <param name="deadline">Deadline for the call to finish. null means no deadline.</param>
/// <param name="cancellationToken">Can be used to request cancellation of the call.</param>
public CallOptions(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
// TODO(jtattermusch): consider only creating metadata object once it's really needed.
this.headers = headers != null ? headers : new Metadata();
this.deadline = deadline.HasValue ? deadline.Value : DateTime.MaxValue;
this.cancellationToken = cancellationToken;
}
开发者ID:vanliao,项目名称:grpc,代码行数:13,代码来源:CallOptions.cs
示例3: ServerCallContext
public ServerCallContext(string method, string host, DateTime deadline, Metadata requestHeaders, CancellationToken cancellationToken)
{
this.method = method;
this.host = host;
this.deadline = deadline;
this.requestHeaders = requestHeaders;
this.cancellationToken = cancellationToken;
}
开发者ID:meisterpeeps,项目名称:grpc,代码行数:8,代码来源:ServerCallContext.cs
示例4: ServerRpcNew
public ServerRpcNew(Server server, CallSafeHandle call, string method, string host, Timespec deadline, Metadata requestMetadata)
{
this.server = server;
this.call = call;
this.method = method;
this.host = host;
this.deadline = deadline;
this.requestMetadata = requestMetadata;
}
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:9,代码来源:ServerRpcNew.cs
示例5: CreateAndDestroy
public void CreateAndDestroy()
{
var metadata = new Metadata {
new Metadata.Entry("host", "somehost"),
new Metadata.Entry("header2", "header value"),
};
var nativeMetadata = MetadataArraySafeHandle.Create(metadata);
nativeMetadata.Dispose();
}
开发者ID:hmings888,项目名称:grpc,代码行数:9,代码来源:MetadataArraySafeHandleTest.cs
示例6: CallOptions
/// <summary>
/// Creates a new instance of <c>CallOptions</c> struct.
/// </summary>
/// <param name="headers">Headers to be sent with the call.</param>
/// <param name="deadline">Deadline for the call to finish. null means no deadline.</param>
/// <param name="cancellationToken">Can be used to request cancellation of the call.</param>
/// <param name="writeOptions">Write options that will be used for this call.</param>
/// <param name="propagationToken">Context propagation token obtained from <see cref="ServerCallContext"/>.</param>
public CallOptions(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken),
WriteOptions writeOptions = null, ContextPropagationToken propagationToken = null)
{
this.headers = headers;
this.deadline = deadline;
this.cancellationToken = cancellationToken;
this.writeOptions = writeOptions;
this.propagationToken = propagationToken;
}
开发者ID:hongweiwang,项目名称:grpc,代码行数:17,代码来源:CallOptions.cs
示例7: CallOptions
/// <summary>
/// Creates a new instance of <c>CallOptions</c>.
/// </summary>
/// <param name="headers">Headers to be sent with the call.</param>
/// <param name="deadline">Deadline for the call to finish. null means no deadline.</param>
/// <param name="cancellationToken">Can be used to request cancellation of the call.</param>
/// <param name="writeOptions">Write options that will be used for this call.</param>
/// <param name="propagationToken">Context propagation token obtained from <see cref="ServerCallContext"/>.</param>
public CallOptions(Metadata headers = null, DateTime? deadline = null, CancellationToken? cancellationToken = null,
WriteOptions writeOptions = null, ContextPropagationToken propagationToken = null)
{
// TODO(jtattermusch): consider only creating metadata object once it's really needed.
this.headers = headers ?? new Metadata();
this.deadline = deadline ?? (propagationToken != null ? propagationToken.Deadline : DateTime.MaxValue);
this.cancellationToken = cancellationToken ?? (propagationToken != null ? propagationToken.CancellationToken : CancellationToken.None);
this.writeOptions = writeOptions;
this.propagationToken = propagationToken;
}
开发者ID:ELMERzark,项目名称:grpc,代码行数:18,代码来源:CallOptions.cs
示例8: Init
public void Init()
{
helper = new MockServiceHelper();
server = helper.GetServer();
server.Start();
channel = helper.GetChannel();
headers = new Metadata { { "ascii-header", "abcdefg" } };
}
开发者ID:ConfusedReality,项目名称:pkg_network_grpc,代码行数:10,代码来源:ResponseHeadersTest.cs
示例9: ServerCallContext
internal ServerCallContext(CallSafeHandle callHandle, string method, string host, DateTime deadline, Metadata requestHeaders, CancellationToken cancellationToken,
Func<Metadata, Task> writeHeadersFunc, IHasWriteOptions writeOptionsHolder)
{
this.callHandle = callHandle;
this.method = method;
this.host = host;
this.deadline = deadline;
this.requestHeaders = requestHeaders;
this.cancellationToken = cancellationToken;
this.writeHeadersFunc = writeHeadersFunc;
this.writeOptionsHolder = writeOptionsHolder;
}
开发者ID:nerdrew,项目名称:grpc,代码行数:12,代码来源:ServerCallContext.cs
示例10: ReadMetadataFromPtrUnsafe
public void ReadMetadataFromPtrUnsafe()
{
var metadata = new Metadata
{
new Metadata.Entry("host", "somehost"),
new Metadata.Entry("header2", "header value"),
};
var nativeMetadata = MetadataArraySafeHandle.Create(metadata);
var copy = MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(nativeMetadata.Handle);
Assert.AreEqual(2, copy.Count);
Assert.AreEqual("host", copy[0].Key);
Assert.AreEqual("somehost", copy[0].Value);
Assert.AreEqual("header2", copy[1].Key);
Assert.AreEqual("header value", copy[1].Value);
nativeMetadata.Dispose();
}
开发者ID:rootusr,项目名称:grpc,代码行数:19,代码来源:MetadataArraySafeHandleTest.cs
示例11: WithMethods
public void WithMethods()
{
var options = new CallOptions();
var metadata = new Metadata();
Assert.AreSame(metadata, options.WithHeaders(metadata).Headers);
var deadline = DateTime.UtcNow;
Assert.AreEqual(deadline, options.WithDeadline(deadline).Deadline.Value);
var token = new CancellationTokenSource().Token;
Assert.AreEqual(token, options.WithCancellationToken(token).CancellationToken);
// Change original instance is unchanged.
Assert.IsNull(options.Headers);
Assert.IsNull(options.Deadline);
Assert.AreEqual(CancellationToken.None, options.CancellationToken);
Assert.IsNull(options.WriteOptions);
Assert.IsNull(options.PropagationToken);
Assert.IsNull(options.Credentials);
}
开发者ID:xianglinghui,项目名称:grpc,代码行数:21,代码来源:CallOptionsTest.cs
示例12: Merge_HeaderMutationOrdering
public void Merge_HeaderMutationOrdering()
{
Action<Metadata> clearAndAddFoo = m => { m.Clear(); m.Add("foo", "bar"); };
Action<Metadata> addSample = m => m.Add("sample", "value");
CallSettings clearAndAddFooSettings = new CallSettings(null, null, null, clearAndAddFoo, null, null);
CallSettings addSampleSettings = new CallSettings(null, null, null, addSample, null, null);
var merged1 = CallSettings.Merge(clearAndAddFooSettings, addSampleSettings);
var merged2 = CallSettings.Merge(addSampleSettings, clearAndAddFooSettings);
// Original should be called first, so merged1 should end up with foo and sample;
// merged2 should end up with just foo.
var metadata = new Metadata();
merged1.HeaderMutation(metadata);
Assert.Equal(2, metadata.Count);
metadata = new Metadata();
merged2.HeaderMutation(metadata);
Assert.Equal(1, metadata.Count);
}
开发者ID:googleapis,项目名称:gax-dotnet,代码行数:21,代码来源:CallSettingsTest.cs
示例13: CloseWallet
public global::Walletrpc.CloseWalletResponse CloseWallet(global::Walletrpc.CloseWalletRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
var call = CreateCall(__Method_CloseWallet, new CallOptions(headers, deadline, cancellationToken));
return Calls.BlockingUnaryCall(call, request);
}
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs
示例14: UnaryCallAsync
public AsyncUnaryCall<global::grpc.testing.SimpleResponse> UnaryCallAsync(global::grpc.testing.SimpleRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
var call = CreateCall(__ServiceName, __Method_UnaryCall, headers, deadline);
return Calls.AsyncUnaryCall(call, request, cancellationToken);
}
开发者ID:rootusr,项目名称:grpc,代码行数:5,代码来源:TestGrpc.cs
示例15: AccountNotifications
public AsyncServerStreamingCall<global::Walletrpc.AccountNotificationsResponse> AccountNotifications(global::Walletrpc.AccountNotificationsRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
var call = CreateCall(__Method_AccountNotifications, new CallOptions(headers, deadline, cancellationToken));
return Calls.AsyncServerStreamingCall(call, request);
}
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs
示例16: StreamingOutputCall
public AsyncServerStreamingCall<global::grpc.testing.StreamingOutputCallResponse> StreamingOutputCall(global::grpc.testing.StreamingOutputCallRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
var call = CreateCall(__ServiceName, __Method_StreamingOutputCall, headers, deadline);
return Calls.AsyncServerStreamingCall(call, request, cancellationToken);
}
开发者ID:rootusr,项目名称:grpc,代码行数:5,代码来源:TestGrpc.cs
示例17: StartBtcdRpcAsync
public AsyncUnaryCall<global::Walletrpc.StartBtcdRpcResponse> StartBtcdRpcAsync(global::Walletrpc.StartBtcdRpcRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
var call = CreateCall(__Method_StartBtcdRpc, new CallOptions(headers, deadline, cancellationToken));
return Calls.AsyncUnaryCall(call, request);
}
开发者ID:tuxcanfly,项目名称:Paymetheus,代码行数:5,代码来源:ApiGrpc.cs
示例18: DivMany
public AsyncDuplexStreamingCall<global::math.DivArgs, global::math.DivReply> DivMany(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{
var call = CreateCall(__ServiceName, __Method_DivMany, headers);
return Calls.AsyncDuplexStreamingCall(call, cancellationToken);
}
开发者ID:meisterpeeps,项目名称:grpc,代码行数:5,代码来源:MathGrpc.cs
示例19: AsyncUnaryCall_EchoMetadata
public void AsyncUnaryCall_EchoMetadata()
{
var headers = new Metadata
{
new Metadata.Entry("asciiHeader", "abcdefg"),
new Metadata.Entry("binaryHeader-bin", new byte[] { 1, 2, 3, 0, 0xff }),
};
var internalCall = new Call<string, string>(ServiceName, EchoMethod, channel, headers);
var call = Calls.AsyncUnaryCall(internalCall, "ABC", CancellationToken.None);
Assert.AreEqual("ABC", call.ResponseAsync.Result);
Assert.AreEqual(StatusCode.OK, call.GetStatus().StatusCode);
var trailers = call.GetTrailers();
Assert.AreEqual(2, trailers.Count);
Assert.AreEqual(headers[0].Key, trailers[0].Key);
Assert.AreEqual(headers[0].Value, trailers[0].Value);
Assert.AreEqual(headers[1].Key, trailers[1].Key);
CollectionAssert.AreEqual(headers[1].ValueBytes, trailers[1].ValueBytes);
}
开发者ID:simonkuang,项目名称:grpc,代码行数:22,代码来源:ClientServerTest.cs
示例20: Sum
public AsyncClientStreamingCall<global::math.Num, global::math.Num> Sum(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{
var call = CreateCall(__ServiceName, __Method_Sum, headers);
return Calls.AsyncClientStreamingCall(call, cancellationToken);
}
开发者ID:meisterpeeps,项目名称:grpc,代码行数:5,代码来源:MathGrpc.cs
注:本文中的Grpc.Core.Metadata类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论