M
mp
another silly newbie question(s):
So I have a view/presenter/business layers setup
(i have a service layer too, but not sure what i'm supposed to be doing with
that...at least in this example)
i've put this togeter from examples so only half understand what i've
done...<g>
one thing i wonder about...
the presentation layer is defining an interface the view layer is deriving
from...is that the right 'layout / heirarchy'?
namespace Investments.ViewLayer
{
//IInvestmentListView interface defined in Investments.PresentationLayer
public partial class InvestmentsView : Form, IInvestmentListView
{....}
}
....also....
is the following the right place for the view to implement displaying some
information?
//a button in the view raises an event
private void btnLoadPortfolio_Click(object sender, EventArgs e)
{
if (this.LoadPortfolio != null)
{
this.LoadPortfolio(this, EventArgs.Empty);
}
}
//an object in the presenter catches the event and creates a bus.obj. to
service request
private void mView_LoadPortfolio(object sender, EventArgs e)
{
MessageBox.Show("catch event in Investment list presentation
layer");
try
{
Investments.BusinessLayer.Portfolio p = new
Investments.BusinessLayer.Portfolio();
//send data back to view to display
this.mView.StockWatchDataSource = p.StocksToWatch; //<<<<<
gets list of stock tickers from excel spreadsheet
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
throw;
}
}
//back in the view.cs
//for the view to display the info, is the *set* of the property the
"correct" place to put the implementation?
public StockListCollection StockWatchDataSource
{
set
{
//get List<string> passed into this property from presenter
StockListCollection internalCol = value;
//display list of tickers in gridview
this.grdInvestments.Columns.Add("ID", "ID");
this.grdInvestments.Columns.Add("Ticker", "Ticker");
for (int i = 0; i < internalCol.Count; i++)
{
DataGridViewRow item = new DataGridViewRow();
item.CreateCells(this.grdInvestments);
item.Cells[0].Value = i;
item.Cells[1].Value = internalCol;
this.grdInvestments.Rows.Add(item);
}
}
}
thanks
mark
So I have a view/presenter/business layers setup
(i have a service layer too, but not sure what i'm supposed to be doing with
that...at least in this example)
i've put this togeter from examples so only half understand what i've
done...<g>
one thing i wonder about...
the presentation layer is defining an interface the view layer is deriving
from...is that the right 'layout / heirarchy'?
namespace Investments.ViewLayer
{
//IInvestmentListView interface defined in Investments.PresentationLayer
public partial class InvestmentsView : Form, IInvestmentListView
{....}
}
....also....
is the following the right place for the view to implement displaying some
information?
//a button in the view raises an event
private void btnLoadPortfolio_Click(object sender, EventArgs e)
{
if (this.LoadPortfolio != null)
{
this.LoadPortfolio(this, EventArgs.Empty);
}
}
//an object in the presenter catches the event and creates a bus.obj. to
service request
private void mView_LoadPortfolio(object sender, EventArgs e)
{
MessageBox.Show("catch event in Investment list presentation
layer");
try
{
Investments.BusinessLayer.Portfolio p = new
Investments.BusinessLayer.Portfolio();
//send data back to view to display
this.mView.StockWatchDataSource = p.StocksToWatch; //<<<<<
gets list of stock tickers from excel spreadsheet
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
throw;
}
}
//back in the view.cs
//for the view to display the info, is the *set* of the property the
"correct" place to put the implementation?
public StockListCollection StockWatchDataSource
{
set
{
//get List<string> passed into this property from presenter
StockListCollection internalCol = value;
//display list of tickers in gridview
this.grdInvestments.Columns.Add("ID", "ID");
this.grdInvestments.Columns.Add("Ticker", "Ticker");
for (int i = 0; i < internalCol.Count; i++)
{
DataGridViewRow item = new DataGridViewRow();
item.CreateCells(this.grdInvestments);
item.Cells[0].Value = i;
item.Cells[1].Value = internalCol;
this.grdInvestments.Rows.Add(item);
}
}
}
thanks
mark