Reputation: 2714
Summary:
Is it possible to loop through each project in a certain Solution Folder and get properties from a class or interface each project has? And if so can I require each project to contain this certain class?
Explanation:
I've got a ASP.NET Web API project.
A part of this project is the API Framework for example:
This part probaply won't change much over time and if it changes it are probaply breaking changes or changes that don't influence the Api interface at all.
The other part is the API endpoints for example:
This part will change relatively often and so I would like to implement versioning. My idea is to make each new version in a new project for example:
I would like this projects to all have an Interface which I can call in the main Api project to add a new version.
For example I would like all Api.Endpoints.V*
projects to expose a (Odata) IEdmModel
property which I can loop through and register in my Main project. In code this would look something like:
Api.Endpoints.V1:
namespace Api.Endpoints.V1
{
public class DataModel
{
public Model IEdmModel { get; private set; }
public DataModel()
{
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Users>("Users");
modelBuilder.EntitySet<Relations>("Relations");
modelBuilder.EntitySet<Reactions>("Reactions");
modelBuilder.EntitySet<Likes>("Likes");
this.IEdmModel = modelBuilder.GetEdmModel();
}
}
}
Main Api project (pseudo code):
namespace Api
{
public static void Register(HttpConfiguration configuration)
{
foreach(project in VersionsFolder)
{
configuration.Routes.MapODataRoute(routeName: project.Version, routePrefix: project.Version, model: project.Model);
}
}
}
Is it possible to make these Endpoint projects confirm to a certain interface, for example always contain a class DataModel
which implements a certain Interface and loop through this in the Register Method in the Main project? Or am I going wrong here and should I solve this in another way?
Upvotes: 1
Views: 468
Reputation: 22555
There are some tools for keeping different versions, for example simple one is svn, also you can use github online, it's not good to keep different version in one solution and you should handle versionning automatically. Also I prefer to use TFS for keeping branches and different releases.
Upvotes: 2