I have the following project structure:
- Api Project: Contains the WCF svc endpoints
- ClientServer Library Project: Contains the classes that are used by the server
What I want to do is distribute my ClientServer library as an all encompassing API wrapper that clients can use to connect to the API and pull information.
As the API uses the types defined in the ClientServer Library I would have hoped that adding a ServiceReference in the ClientServer Library would understand that the API return types are actually from the same library as the references will be.
The reason I am doing this is so that I only have to define the classes that get sent to and from the server in one place but also provide an "in-built" mechanism for clients to use the API without any knowledge of how it connects and without and additional depenency librarys (such as a dedicated model library).
Below is a basic example of how I wish it to work:
ClientServer Library:
public class Person {
public string Name { get; set; }
public int Age { get; set; }
.....
}
[ServiceContract]
public interface IPeopleService {
[OperationContract]
public Person[] Find(Person person);
}
Api Project
public class PeopleService : ClientServerLibrary.IPeopleServer {
public ClientServerLibrary.Person Find(ClientServerLibrary.Person person) {
// implementation for finding people based on the input person criteria.
}
}
Given the example above I want to add a reference to the PeopleService into the ClientServer library so that people who use my library can do something along the lines of:
PeopleServiceClient people = new PeopleServiceClient() // Generated from the service references
// Here "Person" needs to be of type ClientServerLibrary.Person
Person person = people.Find(new Person() { Name = "Gary" });
But currently its regenerating all the classes. I have tried ticking and unticking all the options in the "Add Service Dialogue" but its always the same result.
Hope I have explained my intentions well? Thanks.
EDIT: All projects are using C# .NET v4 so no discrepancies there.