public ServiceMessageBuilder(InterfaceInfoProvider infoProvider, ISerializer defaultSerializer, Dictionary <Type, ISerializer> serializers, List <NetworkAdapterService> services)
        {
            _infoProvider = infoProvider.GetServiceCallInfos().ToDictionary(info => Tuple.Create(info.ShortTypeName, info.ShortMethodName));
            foreach (var service in services)
            {
                _infoProvider.Add(Tuple.Create(service.StreamingType, NetworkAdapterService.SubSignature), new ServiceCallInfo
                {
                    Type            = typeof(NetworkAdapterService),
                    Await           = true,
                    Method          = typeof(NetworkAdapterService).GetMethod("Subscribe"),
                    ArgumentTypes   = new [] { service.GetArgumentType().MakeArrayType() },
                    ReturnType      = typeof(bool[]),
                    ShortMethodName = NetworkAdapterService.SubSignature,
                    ShortTypeName   = service.StreamingType,
                    StreamingCall   = true
                });

                _infoProvider.Add(Tuple.Create(service.StreamingType, NetworkAdapterService.UnsubSignature), new ServiceCallInfo
                {
                    Type            = typeof(NetworkAdapterService),
                    Await           = true,
                    Method          = typeof(NetworkAdapterService).GetMethod("Unsubscribe"),
                    ArgumentTypes   = new [] { service.GetArgumentType().MakeArrayType() },
                    ReturnType      = typeof(bool[]),
                    ShortMethodName = NetworkAdapterService.SubSignature,
                    ShortTypeName   = service.StreamingType,
                    StreamingCall   = true
                });
            }
            _serializers       = serializers;
            _defaultSerializer = defaultSerializer;
        }
 public ClientMessageBuilder(InterfaceInfoProvider interfaceInfo, Dictionary <Type, ISerializer> serializers,
                             List <ClientStreamingInfo> streamingCallbacks)
 {
     _defaultSerializer = new DefaultSerializer();
     _serializers       = serializers;
     _methodInfos       = interfaceInfo.GetServiceCallInfos()
                          .ToDictionary(info => Tuple.Create(info.ShortTypeName, info.ShortMethodName));
     foreach (var streamingCallback in streamingCallbacks)
     {
         var adapterType = streamingCallback.Adapter.GetType();
         _methodInfos.Add(Tuple.Create(streamingCallback.Type, SubSignature), new ServiceCallInfo
         {
             Type            = adapterType,
             Method          = adapterType.GetMethod("Subscribe", new [] { streamingCallback.KeyType.MakeArrayType() }),
             ArgumentTypes   = new [] { streamingCallback.KeyType.MakeArrayType() },
             Await           = true,
             ReturnType      = typeof(bool[]),
             ShortMethodName = SubSignature,
             ShortTypeName   = streamingCallback.Type,
             StreamingCall   = false
         });
         _methodInfos.Add(Tuple.Create(streamingCallback.Type, UnsubSignature), new ServiceCallInfo
         {
             Type            = adapterType,
             Method          = adapterType.GetMethod("Unsubscribe", new [] { streamingCallback.KeyType.MakeArrayType() }),
             ArgumentTypes   = new [] { streamingCallback.KeyType.MakeArrayType() },
             Await           = true,
             ReturnType      = typeof(bool[]),
             ShortMethodName = UnsubSignature,
             ShortTypeName   = streamingCallback.Type,
             StreamingCall   = false
         });
     }
 }
示例#3
0
 public ClientProxyGenerator(InterfaceInfoProvider infoProvider, string componentName)
 {
     _componentName = componentName;
     _interfaces    = infoProvider.Services;
     _infoProvider  = infoProvider.GetServiceCallInfos().ToDictionary(info => Tuple.Create(info.Type, info.Method));
 }