Reputation: 51114
I have just been refactoring nearly all classes in my Services layer to inherit from a ServiceBase
, to reduce duplication in initializing data access and other aspects identical to nearly all services, but I was stopped in my tracks when I reached my RoleService
, as it has to inherit from RoleProvider
so that I can configure it as my web site's 'official' role provider.
Now it is a bit late at night, and the caffeine is on form, but I was wondering if there was any way to use a dynamic object in place of a derived object, and add all the members of the base object to the 'derived' object, at runtime, instead of compile time.
Is this even remotely possible?
Upvotes: 8
Views: 1178
Reputation: 34250
No, DynamicObject
does not allow you derive from two concrete classes, which is what multiple inheritance is, and which C# does not support. The problem you face is the same either way, dynamic or static. If you have Base1
and Base2
that are unrelated to each other, then as soon as you derive Derived
from Base1
, there is no way that that Derived is Base2
can ever be true. Instead you can settle for Derived is IBase2
.
I recommend that you use the:
together with multiple interfaces or one concrete derivation and one interface. To simulate multiple inheritance you:
This limits the amount of code in your implementing class to just one forwarding call per interface method or property.
Upvotes: 3
Reputation: 918
Dunno if you really need to go through the trouble at the class level, but here are some resources that might be helpful for setting up your Role provider as a WCF Service:
http://msdn.microsoft.com/en-us/library/aa702542.aspx
edit---- Also it was mentioned in this post here: Can I create a custom roleprovider through a WCF service?
Upvotes: 1