I'm using interfaces for unit testing in my project. My interface have functions as well as properties. I will be creating the object of interface class at the app startup as dependency and will be using throughout the application life cycle. Is it possible to re-instantiate the class pointing to interface on run time with the underlying type?
For example. This is what i do at app startup.
IPerson iperson = new Person();
Now once my API's are getting called i want to reinstatement this object again as per business logic. So again in my API logic how would i know what object type my interface is pointing to? Can i do something like this
// Type could be anything like Person,Person1,Person2 as all these classes implementing IPerson
Type p = iperson.Type
iperson = new p();