/// <summary> /// takes a parameter like "$(FeatureName)$(NameSeparator)$(ID)" and returns the current value "FeatureX_34" /// </summary> /// <param name="parameterName"></param> /// <returns></returns> internal string EvaluateParameterAsString(DTE dte, string parameterName) { try { IDictionaryService serviceToAdapt = (IDictionaryService)this.GetService(typeof(IDictionaryService)); ServiceAdapterDictionary serviceAdaptor = new ServiceAdapterDictionary(serviceToAdapt); ExpressionEvaluationService2 expressionService2 = new ExpressionEvaluationService2(); string evaluatedValue = expressionService2.Evaluate(parameterName, serviceAdaptor).ToString(); if (string.IsNullOrEmpty(evaluatedValue)) { return(""); } return(evaluatedValue); } catch (NullReferenceException) { } return(""); }
internal string EvaluateParameterAsString(DTE dte, string parameterName) { try { IDictionaryService serviceToAdapt = (IDictionaryService)this.GetService(typeof(IDictionaryService)); ServiceAdapterDictionary serviceAdaptor = new ServiceAdapterDictionary(serviceToAdapt); ExpressionEvaluationService2 expressionService2 = new ExpressionEvaluationService2(); object evaluatedValue = expressionService2.Evaluate(parameterName, serviceAdaptor); if (evaluatedValue == null || string.IsNullOrEmpty(evaluatedValue.ToString())) { return ""; } return evaluatedValue.ToString(); } catch (NullReferenceException) { } return ""; }
/// <summary> /// Evaluates the expression /// </summary> public override void Execute() { ExpressionEvaluationService2 evaluator = new ExpressionEvaluationService2(); try { this.WrappedContainer.AddService(evaluator.GetType(), evaluator); IDictionaryService dictservice = (IDictionaryService) this.WrappedContainer.GetService(typeof(IDictionaryService), true); this.ReturnValue = evaluator.Evaluate( this.Expression, new ServiceAdapterDictionary(dictservice)); } finally { this.WrappedContainer.RemoveService(evaluator.GetType()); evaluator = null; } }