public static IContextLinkageOptions Convert(this ContextLinkageOptions options, IProtocolMessageFactory messageFactory) { if (options == null) { return(messageFactory.CreateContextLinkageOptions(ContextLinkageDiscoveryMode.None, Maybe <string> .Nothing)); } return(messageFactory.CreateContextLinkageOptions(options.Mode, options.SpecifiedContextId)); }
private IContextLinkageOptions ConvertFromProtoStrict(ContextLinkageOptions proto) { if (proto == null || proto.ModeCase == ContextLinkageOptions.ModeOneofCase.None) { return(_messageFactory.CreateContextLinkageOptions(ContextLinkageDiscoveryMode.None, Maybe <string> .Nothing)); } return(_messageFactory.CreateContextLinkageOptions( ConvertFromProto(proto.ModeCase), proto.ModeCase == ContextLinkageOptions.ModeOneofCase.SpecificContextId ? new Maybe <string>(proto.SpecificContextId) : Maybe <string> .Nothing)); }
public void ContextLinkageInfoIsSerializedCorrectly(ContextLinkageDiscoveryMode mode) { var serializer = SerializerFactory.Create(MessageFactory); var serviceReference = MessageFactory.CreateConsumedServiceReference("interop.testing.EchoService", Maybe <string> .Nothing); var methodReference = MessageFactory.CreateConsumedMethodReference(serviceReference, "Unary"); var contextLinkageOptions = MessageFactory.CreateContextLinkageOptions(mode, Maybe <string> .Nothing); using (var request = MessageFactory.CreateInvocationStartRequest(methodReference, contextLinkageOptions)) using (var serialized = serializer.Serialize(request)) using (var deserialized = serializer.DeserializeClientToBrokerRequest(serialized)) { deserialized.Handle(new ClientToBrokerRequestHandler <Nothing, Nothing>( (msg, _) => { msg.ContextLinkageOptions.Mode.ShouldBe(mode); return(msg.Target.Handle(new InvocationTargetHandler <Nothing, Nothing>( (target, __) => { target.MethodId.ShouldBe("Unary"); target.ConsumedService.ServiceId.ShouldBe("interop.testing.EchoService"); target.ConsumedService.ServiceAlias.ShouldBe(Maybe <string> .Nothing); return Nothing.Instance; }, (target, __) => throw new InvalidOperationException($"Unexpected target: {target}")))); }, (msg, _) => throw new InvalidOperationException($"Unexpected message: {msg}"), (msg, _) => throw new InvalidOperationException($"Unexpected message: {msg}"))); } }
private static IContextLinkageOptions CreateDefaultContextLinkageOptions(IProtocolMessageFactory messageFactory) { return(messageFactory.CreateContextLinkageOptions(ContextLinkageDiscoveryMode.None, Maybe <string> .Nothing)); }