Exemplo n.º 1
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            var service = base.GetService <DTE>(true);

            newValue = string.Empty;
            string selectedFolderPath = DteHelper.GetFilePathRelative((ProjectItem)DteHelper.GetTarget(service));

            string[] pathParts =
                selectedFolderPath.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
                                         StringSplitOptions.RemoveEmptyEntries);
            if (pathParts.Length > 3)
            {
                if (pathParts[1] == TemplateConfiguration.GetConfiguration().ExtRootFolderName&&
                    (pathParts[2].Equals(ExtJsClassType.Model.ToString(), StringComparison.InvariantCultureIgnoreCase) ||
                     pathParts[2].Equals(ExtJsClassType.View.ToString(), StringComparison.InvariantCultureIgnoreCase) ||
                     pathParts[2].Equals(ExtJsClassType.Store.ToString(), StringComparison.InvariantCultureIgnoreCase) ||
                     pathParts[2].Equals(ExtJsClassType.Controller.ToString(), StringComparison.InvariantCultureIgnoreCase)))
                {
                    for (var i = 3; i < pathParts.Length; i++)
                    {
                        newValue += pathParts[i] + ".";
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 public static bool IsTemplateEnabledFor(object target, string templateName, DTE service = null)
 {
     try
     {
         var selectedItem = target as ProjectItem;
         if (selectedItem == null)
         {
             return(false);
         }
         string selectedFolderPath = DteHelper.GetFilePathRelative(selectedItem);
         var    templatePath       = TemplateConfiguration.GetConfiguration(service).ExtRootFolderName + "\\" + templateName;
         var    wr = new StreamWriter(@"C:\test.text", true);
         if (selectedFolderPath.ToLower().Contains(templatePath.ToLower()))
         {
             wr.WriteLine("SelectedFolderPath:{0}, TemplatePath:{1}, Valid", selectedFolderPath, templatePath);
             wr.Close();
             return(true);
         }
         wr.WriteLine("SelectedFolderPath:{0}, TemplatePath:{1}, Invalid", selectedFolderPath, templatePath);
         wr.Close();
         return(false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format(ErrorMessages.GeneralError, ex.Message), MessageType.Error,
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return(false);
     }
 }
Exemplo n.º 3
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            var    service            = base.GetService <DTE>(true);
            string solutionFolderPath = Path.GetDirectoryName(service.Solution.FullName);

            newValue = Path.Combine(solutionFolderPath,
                                    DteHelper.GetFilePathRelative((ProjectItem)DteHelper.GetTarget(service)));
            return(true);
        }