/// <summary> /// Returns a collection of standard values for the data type this type converter is designed for when provided with a format context. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be null.</param> /// <returns> /// A <see cref="T:System.ComponentModel.TypeConverter.StandardValuesCollection"></see> that holds a standard set of valid values, or null if the data type does not support a standard set of values. /// </returns> public override StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { DTE dte = (DTE)context.GetService(typeof(DTE)); ResponsibleProjectFinder finder = new ResponsibleProjectFinder(dte); List <Project> projects = finder.FindProjectsWithResponsibility(responsibility); return(new StandardValuesCollection(projects)); }
/// <summary> /// Finds across the projects in the solution for projects with a given set of responsibilities. /// </summary> /// <param name="responsibilities">Project responsibilities</param> /// <returns>List of <see cref="IProjectModel"/></returns> public List <IProjectModel> FindProjectsWithResponsibility(string[] responsibilities) { ResponsibleProjectFinder projectFinder = new ResponsibleProjectFinder(solution.DTE); List <IProjectModel> foundProjects = new List <IProjectModel>(); foreach (string responsibility in responsibilities) { List <Project> projects = projectFinder.FindProjectsWithResponsibility(responsibility); foundProjects.AddRange(projects.ConvertAll <IProjectModel>(new Converter <Project, IProjectModel>(ProjectToIProjectModel))); } return(foundProjects); }
private bool Evaluate(out object newValue) { newValue = null; ExpressionEvaluationService evaluator = new ExpressionEvaluationService(); IDictionaryService dictservice = (IDictionaryService)GetService(typeof(IDictionaryService)); string assembly = null; try { assembly = evaluator.Evaluate( this._assemblyExpression, new ServiceAdapterDictionary(dictservice)).ToString(); } catch { } if (assembly == null) { // evaluation failed return(false); } ResponsibleProjectFinder finder = new ResponsibleProjectFinder((DTE)(Site.GetService(typeof(DTE)))); List <Project> moduleProjects = finder.FindProjectsWithResponsibility(_responsibility); if (moduleProjects.Count > 0) { foreach (Project module in moduleProjects) { string projectAssembly = module.Properties.Item("AssemblyName").Value.ToString(); if (String.Compare(projectAssembly, assembly, StringComparison.CurrentCultureIgnoreCase) == 0) { newValue = module; return(true); } } } return(false); }