Esempio n. 1
0
 public ProxyRecord(CpDevice aDevice, CountedReference<T> aRef)
 {
     Device = aDevice;
     iRef = aRef;
 }
Esempio n. 2
0
 public void DeviceAdded(CpDevice aDevice)
 {
     string udn = aDevice.Udn();
     Logger.DebugFormat("DeviceAdded: UDN={0}", udn);
     CountedReference<T> newProxyRef = new CountedReference<T>(iProxyConstructor(aDevice));
     aDevice.AddRef();
     ProxyRecord newProxyRecord = new ProxyRecord(aDevice, newProxyRef);
     ProxyRecord oldProxyRecord = null;
     EventHandler<ProxyEventArgs> handler;
     lock (iProxiesByUdn)
     {
         if (iProxiesByUdn.ContainsKey(udn))
         {
             oldProxyRecord = iProxiesByUdn[udn];
         }
         iProxiesByUdn[aDevice.Udn()] = newProxyRecord;
         handler = DeviceDetectedHandler;
         Monitor.PulseAll(iProxiesByUdn);
     }
     if (oldProxyRecord != null)
     {
         oldProxyRecord.InvokeDisappeared();
         oldProxyRecord.Ref.Dispose();
         oldProxyRecord.Device.RemoveRef();
     }
     if (handler != null)
     {
         handler(this, new ProxyEventArgs(aDevice, newProxyRef, newProxyRecord));
     }
 }
Esempio n. 3
0
 internal ProxyEventArgs(CpDevice aDevice, CountedReference<T> aProxyRef, IDeviceDisappearanceWatcher aDisappearanceWatcher)
 {
     Device = aDevice;
     ProxyRef = aProxyRef;
     DisappearanceWatcher = aDisappearanceWatcher;
 }