private bool TryGetEntryInternal(string entryName, EnvDTE.Expressions expressions, out EnvDTE.Expression expression) { expression = expressions.Cast <EnvDTE.Expression>().FirstOrDefault(e => e.Name == entryName); if (expression != null) { return(true); } return(false); }
private EnvDTE.Expression GetEntryInternal(string entryName, EnvDTE.Expressions expressions) { var expressionCollection = expressions.Cast <EnvDTE.Expression>(); var expressionMatched = expressionCollection.FirstOrDefault(e => e.Name == entryName); if (expressionMatched != null) { return(expressionMatched); } string nestedExpressionNamesString = string.Join(",", expressionCollection.Select(e => e.Name)); throw new Exception($"Could not find the local named {entryName}. Available locals are {nestedExpressionNamesString}."); }
private static IEnumerable <string> GetAllLocals(EnvDTE.Expressions expressions) { foreach (var expression in expressions.Cast <EnvDTE.Expression>()) { var expressionName = expression.Name; yield return(expressionName); var nestedExpressions = expression.DataMembers; if (nestedExpressions != null) { foreach (var nestedLocal in GetAllLocals(nestedExpressions)) { yield return(string.Format("{0}->{1}", expressionName, nestedLocal)); } } } }