/// <summary> /// Creates the new regional book instance /// </summary> /// <remarks> /// Don't call this constructor inside any listeners and callbacks of NativeSubscription, NativeConnection, /// NativeRegionalBook, NativeSnapshotSubscription classes /// </remarks> /// <param name="connection">The current connection</param> /// <param name="symbol">The book symbol</param> /// <param name="bookListener">The book listener implementation</param> /// <param name="quoteListener">The quote listener implementation</param> /// <exception cref="ArgumentException"></exception> public NativeRegionalBook(NativeConnection connection, string symbol, IDxRegionalBookListener bookListener, IDxQuoteListener quoteListener) { if (string.IsNullOrWhiteSpace(symbol)) { throw new ArgumentException("Invalid symbol parameter."); } this.bookListener = bookListener; this.quoteListener = quoteListener; if (bookListener == null && quoteListener == null) { return; } C.CheckOk(C.Instance.dxf_create_regional_book(connection.Handle, symbol, out bookHandle)); try { if (this.bookListener != null) { C.CheckOk(C.Instance.dxf_attach_regional_book_listener(bookHandle, nativeBookListener = OnBook, IntPtr.Zero)); } if (this.quoteListener != null) { C.CheckOk(C.Instance.dxf_attach_regional_book_listener_v2(bookHandle, nativeQuoteListener = OnQuote, IntPtr.Zero)); } } catch (DxException) { C.Instance.dxf_close_regional_book(bookHandle); throw; } }
/// <summary> /// Creates a regional book /// </summary> /// <remarks> /// Don't call this method inside any listeners and callbacks of NativeSubscription, NativeConnection, /// NativeRegionalBook, NativeSnapshotSubscription classes /// </remarks> /// <param name="symbol">Single symbol name</param> /// <param name="bookListener">Regional book changes listener. Null is allowed.</param> /// <param name="quoteListener">Quotes listener. Null is allowed.</param> /// <returns>regional book object</returns> public IDxRegionalBook CreateRegionalBook(string symbol, IDxRegionalBookListener bookListener, IDxQuoteListener quoteListener) { return(new NativeRegionalBook(this, symbol, bookListener, quoteListener)); }