class O2GGenericTableResponseReader
Brief
The class provides methods to read a stream of trading table rows coming from the trading server.
Details
The O2GGenericTableResponseReader is a generic class that provides
methods to read responses to requests for initial trading tables information.
The O2GGenericTableResponseReader can be used to process the contents of the following response types:
GetOffers, GetAccounts,
GetTrades, GetClosedTrades,
GetOrders, and GetMessages.
You can not create an instance of the class directly. You can only use the methods of the class on the following subclasses:
O2GOffersTableResponseReader
O2GAccountsTableResponseReader
O2GTradesTableResponseReader
O2GClosedTradesTableResponseReader
O2GOrdersTableResponseReader
O2GMessagesTableResponseReader
O2GTable.
Note: The O2GTable class is available only when your application uses the O2GTableManager.
The usage of the O2GTable class is similar to the usage of the O2GGenericTableResponseReader class: it can not be instantiated directly and you can use its methods
only on the following subclasses:
O2GOffersTable
O2GAccountsTable
O2GTradesTable
O2GClosedTradesTable
O2GOrdersTable
O2GMessagesTable
O2GSummaryTable
If initial trading table information is received as a response to the
O2GLoginRules.getTableRefreshResponse request, you can process the response in
the main thread of your program.
If initial trading table information is received as a response to the
O2GRequestFactory.createRefreshTableRequest, you must process the response in
your implementation of the IO2GResponseListener.onRequestCompleted method.
Get initial accounts and trades information [hide]
// Get accounts information
public static void getAccounts(O2GSession session, ResponseListener responseListener)
{
try
{
O2GLoginRules loginRules = session.getLoginRules();
if (loginRules != null && loginRules.isTableLoadedByDefault(O2GTableType.Accounts))
{
O2GResponse accountsResponse = loginRules.getTableRefreshResponse(O2GTableType.Accounts);
O2GResponseReaderFactory responseFactory = session.getResponseReaderFactory();
O2GAccountsTableResponseReader accountsReader = responseFactory.createAccountsTableReader(accountsResponse);
useGenericReader(accountsReader);
}
else
{
O2GRequestFactory requestFactory = session.getRequestFactory();
if (requestFactory != null)
{
O2GRequest request = requestFactory.createRefreshTableRequest(O2GTableType.Accounts);
responseListener.RequestID = request.RequestID;
session.sendRequest(request);
Thread.Sleep(1000);
}
}
}
catch (Exception e)
{
Console.WriteLine("Exception in getAccounts(). " + e.Message);
}
}
// Get trades information
public static void getTrades(O2GSession session, ResponseListener responseListener)
{
try
{
O2GLoginRules loginRules = session.getLoginRules();
if (loginRules != null && loginRules.isTableLoadedByDefault(O2GTableType.Trades))
{
O2GResponse tradesResponse = loginRules.getTableRefreshResponse(O2GTableType.Trades);
O2GResponseReaderFactory responseFactory = session.getResponseReaderFactory();
O2GTradesTableResponseReader tradesReader = responseFactory.createTradesTableReader(tradesResponse);
useGenericReader(tradesReader);
}
else
{
O2GRequestFactory requestFactory = session.getRequestFactory();
if (requestFactory != null)
{
O2GRequest request = requestFactory.createRefreshTableRequest(O2GTableType.Trades);
responseListener.RequestID = request.RequestID;
session.sendRequest(request);
Thread.Sleep(1000);
}
}
}
catch (Exception e)
{
Console.WriteLine("Exception in getTrades(). " + e.Message);
}
}
// Use generic reader
public static void useGenericReader(O2GGenericTableResponseReader genericReader)
{
int columnsCount = 0;
Console.WriteLine("This is a response to your " + genericReader.Type + " table refresh request.");
O2GTableColumnCollection columns = genericReader.Columns;
columnsCount = columns.Count;
for (int j = 0; j < columnsCount; j++)
{
O2GTableColumn column = columns[j];
Console.WriteLine("" + column.ID + " " + column.ColumnType);
for (int i = 0; i < genericReader.Count; i++)
{
Object value = genericReader.getCell(i, j);
Console.WriteLine("Value: " + value);
}
}
}
// Implementation of IO2GResponseListener interface public method onRequestCompleted
public void onRequestCompleted(String requestID, O2GResponse response)
{
int columnsCount = 0;
O2GGenericTableResponseReader reader = null;
if (requestID.Equals(mRequestID))
{
O2GResponseReaderFactory readerFactory = mSession.getResponseReaderFactory();
if (readerFactory != null)
{
switch (response.Type)
{
case O2GResponseType.GetAccounts:
reader = readerFactory.createAccountsTableReader(response);
break;
case O2GResponseType.GetTrades:
reader = readerFactory.createTradesTableReader(response);
break;
}
Console.WriteLine("This is a response to your " + reader.Type + " request.");
O2GTableColumnCollection columns = reader.Columns;
columnsCount = columns.Count;
for (int j = 0; j < columnsCount; j++)
{
O2GTableColumn column = columns[j];
Console.WriteLine("" + column.ID + " " + column.ColumnType);
for (int i = 0; i < reader.Count; i++)
{
Object value = reader.getCell(i, j);
Console.WriteLine("Value: " + value);
}
}
}
}
}
The type defined in the fxcore2.dll assembly.
The namespace is fxcore2.
| Public Properties | |
|
Gets an instance of the class that provides access to the list of table columns. |
|
|
Gets the number of rows in the reader. |
|
|
Gets the type of a trading table. |
|
| Public Methods | |
|
Gets the value of a cell. |
|
|
Gets a generic row by its index. |
|
|
Checks whether the cell value can be used or not. |
|