日期:2014-05-17  浏览次数:21025 次

子类直接调用父类中的抽象方法
我反编译了一下IIS7的url rewrite module的dll文件,想从源代码中找一些关于IIS7 rewrite设置操作的方法。

我发现里面大部分的操作都是写在RewriteModuleProxy.cs这个文件中的,里面有几十个方法,但所有的方法实现都是直接调用了父类的invoke方法。而它的父类是一个抽象类,里面只有对invoke的定义。

请问这种用法是怎么回事呢,对于所有操作的具体实现,是写在什么地方的呢。

ModuleServiceProxy类大致内容如下:

internal sealed class RewriteModuleProxy : ModuleServiceProxy
    {
        public PropertyBag AddAllowedServerVariable(string name)
        {
            return (PropertyBag) base.Invoke("AddAllowedServerVariable", new object[] { name });
        }

        public void AddCondition(string ruleName, int ruleKind, PropertyBag conditionBag)
        {
            base.Invoke("AddCondition", new object[] { ruleName, ruleKind, conditionBag });
        }

        public void AddCustomTag(string groupName, string tagName, string matchingAttribute)
        {
            base.Invoke("AddCustomTag", new object[] { groupName, tagName, matchingAttribute });
        }

        public void AddCustomTagGroup(PropertyBag bag)
        {
            base.Invoke("AddCustomTagGroup", new object[] { bag });
        }
//............................


它的父类很简单,内容如下:

    public abstract class ModuleServiceProxy
    {
        protected ModuleServiceProxy();

        public static string GetErrorInformation(Exception ex, ResourceManager resourceManager, out string errorText, out string errorMessage);
        protected object Invoke(string methodName, params object[] parameters);
    }





------解决方案--------------------
肯定是在它的派生类中实现的。

但是派生类未必你能找到,也许是动态生成的。