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
         });
     }
 }
示例#2
0
        public ClientServiceProxy(InterfaceInfoProvider interfaceInfo, Dictionary <Type, ISerializer> serializers, List <ClientStreamingInfo> streamingCallbacks)
        {
            var streamers = streamingCallbacks.ToDictionary(info => info.Type, info => info.Callback);

            _streamingCallbacks = streamers;
            _messageBuilder     = new ClientMessageBuilder(interfaceInfo, serializers, streamingCallbacks);
        }
        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;
        }
示例#4
0
        public ClientServiceContainer(
            string host,
            int port,
            List <Type> remoteInterfaces,
            Dictionary <Type, ISerializer> serializers,
            List <ClientStreamingInfo> networkStreamingAdapters)
        {
            var interfaceInfoProvider = new InterfaceInfoProvider(remoteInterfaces);
            var generator             = new ClientProxyGenerator(interfaceInfoProvider);
            var proxies = generator.Generate();

            _serviceProxy = new ClientServiceProxy(interfaceInfoProvider, serializers, networkStreamingAdapters);

            var streamingAdapters = networkStreamingAdapters.Select(info => info.Adapter).OfType <ClientProxyBase>();
            var rpcProxies        = proxies.OfType <ClientProxyBase>();

            foreach (var proxy in rpcProxies.Concat(streamingAdapters))
            {
                proxy.ServiceProxy = _serviceProxy;
            }

            _services = remoteInterfaces.Zip(proxies, Tuple.Create)
                        .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2);

            _serviceProxy.Connect(host, port);
        }
示例#5
0
        public ServiceContainer(int port, Dictionary <Type, object> services, Dictionary <Type, ISerializer> serializers, Dictionary <string, DelegateContract> streamingContracts)
        {
            _services           = services;
            _streamingContracts = streamingContracts;
            var networkAdapterServices = streamingContracts
                                         .Select(pair => new NetworkAdapterService(pair.Key, pair.Value)).ToList();

            _networkAdapters = networkAdapterServices
                               .ToDictionary(service => service.StreamingType);
            _networkListener = new NetworkListener(this, this);
            var interfaceInfoProvider = new InterfaceInfoProvider(services.Keys.ToList());

            _messageBuilder = new ServiceMessageBuilder(interfaceInfoProvider, new DefaultSerializer(), serializers, networkAdapterServices);
            Init(port);
        }
示例#6
0
 public ClientProxyGenerator(InterfaceInfoProvider infoProvider, string componentName)
 {
     _componentName = componentName;
     _interfaces    = infoProvider.Services;
     _infoProvider  = infoProvider.GetServiceCallInfos().ToDictionary(info => Tuple.Create(info.Type, info.Method));
 }
示例#7
0
 public ClientProxyGenerator(InterfaceInfoProvider infoProvider)
     : this(infoProvider, "__" + Guid.NewGuid().ToString("N"))
 {
 }