本文整理汇总了C#中IPlugin.Name方法的典型用法代码示例。如果您正苦于以下问题:C# IPlugin.Name方法的具体用法?C# IPlugin.Name怎么用?C# IPlugin.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPlugin
的用法示例。
在下文中一共展示了IPlugin.Name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public static void Add(SPSite site, IPlugin plugin, bool force = false)
{
if (site == null) throw new ArgumentNullException("site");
if (plugin == null) throw new ArgumentNullException("plugin");
//if (!ValidatePlugin(plugin)) return;
if ((plugin.Name().Length > 0) && !(plugin.Name().Equals("All") || plugin.Name().Equals("None")))
{
if (List(site).Contains(plugin.Name()))
{
if (force) Remove(site, plugin.Name());
else return;
}
if (!Collection.ContainsKey(site.Url))
{
Collection.Add(site.Url, new List<IPlugin> {plugin});
}
else
{
Collection[site.Url].Add(plugin);
}
}
}
示例2: ValidatePlugin
//Kontrola jestli plugin obsahuje vsechny potrebne metody
//TODO - nelze ale zjisit jestli metodu obsahuje jinak nez tim ze ji vola - nepouzivame tedy
//
public static bool ValidatePlugin(IPlugin plugin)
{
List<string> missingMethods = new List<string>();
try
{
plugin.Name();
}
catch (MissingMemberException)
{
missingMethods.Add("Name");
}
try
{
plugin.Description();
}
catch (MissingMemberException)
{
missingMethods.Add("Description");
}
try
{
plugin.Version();
}
catch (MissingMemberException)
{
missingMethods.Add("Version");
}
try
{
//Tuto metodu pouzivame pouze v DLLExecute neni ji tedy nutne kontrolovatna DLR
plugin.PluginScope();
}
catch (MissingMemberException)
{
missingMethods.Add("PluginScope");
}
try
{
plugin.Execute(null, null);
}
catch (MissingMemberException)
{
missingMethods.Add("Execute");
}
catch (Exception) {}
try
{
plugin.Install(null, null);
}
catch (MissingMemberException)
{
missingMethods.Add("Install");
}
catch (Exception) { }
try
{
plugin.Test(null, null);
}
catch (MissingMemberException)
{
missingMethods.Add("Test");
}
catch (Exception) {}
try
{
plugin.GetInstance();
}
catch (Exception)
{
missingMethods.Add("GetInstance");
}
if (missingMethods.Count > 0)
{
var log = NaverticaLog.GetInstance();
log.LogError(missingMethods.Contains("Name") ? "" : plugin.Name(), "Missing methods in plugin: " + missingMethods.JoinStrings(", "));
}
return missingMethods.Count == 0;
}