I have classes generated from a WCF soap service.
public partial class Job
{
public ActivityId {get;set;}
}
And written additions to the classes
public partial class Job
{
public Activity Activity
{
get
{
return *ActivityService*.Activities
.Where(x=>x.ActivityId==this.ActivityId)
.FirstOrDefault();
}
}
}
Due to the modular nature of Prism, the classes the list of Activity come from a different web service and module to what Job is generated from.
So what's the best way of populating ActivityService or is there a better approach?
Cheers
Just to note, I've taken a different approach and used a decorator pattern.
The JobService imports the ActivityService at construction and references it using a private member field. When the JobService retrieves job from the WCF service it populates the Activity using the ActivityService.
public class JobService
{
private ActivityService activityService;
public JobService(ActivityService activityService)
{
this.activityService = activityService;
}
public Job GetJob(int jobId)
{
using(Client client = new Client())
{
Job j = client.GetJob(jobId);
j.Activity = this.activityService.Activities
.Where(a=>a.ActivityId == j.ActivityId)
.FirstOrDefault();
return j;
}
}
}