@@ -82,7 +82,7 @@ ValueTask<Stream> IMarketDataStorageDrive.LoadStreamAsync(DateTime date, bool re
8282 /// </summary>
8383 public static readonly string DefaultTargetCompId = "StockSharpHydraMD" ;
8484
85- private readonly IMessageAdapter _adapter ;
85+ private readonly Lazy < IMessageAdapter > _adapter ;
8686
8787 /// <summary>
8888 /// Initializes a new instance of the <see cref="RemoteMarketDataDrive"/>.
@@ -97,7 +97,7 @@ public RemoteMarketDataDrive()
9797 /// </summary>
9898 /// <param name="address">Server address.</param>
9999 public RemoteMarketDataDrive ( EndPoint address )
100- : this ( address , ServicesRegistry . AdapterProvider . CreateTransportAdapter ( new IncrementalIdGenerator ( ) ) )
100+ : this ( address , ( ) => ServicesRegistry . AdapterProvider . CreateTransportAdapter ( new IncrementalIdGenerator ( ) ) )
101101 {
102102 }
103103
@@ -107,8 +107,13 @@ public RemoteMarketDataDrive(EndPoint address)
107107 /// <param name="address">Server address.</param>
108108 /// <param name="adapter">Message adapter.</param>
109109 public RemoteMarketDataDrive ( EndPoint address , IMessageAdapter adapter )
110+ : this ( address , adapter is null ? throw new ArgumentNullException ( nameof ( adapter ) ) : ( ) => adapter )
110111 {
111- _adapter = adapter ?? throw new ArgumentNullException ( nameof ( adapter ) ) ;
112+ }
113+
114+ private RemoteMarketDataDrive ( EndPoint address , Func < IMessageAdapter > adapterFactory )
115+ {
116+ _adapter = new ( adapterFactory ?? throw new ArgumentNullException ( nameof ( adapterFactory ) ) ) ;
112117 Address = address ?? throw new ArgumentNullException ( nameof ( address ) ) ;
113118 }
114119
@@ -215,7 +220,7 @@ public override string Path
215220
216221 private RemoteStorageClient CreateClient ( )
217222 {
218- var adapter = _adapter ;
223+ var adapter = _adapter . Value ;
219224
220225 if ( adapter is IAddressAdapter < EndPoint > addressAdapter )
221226 addressAdapter . Address = Address ;
0 commit comments