/// <summary> /// Gets metadata describing all extensions of the input <paramref name="extensionPoint"/>, /// matching the given <paramref name="filter"/>. /// </summary> /// <param name="extensionPoint">The <see cref="ExtensionPoint"/> whose extension metadata is to be retrieved.</param> /// <param name="filter">An <see cref="ExtensionFilter"/> used to filter out extensions with particular characteristics.</param> /// <returns></returns> public virtual ExtensionInfo[] ListExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter) { if (extensionPoint == null) { throw new ArgumentNullException("extensionPoint"); } var extensionPointType = extensionPoint.GetType(); if (!_extensionMap.ContainsKey(extensionPointType)) { return(new ExtensionInfo[0]); } var extensions = new List <ExtensionInfo>(); foreach (var extensionType in _extensionMap[extensionPointType]) { var extensionInfo = new ExtensionInfo(extensionType, extensionPointType, extensionType.Name, extensionType.AssemblyQualifiedName, true); if (filter == null || filter.Test(extensionInfo)) { extensions.Add(extensionInfo); } } return(extensions.ToArray()); }
private IEnumerable <ExtensionDescriptor> ListExtensionsCore(ExtensionPoint extensionPoint, ExtensionFilter filter) { if (extensionPoint == null) { throw new ArgumentNullException("extensionPoint"); } var extensionPointType = extensionPoint.GetType(); if (!_extensionMap.ContainsKey(extensionPointType)) { return(Enumerable.Empty <ExtensionDescriptor>()); } var extensions = _extensionMap[extensionPointType].Select(x => x); if (filter != null) { extensions = extensions.Where(x => filter.Test(x.Info)); } return(extensions); }