Let's say I have a class ClassWhichDoesThings which makes various calls to methods such as
DoSomething<TheTypeIWantToSpecifyOnce>();
DoAnotherThing<TheTypeIWantToSpecifyOnce>();
AndAnother<TheTypeIWantToSpecifyOnce>();
throughout the class.
Is it possible to specify the generic type in one place (like a variable but not determined at runtime) without anything outside of the class having to also pass a generic type (avoiding ClassWhichDoesThings<T>) such that the method calls become something like:
Type WriteTypeOnce = typeof(TheTypeIWantToSpecifyOnce);
DoSomething<WriteTypeOnce>();
DoAnotherThing<WriteTypeOnce>();
AndAnother<WriteTypeOnce>();
The objective here being that if I want to change the Type, I don't have to do a find and replace on 20 different method calls for example.
Essentially I want a generic class which specifies its own generic type privately.
Edit: In other words, I'm trying to better organise code which is completely private to a class but focuses on dealing with a single Type. For example, let's say I wanted to add the method:
public TheTypeIWantToSpecifyOnce CreateAThing(string input){ ... }
I want it to be very clear that this class focuses on TheTypeIWantToSpecifyOnce or T so that it's easy to write another method with T but without T being specified when creating the class...