示例#1
0
 /// <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);
     }
 }
示例#2
0
 /// <summary>
 /// Detach all registered In-Memory adapters.
 /// </summary>
 public static void DisposeAll()
 {
     InMemoryAdaptersManager.Reset();
 }
示例#3
0
 /// <summary>
 /// Called when the adapter is disconnecting.
 /// </summary>
 /// <returns></returns>
 protected override Task OnDisconnect()
 {
     InMemoryAdaptersManager.UnregisterAdapter(this);
     return(Task.FromResult(true));
 }
示例#4
0
 /// <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);
 }