How to set parameter on Interface?

  • Thread starter Thread starter Mr. Arnold
  • Start date Start date
M

Mr. Arnold

public interface IDefaultView

{

DataTable BrokenRules { set; }

DataTable TableContext { get; set; }

List<Department> ObjectContext { get; set; }

event EventHandler<EventArgs> GetDepartments;

event EventHandler<EventArgs> Save;

}



The class that's using the Interface.

public class DefaultEditorPresenter

{

private readonly IDefaultView mView;

private readonly IDepartmentService mService;

public DefaultEditorPresenter(IDefaultView view, IDepartmentService service)

{

mView = view;

mService = service;

Initialize();

}

private void Initialize()

{

mView.GetDepartments += new EventHandler<EventArgs>(mView_GetDepartments);

mView.Save += new EventHandler<EventArgs>(mView_Save);

}



The method that is having the trouble.

private void mView_GetDepartments(object sender, EventArgs e)

{

try

{

var depts = mService.GetDepartments();

mView.ObjectContext = depts;

}

catch (Exception ex)

{

throw ex;

}

}

I have tried what I know to get mView.ObjectContext to be populated. The
problem is that I cannot set mView.ObjectContext = depts, as
mView.ObjectContext is *null* after the set is done.

I was able to do this when the Presenter referenced the BLL directly to
execute List<Department> GetDepartments and the definition was Object
ObjectContext { get; set; }, and I had no problem doing this.

But now that this ServiceController has been introduced, I can't set
mView.ObjectContext, period.

Is there a way to get it set? I am pissed-off about this to get all of this
in place and hit this snag.

What I really want is that the UI have no reference to the BLL, which I
could achieve when it was Object. Now am forced to make reference to
List<Department> at the UI.
 
Mr. Arnold said:
I have tried what I know to get mView.ObjectContext to be populated. The
problem is that I cannot set mView.ObjectContext = depts, as
mView.ObjectContext is *null* after the set is done.

I was able to do this when the Presenter referenced the BLL directly to
execute List<Department> GetDepartments and the definition was Object
ObjectContext { get; set; }, and I had no problem doing this.

But now that this ServiceController has been introduced, I can't set
mView.ObjectContext, period.

Is there a way to get it set? I am pissed-off about this to get all of
this
in place and hit this snag.

What I really want is that the UI have no reference to the BLL, which I
could achieve when it was Object. Now am forced to make reference to
List<Department> at the UI.

Well, the solution was to use an ArrayList on all layers of the Model View
Presenter N-tier solution to hold the Department objects.
The second part of the solution was to give ObjectContext a dummyarraylist
holding one object in it on the Interface, to get ObjectContext initialized.

With that being done and making the call to the Presenter. ObjectContext had
one object in it and ServiceController's GetDepartments had something to do
a set against, since ObjectContext was not null.


if (this.IsPostBack)

{

ObjContext = (ArrayList)Session["ObjContext"];

TblContext = (DataTable)Session["TblContext"];

}

else

{

dummyarraylst.Add("dummy"); //give it a dummy object

ObjContext = dummyarraylst;

Session["ObjContext"] = ObjContext;

GetTheDepartments();

}


Session["ObjContext"] = ObjContext;

Session["TblContext"] = TblContext;

}
 
Back
Top