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;
}

上一篇:LeetCode 算法题解 js 版 (001 Two Sum)


下一篇:CURL访问url显示响应时间