/// <summary> /// Dispose implementation which ensures the native window is destroyed, and /// managed resources detached. /// </summary> private void Dispose(bool disposeManaged) { if (!disposed) { disposed = true; if (disposeManaged) { if (networkRelay != null) { networkRelay.Dispose(); networkRelay = null; } if (MessageReceived != null) { // remove all handlers Delegate[] del = MessageReceived.GetInvocationList(); foreach (XDMessageHandler msg in del) { MessageReceived -= msg; } } if (this.Handle != IntPtr.Zero) { this.DestroyHandle(); this.Dispose(); } } } }
/// <summary> /// Default constructor. /// </summary> internal XDIOStreamListener() { this.watcherList = new Dictionary<string, FileSystemWatcher>(StringComparer.InvariantCultureIgnoreCase); // ensure there is a network watcher for this mode, the implementation ensures only one is active at // any one time this.networkRelay = new NetworkRelayListener(XDBroadcast.CreateBroadcast(XDTransportMode.IOStream), XDListener.CreateListener(XDTransportMode.MailSlot)); }
/// <summary> /// Default constructor. /// </summary> internal XDIOStreamListener() { this.watcherList = new Dictionary <string, FileSystemWatcher>(StringComparer.InvariantCultureIgnoreCase); // ensure there is a network watcher for this mode, the implementation ensures only one is active at // any one time this.networkRelay = new NetworkRelayListener(XDBroadcast.CreateBroadcast(XDTransportMode.IOStream), XDListener.CreateListener(XDTransportMode.MailSlot)); }
/// <summary> /// The non-obsolete constructor used internally for creating new instances of XDListener. /// </summary> /// <param name="nonObsolete"></param> internal XDListener(bool nonObsolete) { // create a top-level native window CreateParams p = new CreateParams(); p.Width = 0; p.Height = 0; p.X = 0; p.Y = 0; p.Caption = string.Concat("TheCodeKing.Net.XDServices.", Guid.NewGuid().ToString()); p.Parent = IntPtr.Zero; base.CreateHandle(p); this.networkRelay = new NetworkRelayListener(XDBroadcast.CreateBroadcast(XDTransportMode.WindowsMessaging), XDListener.CreateListener(XDTransportMode.MailSlot)); }
public IXDListener GetListenerForMode(XDTransportMode transportMode) { var listener = GetListenerForModeInternal(transportMode); if (transportMode == XDTransportMode.RemoteNetwork) { return(listener); } var networkListener = CreateNetworkListener(new MachineNameIdentityProvider()); if (networkListener == null || !networkListener.IsAlive) { return(listener); } var networkBroadcaster = client.Broadcasters.GetBroadcasterForMode(transportMode); listener = new NetworkRelayListener(networkBroadcaster, listener, networkListener, transportMode); return(listener); }
public IXDListener GetListenerForMode(XDTransportMode transportMode) { var listener = Container.Resolve <IXDListener>(Convert.ToString(transportMode)); if (listener == null) { throw new NotSupportedException( string.Format( "No concrete IXDListener for mode {0} could be loaded. Install the {0} assembly in the program directory.", transportMode)); } if (transportMode != XDTransportMode.RemoteNetwork) { var networkListener = Container.Use <IIdentityProvider, MachineNameIdentityProvider>() .Resolve <IXDListener>(Convert.ToString(XDTransportMode.RemoteNetwork)); if (networkListener != null && networkListener.IsAlive) { var networkBroadcaster = client.Broadcasters.GetBroadcasterForMode(transportMode, false); listener = new NetworkRelayListener(networkBroadcaster, listener, networkListener, transportMode); } } return(listener); }
/// <summary> /// Dispose implementation, which ensures the native window is destroyed /// </summary> private void Dispose(bool disposeManaged) { if (!disposed) { disposed = true; if (disposeManaged) { if (networkRelay != null) { networkRelay.Dispose(); networkRelay = null; } if (MessageReceived != null) { // remove all handlers Delegate[] del = MessageReceived.GetInvocationList(); foreach (TheCodeKing.Net.Messaging.XDListener.XDMessageHandler msg in del) { MessageReceived -= msg; } } if (watcherList != null) { // shut down watchers foreach (FileSystemWatcher watcher in watcherList.Values) { watcher.EnableRaisingEvents = false; watcher.Changed -= new FileSystemEventHandler(OnMessageReceived); watcher.Dispose(); } watcherList.Clear(); watcherList = null; } } } }