It would be really nice if I could do something like a generic "typedef" using the syntax below.
I really like how this allows me to progressively specify type parameters to a class in a more readable fashion, however, I don't like that my final types end up being a "WithDriver" or a "WithLaser". Any suggestions or ideas?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication17 {
class Program {
static void Main(string[] args) {
var C = new Spaceship
.WithDriver<int>
();
var D = new Spaceship
.WithEngine<String>
.WithLasers<long>
();
}
}
public class Spaceship : Spaceship<object, object, object> { }
public class Spaceship<TDriver, TEngine, TLasers> {
public class WithDriver<TNewDriver> : Spaceship<TNewDriver, TEngine, TLasers> {
}
public class WithEngine<TNewEngine> : Spaceship<TDriver, TNewEngine, TLasers> {
}
public class WithLasers<TNewLasers> : Spaceship<TDriver, TEngine, TNewLasers> {
}
}
}