Esempio n. 1
0
        // Methods
        public override void Execute()
        {
            if (!String.IsNullOrEmpty(this.templateExpression))
            {
                this.Template = (string)ExpressionEvaluationHelper.EvaluateExpression(
                    (IDictionaryService)GetService(typeof(IDictionaryService)),
                    this.templateExpression);
            }
            string path         = this.Template;
            string templateCode = string.Empty;

            if (path == null)
            {
                throw new ArgumentNullException("Template");
            }
            string templateBasePath = base.GetTemplateBasePath();

            if (!Path.IsPathRooted(path))
            {
                path = Path.Combine(templateBasePath, path);
            }
            path = new FileInfo(path).FullName;
            if (!path.StartsWith(templateBasePath))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.TemplateNotFoundMessage));
            }
            templateCode = File.ReadAllText(path);
            this.Content = base.Render(templateCode, path);
        }
 public override bool OnBeginRecipe(object currentValue, out object newValue)
 {
     if (currentValue == null)
     {
         Project webproject = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                            _webProjectExpression) as Project;
         if (webproject != null)
         {
             newValue = webproject;
             return(true);
         }
         else
         {
             ProjectItem webfolder = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                   _webFolderExpression) as ProjectItem;
             if (webfolder == null)
             {
                 newValue = null;
                 return(false);
             }
             if (webfolder.ContainingProject != null)
             {
                 newValue = webfolder.ContainingProject;
                 return(true);
             }
         }
     }
     newValue = null;
     return(false);
 }
Esempio n. 3
0
        private bool Evaluate(out object newValue)
        {
            newValue = null;
            CodeClass currentDSAClass = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                      currentDSAClassExpression) as CodeClass;

            if (currentDSAClass != null)
            {
                CodeProperty onlineProxyTypeProperty = CodeModelHelper.GetProperty(currentDSAClass, "OnlineProxyType", vsCMAccess.vsCMAccessPublic);
                if (onlineProxyTypeProperty != null)
                {
                    CodeFunction getMethod = onlineProxyTypeProperty.Getter;
                    EditPoint    edit      = getMethod.StartPoint.CreateEditPoint();
                    EditPoint    endpoint  = null;
                    TextRanges   tags      = null;
                    if (edit.FindPattern(@"(typeof|GetType)\((.+)\)", (int)vsFindOptions.vsFindOptionsRegularExpression, ref endpoint, ref tags))
                    {
                        EditPoint begin         = edit.CreateEditPoint();
                        string    proxyTypeName = begin.GetText(endpoint);
                        Regex     extractRegex  = new Regex(@"(typeof|GetType)\((.+)\)");
                        if (extractRegex.IsMatch(proxyTypeName) && extractRegex.Match(proxyTypeName).Groups.Count == 3)
                        {
                            proxyTypeName = extractRegex.Match(proxyTypeName).Groups[2].Value;
                            newValue      = proxyTypeName;
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 4
0
        private bool Evaluate(out object newValue)
        {
            newValue = null;
            IModuleInfo[] moduleInfoList = (IModuleInfo[])ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                                        _moduleInfoListExpression);
            Project     webProject;
            ProjectItem folder;

            IsWebProjectSelected(out webProject, out folder);
            IModuleInfo found;

            if (folder != null)
            {
                found = FindModuleInfo(moduleInfoList, folder);
            }
            else if (IsFolderOfRootWebProject(webProject))
            {
                found = FindModuleInfoInSubWebProject(moduleInfoList, webProject);
            }
            else
            {
                found = FindRootVirtualPathModuleInfo(moduleInfoList);
            }
            newValue = found;
            return(true);
        }
        private bool Evaluate(object currentValue, out object newValue)
        {
            IDictionaryService dictionaryService = (IDictionaryService)GetService(typeof(IDictionaryService));

            string moduleProjectLanguage   = ExpressionEvaluationHelper.EvaluateExpression(dictionaryService, _moduleProjectLanguage) as string;
            bool   isWCSFSolutionWAP       = (bool)ExpressionEvaluationHelper.EvaluateExpression(dictionaryService, _isWCSFSolutionWAP);
            bool   createAsFolderInWebsite = (bool)ExpressionEvaluationHelper.EvaluateExpression(dictionaryService, _createAsFolderInWebsite);

            if (isWCSFSolutionWAP && createAsFolderInWebsite)
            {
                Project project = ExpressionEvaluationHelper.EvaluateExpression(dictionaryService, _projectExpression) as Project;
                if (project != null)
                {
                    newValue = null;
                    switch (project.CodeModel.Language)
                    {
                    case CodeModelLanguageConstants.vsCMLanguageCSharp:
                        newValue = "cs";
                        break;

                    case CodeModelLanguageConstants.vsCMLanguageVB:
                        newValue = "vb";
                        break;
                    }
                    return(true);
                }
            }
            else
            {
                newValue = moduleProjectLanguage;
                return(true);
            }
            newValue = null;
            return(false);
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            newValue = null;
            if (currentValue == null)
            {
                CodeClass currentDSAClass = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                currentDSAClassExpression) as CodeClass;
                string methodName = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                methodNameExpression) as string;

                bool built = true;
                object builtValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                builtExpression);
                if (builtValue != null)
                { built = (bool)builtValue; }

                if (currentDSAClass != null && built)
                {
                    Type dsaType = DteConverter.ToType(currentDSAClass);
                    if (dsaType != null)
                    {
                        MethodInfo method=dsaType.GetMethod(methodName);
                        if (method != null
                            && method.IsStatic
                            && method.GetParameters().Length==0)
                        {
                            newValue = method.Invoke(null, null);
                            newValue = MethodBehaviorHelper.TranslateToOfflineBehavior(newValue);
                        }
                    }
                }

            }
            return currentValue!=newValue;
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            newValue = null;
            if (currentValue == null)
            {
                CodeClass currentDSAClass = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                          currentDSAClassExpression) as CodeClass;
                string propertyName = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                    propertyNameExpression) as string;

                bool   built      = true;
                object builtValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                  builtExpression);
                if (builtValue != null)
                {
                    built = (bool)builtValue;
                }

                if (currentDSAClass != null && built)
                {
                    Type dsaType = DteConverter.ToType(currentDSAClass);
                    if (dsaType != null)
                    {
                        newValue = dsaType.InvokeMember(propertyName, BindingFlags.Static | BindingFlags.Public | BindingFlags.GetProperty, null, null, null);
                        if (newValue != null)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
 public override bool OnBeginRecipe(object currentValue, out object newValue)
 {
     newValue = null;
     if (currentValue == null)
     {
         ProjectItem currentItem = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                 currentItemExpression) as ProjectItem;
         if (currentItem != null)
         {
             object proxyTechnology = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                    proxyTechnologyExpression);
             if (proxyTechnology == null || (ProxyTechnology)proxyTechnology == ProxyTechnology.Asmx)
             {
                 newValue = GetWsdlOperations(currentItem);
             }
             else
             {
                 List <MethodInfo> originalTypeMethods = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                                       originalTypeMethodsExpression) as List <MethodInfo>;
                 if (originalTypeMethods != null)
                 {
                     newValue = GetOperationsFromTypeMethods(originalTypeMethods);
                 }
             }
             return(true);
         }
     }
     return(false);
 }
Esempio n. 9
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            newValue = null;
            if (currentValue == null)
            {
                Type proxyType = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                               _proxyType) as Type;

                if (proxyType != null)
                {
                    ProjectItem selectedItem = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                             _selectedItem) as ProjectItem;
                    XmlDocument mapFile = null;
                    if (selectedItem != null &&
                        selectedItem.get_FileNames(0) != null &&
                        selectedItem.get_FileNames(0).ToLower().EndsWith(".map"))
                    {
                        mapFile = new XmlDocument();
                        mapFile.Load(selectedItem.get_FileNames(0));
                    }
                    newValue = GetProxyAddress(proxyType, mapFile);
                    return(true);
                }
            }
            return(false);
        }
        public override bool OnBeforeActions(object currentValue, out object newValue)
        {
            newValue = null;
            bool solvedExpression = (bool)ExpressionEvaluationHelper.EvaluateExpression(
                (IDictionaryService)GetService(typeof(IDictionaryService)),
                _valueToNegateExpression);

            newValue = !solvedExpression;
            return(true);
        }
Esempio n. 11
0
        public override bool OnBeforeActions(object currentValue, out object newValue)
        {
            string solvedExpression = (string)ExpressionEvaluationHelper.EvaluateExpression(
                (IDictionaryService)GetService(typeof(IDictionaryService)),
                _expression);

            newValue = ConvertToValidIdentifier(solvedExpression);

            return(true);
        }
        private bool Evaluate()
        {
            IDictionaryService dictionary = (IDictionaryService)GetService(typeof(IDictionaryService));
            bool _firstOperand            = (bool)ExpressionEvaluationHelper.EvaluateExpression(
                dictionary,
                _firstOperandExpression);
            bool _secondOperand = (bool)ExpressionEvaluationHelper.EvaluateExpression(
                dictionary,
                _secondOperandExpression);

            return(_firstOperand && _secondOperand);
        }
Esempio n. 13
0
        private bool Evaluate(out object newValue)
        {
            newValue = null;
            Type proxyType = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                           _proxyType) as Type;

            if (proxyType != null)
            {
                newValue = ProxyFactoryHelper.GetProxyTechnology(proxyType);
                return(true);
            }
            return(false);
        }
        private bool Evaluate(out object newValue)
        {
            DTE dte = (DTE)GetService(typeof(DTE));
            IDictionaryService dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));
            string             itemName    = ExpressionEvaluationHelper.EvaluateExpression(dictservice, this.itemNameExpression) as string;
            Project            project     = ExpressionEvaluationHelper.EvaluateExpression(dictservice, this.projectExpression) as Project;

            newValue = DteHelperEx.FindItemByName(project.ProjectItems, itemName, true);
            if (newValue != null)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 15
0
        public override bool OnBeforeActions(object currentValue, out object newValue)
        {
            newValue = null;
            if (string.IsNullOrEmpty(currentValue as string))
            {
                string folder = (string)ExpressionEvaluationHelper.EvaluateExpression(
                    (IDictionaryService)GetService(typeof(IDictionaryService)),
                    _folderExpression);

                newValue = GetSolvedPath(folder);
                return(true);
            }
            return(false);
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            object trueValue = null, falseValue = null;
            bool   conditionValue = false;

            trueValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                      _trueValueExpression);
            falseValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                       _falseValueExpression);
            conditionValue = (bool)ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                 _conditionValueExpression);

            newValue = conditionValue ? trueValue : falseValue;
            return(!object.Equals(currentValue, newValue));
        }
        private bool Evaluate(object currentValue, out object newValue)
        {
            Project project = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                            _projectExpression) as Project;

            if (project != null)
            {
                newValue = GetProjectLanguage(project);
                return(!newValue.Equals(currentValue));
            }
            else
            {
                newValue = null;
                return(false);
            }
        }
Esempio n. 18
0
        private bool Evaluate(out object newValue)
        {
            newValue = null;
            string typeName = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                            TypeNameExpression) as string;
            Project project = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                            ProjectExpression) as Project;

            if (typeName != null && project != null)
            {
                CodeClass targetClass = FileCodeModelHelper.FindCodeElementFromType(project, typeName, vsCMElement.vsCMElementClass) as CodeClass;
                newValue = (targetClass != null);
                return(true);
            }

            return(false);
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            DTE vs = GetService <DTE>(true);

            vs.Solution.SolutionBuild.Build(true);

            if (vs.Solution.SolutionBuild.LastBuildInfo == 0)
            {
                newValue = true;
            }
            else
            {
                bool throwException   = false;
                bool showErrorMessage = false;

                object throwExceptionValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                           _throwExceptionExpression);
                object showErrorMessageValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                             _showErrorMessageExpression);

                if (throwExceptionValue != null)
                {
                    throwException = (bool)throwExceptionValue;
                }
                if (showErrorMessageValue != null)
                {
                    showErrorMessage = (bool)showErrorMessageValue;
                }

                if (showErrorMessage)
                {
                    DisplayErrorMessage(Resources.SolutionBuildFailed);
                }

                if (throwException)
                {
                    throw new InvalidOperationException(String.Format(
                                                            CultureInfo.CurrentCulture,
                                                            Resources.SolutionMustBeBuildToRunTheRecipe));
                }

                newValue = false;
            }

            return(newValue != currentValue);
        }
Esempio n. 20
0
        /// <summary>
        /// Uses <see cref="DteHelper.FindProjectByPath"/> to search for the project specified by the "Path" attributte
        /// </summary>
        /// <param name="currentValue"></param>
        /// <param name="newValue"></param>
        /// <returns></returns>
        /// <seealso cref="ValueProvider.OnBeginRecipe"/>
        /// <seealso cref="DteHelper.FindProjectByPath"/>
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            DTE dte = (DTE)GetService(typeof(DTE));
            IDictionaryService dictservice = (IDictionaryService)GetService(typeof(IDictionaryService));

            if (currentValue == null)
            {
                string projectName = ExpressionEvaluationHelper.EvaluateExpression(dictservice, this.nameExpression) as string;

                newValue = DteHelperEx.FindProjectByName(dte, projectName, false);
                if (newValue != null)
                {
                    return(true);
                }
            }
            newValue = currentValue;
            return(false);
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            if (currentValue == null)
            {
                Project project = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                _projectExpression) as Project;
                if (project != null)
                {
                    IProjectModel projectModel    = new DteProjectModel(project, Site);
                    string        searchingPrefix = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                                  _searchingPrefix) as string;
                    string generatingPrefix = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                            _generatingPrefix) as string;
                    int    numericSuffix         = 1;
                    string searchingTypeName     = "";
                    string searchingTypeFullName = "";
                    string generatingTypeName    = "";
                    bool   typeExists            = true; //Dummy value forcing enter while structure

                    while (typeExists)
                    {
                        searchingTypeName  = string.Format(CultureInfo.InvariantCulture, "{0}{1}", searchingPrefix, numericSuffix);
                        generatingTypeName = string.Format(CultureInfo.InvariantCulture, "{0}{1}", generatingPrefix, numericSuffix);

                        if (!projectModel.IsWebProject)
                        {
                            searchingTypeFullName = string.Format(CultureInfo.InvariantCulture, "{1}.{0}", searchingTypeName, project.Properties.Item("DefaultNamespace").Value);
                        }
                        else
                        {
                            searchingTypeFullName = searchingTypeName;
                        }

                        typeExists = IsTypeAlreadyDeclared(projectModel, searchingTypeFullName);
                        numericSuffix++;
                    }

                    newValue = generatingTypeName;
                    return(true);
                }
            }
            newValue = null;
            return(false);
        }
 public override bool OnBeginRecipe(object currentValue, out object newValue)
 {
     newValue = null;
     if (currentValue == null)
     {
         ProjectItem currentItem = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                 currentItemExpression) as ProjectItem;
         if (currentItem != null)
         {
             CodeClass codeClass;
             if (CodeModelHelper.HaveAClassInProjectItems(currentItem, out codeClass, CodeModelHelper.IsDSAClass))
             {
                 newValue = codeClass;
             }
             return(true);
         }
     }
     return(false);
 }
Esempio n. 23
0
        public override bool OnBeforeActions(object currentValue, out object newValue)
        {
            newValue = currentValue;
            Project project = ExpressionEvaluationHelper.EvaluateExpression(
                (IDictionaryService)GetService(typeof(IDictionaryService)),
                _projectExpression) as Project;

            if (project != null &&
                project.ParentProjectItem != null &&
                project.ParentProjectItem.ContainingProject != null &&
                project.ParentProjectItem.ContainingProject.Object is SolutionFolder)
            {
                newValue = project.ParentProjectItem.ContainingProject as Project;
            }
            if (newValue != null && newValue != currentValue)
            {
                return(true);
            }
            return(false);
        }
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            newValue = null;
            if (currentValue == null)
            {
                CodeClass currentDSAClass = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                          currentDSAClassExpression) as CodeClass;
                Type proxyType = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                               proxyTypeExpression) as Type;

                if (currentDSAClass != null && proxyType != null)
                {
                    Type dsaType = DteConverter.ToType(currentDSAClass);
                    if (dsaType != null)
                    {
                        newValue = MethodBehaviorHelper.GetMethodsBehavior(dsaType, proxyType);
                    }
                }
            }
            return(currentValue != newValue);
        }
Esempio n. 25
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            DTE vs = GetService <DTE>(true);

            newValue = null;
            if (vs.SelectedItems.Item(1).Project == null)
            {
                ProjectItem webRef = vs.SelectedItems.Item(1).ProjectItem;
                if (webRef == null)
                {
                    throw new InvalidOperationException(Properties.Resources.NoProxyFound);
                }

                ProjectItem proxyItem = FindProxyClass(webRef.ProjectItems);
                if (proxyItem == null)
                {
                    throw new InvalidOperationException(Properties.Resources.NoProxyFound);
                }
                if (proxyItem.FileCodeModel == null)
                {
                    throw new InvalidOperationException(Properties.Resources.NoProxyFound);
                }

                bool   built      = true;
                object builtValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                  builtExpression);
                if (builtValue != null)
                {
                    built = (bool)builtValue;
                }

                if (built)
                {
                    CodeClass proxyTypeCodeClass = CodeModelHelper.FindFirstClass(proxyItem.FileCodeModel.CodeElements, CodeModelHelper.IsProxyClass);
                    newValue = DteConverter.ToType(proxyTypeCodeClass);
                }
            }
            return(true);
        }
        private bool Evaluate(object currentValue, out object newValue)
        {
            IDictionaryService dictionaryService = (IDictionaryService)GetService(typeof(IDictionaryService));

            Project project = ExpressionEvaluationHelper.EvaluateExpression(dictionaryService, _projectExpression) as Project;

            if (project != null)
            {
                newValue = null;
                try
                {
                    newValue = project.Properties.Item("DefaultNamespace").Value.ToString();
                }
                catch (ArgumentException)
                {
                    newValue = "";
                }
                return(true);
            }

            newValue = null;
            return(false);
        }
Esempio n. 27
0
        private bool IsWebProjectSelected(out Project webProject, out ProjectItem folder)
        {
            webProject = null;
            folder     = null;
            object project = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                           _webProjectExpression);

            if (project == null)
            {
                object projectItem = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                   _webFolderExpression);
                if (projectItem != null)
                {
                    folder = projectItem as ProjectItem;
                    return(false);
                }
            }
            else
            {
                webProject = project as Project;
                return(true);
            }
            return(true);
        }