private bool Evaluate(out object newValue)
        {
            newValue = null;

            ExpressionEvaluationService evaluator   = new ExpressionEvaluationService();
            IDictionaryService          dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            Type   proxyType = null;
            string language  = string.Empty;

            try
            {
                proxyType = (Type)evaluator.Evaluate(
                    this._typeExpression,
                    new ServiceAdapterDictionary(dictservice));
                language = (string)evaluator.Evaluate(
                    this._languageExpression,
                    new ServiceAdapterDictionary(dictservice));
            }
            catch { }

            newValue = ProxyFactoryHelper.GetProxyFactory(proxyType, language);

            return(newValue != null);
        }
 /// <summary>
 /// Evaluates an expression using <see cref="ExpressionEvaluationService"/>
 /// </summary>
 /// <param name="dictionary">An instance of <see cref="IDictionaryService"/></param>
 /// <param name="expression">Expression to evaluate</param>
 /// <returns>The result as an object</returns>
 public static object EvaluateExpression(IDictionaryService dictionary, string expression)
 {
     ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
     object result = null;
     try
     {
         result = evaluator.Evaluate(expression, new ServiceAdapterDictionary(dictionary));
     }
     catch { }
     return result;
 }
Exemple #3
0
        /// <summary>
        /// Evaluates an expression using <see cref="ExpressionEvaluationService"/>
        /// </summary>
        /// <param name="dictionary">An instance of <see cref="IDictionaryService"/></param>
        /// <param name="expression">Expression to evaluate</param>
        /// <returns>The result as an object</returns>
        public static object EvaluateExpression(IDictionaryService dictionary, string expression)
        {
            ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
            object result = null;

            try
            {
                result = evaluator.Evaluate(expression, new ServiceAdapterDictionary(dictionary));
            }
            catch { }
            return(result);
        }
        /// <summary>
        /// Runs the coordination using the configuration data specified in the configuration file.
        /// </summary>
        /// <param name="declaredActions">Actions defined in the package configuration file for the currently executing recipe.</param>
        /// <param name="coordinationData">The configuration data used to setup the coordination.</param>
        public void Run(Dictionary <string, Microsoft.Practices.RecipeFramework.Configuration.Action> declaredActions,
                        XmlElement coordinationData)
        {
            IActionExecutionService exec = GetService <IActionExecutionService>(true);
            int amountCompleted          = 0;

            try
            {
                foreach (Microsoft.Practices.RecipeFramework.Configuration.Action action in declaredActions.Values)
                {
                    amountCompleted++;
                    visualStudio.StatusBar.Progress(true, Properties.Resources.StatusBarProgressMessage, amountCompleted, declaredActions.Values.Count);

                    bool execute = (action.AnyAttr == null || action.AnyAttr.Length == 0);

                    if (!execute)
                    {
                        IDictionaryService          dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));
                        ExpressionEvaluationService evaluator   = new ExpressionEvaluationService();
                        execute = true;
                        foreach (XmlAttribute att in action.AnyAttr)
                        {
                            if (att.Name.Equals(ConditionalCoordinator.ConditionalAttributeName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                try
                                {
                                    execute = (bool)evaluator.Evaluate(att.Value, new ServiceAdapterDictionary(dictservice));
                                }
                                catch (Exception e)
                                {
                                    execute = false;
                                    System.Diagnostics.Trace.TraceWarning(Properties.Resources.InvalidConditionException, e.Message, e.StackTrace);
                                }
                                break;
                            }
                        }
                    }

                    if (execute)
                    {
                        Trace.TraceInformation(Properties.Resources.ExecutingAction, action.Name);
                        exec.Execute(action.Name);
                    }
                }
            }
            finally
            {
                visualStudio.StatusBar.Progress(false, "", 0, 0);
            }
        }
        /// <summary>
        /// Runs the coordination using the configuration data specified in the configuration file.
        /// </summary>
        /// <param name="declaredActions">Actions defined in the package configuration file for the currently executing recipe.</param>
        /// <param name="coordinationData">The configuration data used to setup the coordination.</param>
        public void Run(Dictionary<string, Microsoft.Practices.RecipeFramework.Configuration.Action> declaredActions, 
			XmlElement coordinationData)
        {
            IActionExecutionService exec = GetService<IActionExecutionService>(true);
            int amountCompleted = 0;

            try
            {
                foreach (Microsoft.Practices.RecipeFramework.Configuration.Action action in declaredActions.Values)
                {
                    amountCompleted++;
                    visualStudio.StatusBar.Progress(true, Properties.Resources.StatusBarProgressMessage, amountCompleted, declaredActions.Values.Count);

                    bool execute = (action.AnyAttr == null || action.AnyAttr.Length == 0);

                    if (!execute)
                    {
                        IDictionaryService dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));
                        ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
                        execute = true;
                        foreach (XmlAttribute att in action.AnyAttr)
                        {
                            if (att.Name.Equals(ConditionalCoordinator.ConditionalAttributeName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                try
                                {
                                    execute = (bool)evaluator.Evaluate(att.Value, new ServiceAdapterDictionary(dictservice));
                                }
                                catch (Exception e)
                                {
                                    execute = false;
                                    System.Diagnostics.Trace.TraceWarning(Properties.Resources.InvalidConditionException, e.Message, e.StackTrace);
                                }
                                break;
                            }
                        }
                    }

                    if (execute)
                    {
                        Trace.TraceInformation(Properties.Resources.ExecutingAction, action.Name);
                        exec.Execute(action.Name);
                    }
                }
            }
            finally
            {
                visualStudio.StatusBar.Progress(false, "", 0, 0);
            }
        }
Exemple #6
0
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <returns></returns>
        private object GetValue()
        {
            DTE    dte = (DTE)GetService(typeof(DTE));
            object newValue;

            ExpressionEvaluationService evaluator   = new ExpressionEvaluationService();
            IDictionaryService          dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            string path = evaluator.Evaluate(
                this.pathExpression,
                new ServiceAdapterDictionary(dictservice)).ToString();

            newValue = DteHelper.FindProjectByPath(dte.Solution, path);
            return(newValue);
        }
 /// <summary>
 /// Evaluates the expression
 /// </summary>
 public override void Execute()
 {
     ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
     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;
     }
 }
        public void Run(Dictionary <string, Microsoft.Practices.RecipeFramework.Configuration.Action> declaredActions, XmlElement coordinationData)
        {
            IActionExecutionService service = base.GetService <IActionExecutionService>(true);
            int amountCompleted             = 0;

            try
            {
                foreach (Microsoft.Practices.RecipeFramework.Configuration.Action action in declaredActions.Values)
                {
                    amountCompleted++;
                    bool flag = (action.AnyAttr == null) || (action.AnyAttr.Length == 0);
                    if (!flag)
                    {
                        IDictionaryService          serviceToAdapt = (IDictionaryService)this.GetService(typeof(IDictionaryService));
                        ExpressionEvaluationService service3       = new ExpressionEvaluationService();
                        flag = true;
                        foreach (XmlAttribute attribute in action.AnyAttr)
                        {
                            if (attribute.Name.Equals("Condition", StringComparison.InvariantCultureIgnoreCase))
                            {
                                try
                                {
                                    flag = (bool)service3.Evaluate(attribute.Value, new ServiceAdapterDictionary(serviceToAdapt));
                                }
                                catch (Exception exception)
                                {
                                    flag = false;
                                    Trace.TraceWarning("InvalidConditionException", new object[] { exception.Message, exception.StackTrace });
                                }
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        service.Execute(action.Name);
                    }
                }
            }
            finally
            {
                this.visualStudio.StatusBar.Progress(false, "", 0, 0);
            }
        }
        private bool Evaluate()
        {
            ExpressionEvaluationService evaluator   = new ExpressionEvaluationService();
            IDictionaryService          dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            object value = null;

            try
            {
                value = evaluator.Evaluate(
                    this._valueExpression,
                    new ServiceAdapterDictionary(dictservice)).ToString();
            }
            catch { }

            bool expressionIsValid = (value != null);

            return(expressionIsValid);
        }
        /// <summary>
        /// Evaluates the expression
        /// </summary>
        public override void Execute()
        {
            ExpressionEvaluationService evaluator = new ExpressionEvaluationService();

            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;
            }
        }
 public void Run(Dictionary<string, Microsoft.Practices.RecipeFramework.Configuration.Action> declaredActions, XmlElement coordinationData)
 {
     IActionExecutionService service = base.GetService<IActionExecutionService>(true);
     int amountCompleted = 0;
     try
     {
       foreach (Microsoft.Practices.RecipeFramework.Configuration.Action action in declaredActions.Values)
       {
         amountCompleted++;
         bool flag = (action.AnyAttr == null) || (action.AnyAttr.Length == 0);
         if (!flag)
         {
           IDictionaryService serviceToAdapt = (IDictionaryService)this.GetService(typeof(IDictionaryService));
           ExpressionEvaluationService service3 = new ExpressionEvaluationService();
           flag = true;
           foreach (XmlAttribute attribute in action.AnyAttr)
           {
             if (attribute.Name.Equals("Condition", StringComparison.InvariantCultureIgnoreCase))
             {
               try
               {
                 flag = (bool)service3.Evaluate(attribute.Value, new ServiceAdapterDictionary(serviceToAdapt));
               }
               catch (Exception exception)
               {
                 flag = false;
                 Trace.TraceWarning("InvalidConditionException", new object[] { exception.Message, exception.StackTrace });
               }
               break;
             }
           }
         }
         if (flag)
         {
           service.Execute(action.Name);
         }
       }
     }
     finally
     {
         this.visualStudio.StatusBar.Progress(false, "", 0, 0);
     }
 }
Exemple #12
0
        /// <summary>
        /// Contains code that will be called when recipe execution begins. This is the first method in the lifecycle.
        /// </summary>
        /// <param name="currentValue">An <see cref="T:System.Object"/> that contains the current value of the argument.</param>
        /// <param name="newValue">When this method returns, contains an <see cref="T:System.Object"/> that contains
        /// the new value of the argument, if the returned value
        /// of the method is <see langword="true"/>. Otherwise, it is ignored.</param>
        /// <returns>
        ///     <see langword="true"/> if the argument value should be replaced with
        /// the value in <paramref name="newValue"/>; otherwise, <see langword="false"/>.
        /// </returns>
        /// <remarks>By default, always returns <see langword="false"/>, unless overriden by a derived class.</remarks>
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            DTE dte = (DTE)GetService(typeof(DTE));

            ExpressionEvaluationService evaluator   = new ExpressionEvaluationService();
            IDictionaryService          dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            string defaultName = evaluator.Evaluate(
                this.expression,
                new ServiceAdapterDictionary(dictservice)).ToString();

            string projectName = defaultName;

            while (DteHelperEx.ProjectExists(dte.Solution, projectName, this.language))
            {
                projectName = ProvideNewDefaultValue(defaultName, projectName);
            }

            newValue = projectName;
            return(true);
        }
        /// <summary>
        /// Contains code that will be called when recipe execution begins. This is the first method in the lifecycle.
        /// </summary>
        /// <param name="currentValue">An <see cref="T:System.Object"/> that contains the current value of the argument.</param>
        /// <param name="newValue">When this method returns, contains an <see cref="T:System.Object"/> that contains
        /// the new value of the argument, if the returned value
        /// of the method is <see langword="true"/>. Otherwise, it is ignored.</param>
        /// <returns>
        /// 	<see langword="true"/> if the argument value should be replaced with
        /// the value in <paramref name="newValue"/>; otherwise, <see langword="false"/>.
        /// </returns>
        /// <remarks>By default, always returns <see langword="false"/>, unless overriden by a derived class.</remarks>
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            DTE dte = (DTE)GetService(typeof(DTE));

            ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
            IDictionaryService dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            string defaultName = evaluator.Evaluate(
                                             this.expression,
                                             new ServiceAdapterDictionary(dictservice)).ToString();

            string projectName = defaultName;

            while(DteHelperEx.ProjectExists(dte.Solution, projectName, this.language))
            {
                projectName = ProvideNewDefaultValue(defaultName, projectName);
            }

            newValue = projectName;
            return true;
        }
        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);
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            if (currentValue == null)
            {
                ExpressionEvaluationService evaluator   = new ExpressionEvaluationService();
                IDictionaryService          dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

                string path = evaluator.Evaluate(
                    this._pathExpression,
                    new ServiceAdapterDictionary(dictservice)).ToString();

                WebConfigXmlParseModuleInfoStore store = new WebConfigXmlParseModuleInfoStore(path);
                WebModuleEnumerator moduleEnumerator   = new WebModuleEnumerator(store);

                IModuleInfo[] modules = moduleEnumerator.EnumerateModules();

                newValue = new ModuleInfoMapper().Translate(modules);

                return(true);
            }

            newValue = null;
            return(false);
        }
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <returns></returns>
        private object GetValue()
        {
            DTE dte = (DTE)GetService(typeof(DTE));
            object newValue;

            ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
            IDictionaryService dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            string path = evaluator.Evaluate(
                                             this.pathExpression,
                                             new ServiceAdapterDictionary(dictservice)).ToString();

            newValue = DteHelper.FindProjectByPath(dte.Solution, path);
            return newValue;
        }
        private bool Evaluate()
        {
            ExpressionEvaluationService evaluator = new ExpressionEvaluationService();
            IDictionaryService dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            object value = null;

            try
            {
                value = evaluator.Evaluate(
                                            this._valueExpression,
                                            new ServiceAdapterDictionary(dictservice)).ToString();
            }
            catch { }

            bool expressionIsValid = (value != null);
            return expressionIsValid;
        }
        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;
        }