tuongkha
Hi everybody,
I'm trying to build an example dataAdapter. I start out creating a new Project (windows application c#) in Visual Studio 2003,and copy DotNetAdapter.dll from "DOCS-SDKs\sdk_adapter_dotnet\lib\dotnet_1.1" into my directory project, add reference "DotNetAdapter.dll", and then I have created 2 class "ExternalFeed.cs", "StockList.cs" (just only copy & paste from source code demo in folder "DOCS-SDKs\sdk_adapter_dotnet\examples\DotNetStockListDemo\src_data_adapter").
There are my code :
----------------------
ExternalFeed.cs
----------------------
using System;
using System.Threading;
using System.Collections;
namespace Lightstreamer.Adapters.Data
{
/// <summary>
/// Summary description for ExternalFeed.
/// </summary>
publicclass ExternalFeed
{
/// <summary>
/// Used by the Stock List Adapter to receive data from the simulated broadcast feed in an
/// asynchronous way, through the OnEvent method.
/// </summary>
publicinterface IExternalFeedListener
{
/// <summary>
/// Called by the feed for each update event occurrence on some stock.
/// If isSnapshot is true, then the event contains a full snapshot,
/// with the current values of all fields for the stock.
/// </summary>
voidOnEvent( stringitemName, IDictionary currentValues, bool isSnapshot);
}
/// <summary>
/// Used to automatically generate the updates for the 30 stocks:
/// mean and standard deviation of the times between consecutive
/// updates for the same stock.
/// </summary>
privatedouble [] _updateTimeMeans;
privatedouble [] _updateTimeStdDevs;
/// <summary>
/// Used to generate the initial field values for the 30 stocks
/// </summary>
privatedouble [] _refprices;
privatedouble [] _openprices;
privatedouble [] _minprices;
privatedouble [] _maxprices;
privatestring [] _stockNames;
/// <summary>
/// Used to keep the contexts of the 30 stocks.
/// </summary>
private IDictionary _stockGenerators;
privateIExternalFeedListener _listener;
private IList _snapshotQueue;
private Thread _snapshotSender;
public ExternalFeed()
{
_stockGenerators= new Hashtable();
_snapshotQueue= new ArrayList();
_updateTimeMeans = newdouble [] {30000, 500, 3000, 90000,
7000, 10000, 3000, 7000,
7000, 7000, 500, 3000,
20000, 20000, 20000, 30000,
500, 3000, 90000, 7000,
10000, 3000, 7000, 7000,
7000, 500, 3000, 20000,
20000, 20000 };
...
publicclass ExternalFeedProducer
{
publicstring _itemName;
privateint _open, _refer, _last, _min, _max, _other;
privatedouble _mean, _stddev;
privatestring _stockName;
private Random _random;
privatebool _haveNextNextGaussian;
privatedouble _nextNextGaussian;
privateIExternalFeedListener _listener;
private Thread _thread;
/// <summary>
/// Initializes stock data based on the already prepared values.
/// </summary>
publicExternalFeedProducer( string name,
doubleopenPrice, doublereferPrice, doubleminPrice, double maxPrice,
doubleupdateTimeMean, doubleupdateTimeStdDev, string stockName)
{
_itemName = name;
_open = (int) Math.Round(openPrice * 100);
_refer = (int) Math.Round(referPrice * 100);
_min = (int) Math.Ceiling(minPrice * 100);
_max = (int) Math.Floor(maxPrice * 100);
_last = _open;
_mean = updateTimeMean;
_stddev = updateTimeStdDev;
_stockName = stockName;
_random = new Random();
_haveNextNextGaussian= false;
_nextNextGaussian= 0.0;
ComputeNewValues();
}
...
publicvoid SetFeedListener(IExternalFeedListener listener)
{
lock( this)
{
_listener = listener;
}
}
-------------------------
StockList.cs
-------------------------
using System;
using System.Collections;
using System.Threading;
using Lightstreamer.Interfaces.Data;
namespace Lightstreamer.Adapters.Data
{
/// <summary>
/// Summary description for StockList.
/// </summary>
publicclass StockListAdapter : IDataProvider, IExternalFeedListener
{
private IDictionary _subscribedItems;
private ExternalFeed _myFeed;
private IItemEventListener _listener;
public StockListAdapter()
{
_subscribedItems= new Hashtable();
_myFeed= new ExternalFeedSimulator();
}
// ////////////////////////////////////////////////////////////////////////
// IDataProvider methos
publicvoid Init(IDictionary parameters, string configFile)
{
_myFeed.SetFeedListener(this);
_myFeed.Start();
}
...
Now I build this application, it has error :
D:\My projects\AnalyzeStockApp\Lightstreamer.Adapters.Data\ExternalFeed.cs(218): The type or namespace name 'IExternalFeedListener' could not be found (are you missing a using directive or an assembly reference?) --> (red color line is mark)
Could anybody help me?
Dario Crivelli
Hi
I notice that, in the reported source code, the IExternalFeedListener interface is defined as an inner class of ExternalFeed. This differs from the original source code, where it is defined at top level, before the ExternalFeed(Simulator) class.
Dario