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); } }
public static FileInfo[] GetListofFilesRaw(ExtJsClassType extJsClassType) { DirectoryInfo directoryInfo = TemplateConfiguration.GetConfiguration().SolutionFolderInfo; DirectoryInfo typeDirectory = directoryInfo.GetDirectories(extJsClassType.ToString(), SearchOption.AllDirectories)[0]; return(typeDirectory.GetFiles("*.js", SearchOption.AllDirectories)); }
public TypeFullName(string fullPath) { if (!string.IsNullOrEmpty(fullPath)) { string directoryName = Path.GetDirectoryName(fullPath); Namespace = directoryName.Substring(directoryName.IndexOf(TemplateConfiguration.GetConfiguration().ExtRootFolderName)); Name = Path.GetFileNameWithoutExtension(fullPath); } }
public static string Parse(string displayName) { if (displayName.Contains(Path.DirectorySeparatorChar)) { string[] nameParts = displayName.Split(' '); string nameSpace = nameParts[1]; var rootNamespace = TemplateConfiguration.GetConfiguration().ExtRootFolderName; return (nameSpace.Replace("(", string.Empty).Replace(")", string.Empty) .Replace(rootNamespace + @"\Model", string.Empty) .Replace(rootNamespace + @"\model", string.Empty) .Replace(rootNamespace + @"\Store", string.Empty) .Replace(rootNamespace + @"\store", string.Empty) .Replace(rootNamespace + @"\View", string.Empty) .Replace(rootNamespace + @"\view", string.Empty) .Replace('\\', '.') + "." + nameParts[0]); } else { return(displayName.Substring(displayName.IndexOf("(") + 1).Replace(")", string.Empty) + "." + displayName.Substring(0, displayName.IndexOf("(")).Trim()); } }
public static string GetCopyrightInfo(string fileName) { var CopyrightInfo = TemplateConfiguration.GetConfiguration().CopyrightInfo; return(String.Format(CopyrightInfo, fileName + ".js")); }