/// <summary> /// Called when the adapter is writing. /// </summary> /// <param name="data">The data.</param> protected override void OnWrite(byte[] data) { if (IsAsync) { Task.Factory.StartNew(() => { InMemoryAdaptersManager.Write(this, data); }); } else { InMemoryAdaptersManager.Write(this, data); } }
/// <summary> /// Detach all registered In-Memory adapters. /// </summary> public static void DisposeAll() { InMemoryAdaptersManager.Reset(); }
/// <summary> /// Called when the adapter is disconnecting. /// </summary> /// <returns></returns> protected override Task OnDisconnect() { InMemoryAdaptersManager.UnregisterAdapter(this); return(Task.FromResult(true)); }
/// <summary> /// Initializes a new instance of the <see cref="InMemoryAdapter"/> class. /// </summary> /// <param name="address">The address.</param> public InMemoryAdapter(String address) : base() { Address = address; InMemoryAdaptersManager.RegisterAdapter(this); }