public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor) { this.functionDescriptor = functionDescriptor; var displayName = functionDescriptor.UserFriendlyName; if (functionDescriptor.IsOverloaded) displayName += "(" + string.Join(", ", functionDescriptor.Parameters) + ")"; Name = displayName; UserFriendlyName = functionDescriptor.UserFriendlyName; FullCategoryName = functionDescriptor.Category; Description = functionDescriptor.Description; Assembly = functionDescriptor.Assembly; ElementType = ElementTypes.ZeroTouch; if (functionDescriptor.IsBuiltIn) ElementType |= ElementTypes.BuiltIn; // Assembly, that is located in package directory, considered as part of package. if (Assembly.StartsWith(functionDescriptor.PathManager.PackagesDirectory)) ElementType |= ElementTypes.Packaged; inputParameters = new List<Tuple<string, string>>(functionDescriptor.InputParameters); outputParameters = new List<string>() { functionDescriptor.ReturnType }; foreach (var tag in functionDescriptor.GetSearchTags()) SearchKeywords.Add(tag); iconName = GetIconName(); }
public ZeroTouchSearchElement(FunctionDescriptor functionDescriptor) { this.functionDescriptor = functionDescriptor; var displayName = functionDescriptor.UserFriendlyName; if (functionDescriptor.IsOverloaded) displayName += "(" + string.Join(", ", functionDescriptor.Parameters) + ")"; Name = displayName; UserFriendlyName = functionDescriptor.UserFriendlyName; FullCategoryName = functionDescriptor.Category; Description = functionDescriptor.Description; Assembly = functionDescriptor.Assembly; ElementType = ElementTypes.ZeroTouch; if (functionDescriptor.IsBuiltIn) ElementType |= ElementTypes.BuiltIn; // Assembly, that is located in package directory, considered as part of package. var packageDirectories = functionDescriptor.PathManager.PackagesDirectories; if (packageDirectories.Any(directory => Assembly.StartsWith(directory))) ElementType |= ElementTypes.Packaged; inputParameters = new List<Tuple<string, string>>(functionDescriptor.InputParameters); outputParameters = new List<string>() { functionDescriptor.ReturnType }; foreach (var tag in functionDescriptor.GetSearchTags()) SearchKeywords.Add(tag); var weights = functionDescriptor.GetSearchTagWeights(); foreach (var weight in weights) { // Search tag weight can't be more then 1. if (weight <= 1) keywordWeights.Add(weight); } int weightsCount = weights.Count(); // If there weren't added weights for search tags, then add default value - 0.5 if (weightsCount != SearchKeywords.Count) { int numberOfLackingWeights = SearchKeywords.Count - weightsCount; // Number of lacking weights should be more than 0. // It can be less then 0 only if there was some mistake in xml file. if (numberOfLackingWeights > 0) { for (int i = 0; i < numberOfLackingWeights; i++) { keywordWeights.Add(0.5); } } } iconName = GetIconName(); }
public static IEnumerable <string> GetSearchTags(this FunctionDescriptor member) { XDocument xml = null; if (member.Assembly != null) { xml = DocumentationServices.GetForAssembly(member.Assembly); } return(member.GetSearchTags(xml)); }