New Posts New Posts RSS Feed: [Resolved]Services ????
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[Resolved]Services ????

 Post Reply Post Reply
Author
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Topic: [Resolved]Services ????
    Posted: 04-Oct-2007 at 2:36pm
I am trying to create a Service for some global variables that I need. The problem is that every time I try to get the data it is null.
 
Am I doing this right.
 
1. Create a class in the Foundation.Services directory. MyService
2. Added a property with get and set properties.
3. Injected the variable into the class that I want to use them

private GlobalService mGlobalService;

 

[InjectionMethod]

public void InjectController(GlobalService pGlobals)

{

mGlobalService = pGlobals;

}

Value is always null.



Edited by orcities - 05-Oct-2007 at 7:33am
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 04-Oct-2007 at 3:54pm
The service needs to be added to the root workitem's Services collection in FoundationModule.cs.
 
B.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 04-Oct-2007 at 5:08pm
I found that after a few hours of looking for the issue. Tx for getting back to me.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 05-Oct-2007 at 7:17am
I added my service to the AddFoundationServices of the FoundationModule as follows:

pServices.AddNew<GlobalService, LOC.CEMS.Interface.Services.IAppGlobalsService>();

On the module/view where I am setting the value I do the following (in a page controller):

private GlobalService mGlobalService;

 

[InjectionMethod]

public void InjectController(GlobalService pGlobals)

{

    mGlobalService = pGlobals;

}

 
In a different module I am trying to get the current value as follows (in a view presenter):

private GlobalService mGlobalService;

 

[InjectionMethod]

public void InjectController(GlobalService pGlobals)

{

   mGlobalService = pGlobals;

}

It says the value was never set. Why does it not seem to be static?

Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 05-Oct-2007 at 7:24am

My collection object wasn't static. Once I changed that it worked fine.

Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 05-Oct-2007 at 10:43am
Glad this worked out OK.
 
When you inject the service, you should use the service's interface rather than it's implementation class.  That way you can change the implementation or have different implementations in different workitems without changing the injection code.
 
B.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down