• C# dll加载,抽象方法的使用


    抽象类! 

    dll的使用

    /// <summary>
    /// 返回类型--插件
    /// </summary>
    /// <param name="baseName"></param>
    /// <param name="name"></param>
    /// <param name="attname"></param>
    /// <returns></returns>
    private Type GetPlugin(string baseName, string name, string attname)
    {
    Hashtable hashtable = this.GetPluginCache();
    name = name.ToLower();
    Type type = hashtable[name] as Type;
    Type result;
    if (type == null)
    {
    if (PluginContainer.pluginCache.Get(this.IndexCacheKey) == null)
    {
    result = null;
    return result;
    }
    XmlDocument xmlDocument = PluginContainer.pluginCache.Get(this.IndexCacheKey) as XmlDocument;
    XmlNode xmlNode = xmlDocument.DocumentElement.SelectSingleNode(string.Concat(new string[]
    {
    "//",
    baseName,
    "/item[@",
    attname,
    "='",
    name,
    "']"
    }));
    if (xmlNode == null || !File.Exists(xmlNode.Attributes["file"].Value))
    {
    result = null;
    return result;
    }
    Assembly assembly = Assembly.Load(PluginContainer.LoadPlugin(xmlNode.Attributes["file"].Value));
    type = assembly.GetType(xmlNode.Attributes["identity"].Value, false, true);
    if (type != null)
    {
    hashtable[name] = type;
    }
    }
    result = type;
    return result;
    }

  • 相关阅读:
    回顾C#3.0新特性(3)
    第五周作业
    第六周基础作业
    第三周syh
    基础作业
    第七周作业
    2019年春季学期第四周作业
    第八周作业
    .Net 反射
    C#中SqlParameter
  • 原文地址:https://www.cnblogs.com/zxs-onestar/p/5993084.html
Copyright © 2020-2023  润新知