本文整理汇总了C#中IPlugin.Attach方法的典型用法代码示例。如果您正苦于以下问题:C# IPlugin.Attach方法的具体用法?C# IPlugin.Attach怎么用?C# IPlugin.Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPlugin
的用法示例。
在下文中一共展示了IPlugin.Attach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
/// <summary>
/// Adds a <see cref="IPlugin" /> to the map.
/// </summary>
/// <param name="plugin">The <see cref="IPlugin" /> to add to the map.</param>
/// <remarks>
/// <para>
/// The <see cref="IPlugin" /> will be attached to the repository when added.
/// </para>
/// <para>
/// If there already exists a plugin with the same name
/// attached to the repository then the old plugin will
/// be <see cref="IPlugin.Shutdown"/> and replaced with
/// the new plugin.
/// </para>
/// </remarks>
public void Add(IPlugin plugin)
{
if (plugin == null)
{
throw new ArgumentNullException("plugin");
}
IPlugin curPlugin = null;
lock(this)
{
// Get the current plugin if it exists
curPlugin = m_mapName2Plugin[plugin.Name] as IPlugin;
// Store new plugin
m_mapName2Plugin[plugin.Name] = plugin;
}
// Shutdown existing plugin with same name
if (curPlugin != null)
{
curPlugin.Shutdown();
}
// Attach new plugin to repository
plugin.Attach(m_repository);
}