I naturally model using POCO, so relationships are normally just a collection of some other type, or in the case of a 1:x a simple reference, either way, a Link normally relates two different classes, yet the built in LinkBuilder takes a single type, I therefore find my self doing the following...
LinkBuilders = new LinkBuilder[]
{
new LinkBuilder<Tuple<Project,Project>>(x => new Link
{
Source = x.Item1.Id,
Target = x.Item2.Id,
Label = "references",
}),
new LinkBuilder<Tuple<Module, Module>>(x => new Link
{
Source = x.Item1.Name,
Target = x.Item2.Name,
Label = "dependsOn",
}),
new LinkBuilder<Tuple<Module, Project>>(x => new Link
{
Source = x.Item1.Name,
Target = x.Item2.Id,
Label = "exports",
})
},
I was thinking instead to create a LinkBuilder which takes TWO types, then I can do this...
LinkBuilders = new LinkBuilder[]
{
new LinkBuilder<Project,Project>((s,t) => new Link
{
Source = s.Id,
Target = t.Id,
Label = "references",
}),
new LinkBuilder<Module, Module>((s,t)=> new Link
{
Source = s.Name,
Target = t.Name,
Label = "dependsOn",
}),
new LinkBuilder<Module, Project>((s,t) => new Link
{
Source = s.Name,
Target = t.Id,
Label = "exports",
})
},
If you want me to submit a pull request for this, please ask, the only hack it the base class has to take a single type, to which I provide "typeof(T)"