本文整理汇总了C#中ITypeFinder.Find方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeFinder.Find方法的具体用法?C# ITypeFinder.Find怎么用?C# ITypeFinder.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeFinder
的用法示例。
在下文中一共展示了ITypeFinder.Find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindControllers
private static IList<ControlsAttribute> FindControllers(ITypeFinder typeFinder)
{
var controllerLookup = new Dictionary<Type, ControlsAttribute>();
foreach (Type controllerType in typeFinder.Find(typeof(IController)))
{
foreach (ControlsAttribute attr in controllerType.GetCustomAttributes(typeof(ControlsAttribute), false))
{
if (controllerLookup.ContainsKey(attr.ItemType))
throw new N2Exception("Duplicate controller " + controllerType.Name + " declared for item type " +
attr.ItemType.Name +
" The controller " + controllerLookup[attr.ItemType].AdapterType.Name +
" already handles this type and two controllers cannot handle the same item type.");
attr.AdapterType = controllerType;
controllerLookup.Add(attr.ItemType, attr);
}
}
var controllerDefinitions = new List<ControlsAttribute>(controllerLookup.Values);
controllerDefinitions.Sort();
return controllerDefinitions;
}
示例2: FindControllers
private static IList<ControlsAttribute> FindControllers(ITypeFinder typeFinder)
{
var controllerDefinitions = new List<ControlsAttribute>();
foreach (Type controllerType in typeFinder.Find(typeof(IController)))
{
foreach (ControlsAttribute attr in controllerType.GetCustomAttributes(typeof(ControlsAttribute), false))
{
attr.AdapterType = controllerType;
controllerDefinitions.Add(attr);
}
}
controllerDefinitions.Sort();
return controllerDefinitions;
}