How to override an internal function
How 开发者_如何学运维can i override a virtual internal function using reflection?
I have an abstract class in a sharepoint assembly (SPIisWebServiceApplication) that i want to implement.
In my logic i'm obligated to override the IisApplicationName property that i can see it using reflector it is writen like below:
internal virtual string IisApplicationName { get { return base.Id.ToString("N"); } }
it is only internal it is not protected...
I don't want the IisApplicationName to be an id because it appears in the IIS. I want to override it as they have done in other internal implementers.
Reflection is about accessing the structure of existing types, not changing it. (You can change the data stored in instances of types, but you can't change the structure of the type itself.)
It's not clear what you're trying to do, but reflection is unlikely to help you if you're trying to override a member.
You can derive from the class normally and override the function, which is presumably protected virtual internal
(private
cannot be virtual
, and it would not need to be internal
if it were public
). Such an access specification allows the access model of both interal
and protected
-- i.e., the method can be accessed from classes in the same assembly and from derived classes.
Is there something that prevents you from doing this?
精彩评论