Beispiel #1
0
        public static ProxyItem Build <TService>(Int16 remoteObjectID, IDataSender sender)
        {
            System.Diagnostics.Debug.Assert(typeof(TService).IsInterface);
            var proxy = new ProxyItem(typeof(TService), remoteObjectID, sender);

            System.Diagnostics.Debug.Assert(typeof(TService).IsAssignableFrom(proxy.Proxy.GetType()));
            return(proxy);
        }
Beispiel #2
0
 public TService CacheProxy <TService>(Int16 remoteObjectID, IDataSender sender)
 {
     lock (_items)
     {
         if (!_items.TryGetValue(remoteObjectID, out ProxyItem item))
         {
             item = ProxyItem.Build <TService>(remoteObjectID, sender);
             _items.Add(item.RemoteObjectID, item);
             _orderedItems.AddFirst(item); //�´����ķ���ǰ��
         }
         return((TService)item.Proxy);
     }
 }
Beispiel #3
0
 public IProxy CreateProxy(ProxyItem proxyItem)
 {
     lock (_lock)
     {
         var serviceType = proxyItem.InterfaceType;
         if (!_factoryMethods.TryGetValue(serviceType.FullName, out MethodInfo factoryMethod))
         {
             factoryMethod = GenerateProxyFactory(serviceType);
             _factoryMethods[serviceType.FullName] = factoryMethod;
         }
         var proxy = factoryMethod.Invoke(null, new object[] { proxyItem });
         return((IProxy)proxy);
     }
 }