So what we'd like to have is a library that expands across many modules, and each add their own respective functionality. For example our base class.
public class Account {
public string Username;
}
Then in a separate package (let's say the ActiveDirectory
package)
public partial class Account {
public UserPrincipal Principal;
}
which would extend our Account
class to
public class Account {
public string Username;
public UserPrincipal Principal;
}
However using the partial
keyword is only supported within the same project. I also don't want to just extend Account
to an ADAccount
because other modules will want to add their own properties and methods and there isn't a structured hierarchy of classes. Extension Methods is a possibility but they are only methods and they can't store any additional data to the class.
Practical Use-Case
I'd like for a user to be able to
Install-Package BaseLibrary
and get public class Account { public string Username }
or run
Install-Package BaseLibrary
Install-Package BaseLibrary-ActiveDirectory
Install-Package BaseLibrary-Twitter
and get
public class Account {
public string Username;
public UserPrincipal Principal;
public Twitter TwitterUser;
}
How can this be done?
Although ExpandoObject
's can do this I would obviously prefer a Statically Typed option.