private static bool IsImportPresentUnderNamespace(CodeElement codeElement, string productNamespace) { bool flag; IEnumerator enumerator = codeElement.Children.GetEnumerator(); try { while (enumerator.MoveNext()) { if (!CodeTypeFilter.IsNamespaceImportPresent((CodeElement)enumerator.Current, productNamespace)) { continue; } flag = true; return(flag); } return(false); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } return(flag); }
public static bool IsProductNamespaceImported(CodeType codeType, string productNamespace) { bool flag; if (codeType == null) { throw new ArgumentNullException("codeType"); } if (productNamespace == null) { throw new ArgumentNullException("productNamespace"); } FileCodeModel fileCodeModel = codeType.ProjectItem.FileCodeModel; if (fileCodeModel != null) { IEnumerator enumerator = fileCodeModel.CodeElements.GetEnumerator(); try { while (enumerator.MoveNext()) { CodeElement current = (CodeElement)enumerator.Current; if (!CodeTypeFilter.IsNamespaceImportPresent(current, productNamespace)) { if (!current.Kind.Equals(vsCMElement.vsCMElementNamespace) || !CodeTypeFilter.IsImportPresentUnderNamespace(current, productNamespace)) { continue; } flag = true; return(flag); } else { flag = true; return(flag); } } return(false); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } return(flag); } return(false); }
protected void CreateAppStartFiles(string configFileName, string productNamespace) { string str = configFileName; int num = 2; while (true) { Project activeProject = this.Context.ActiveProject; CodeType codeType = this.CodeTypeService.GetCodeType(activeProject, string.Concat(ProjectExtensions.GetDefaultNamespace(activeProject), ".", configFileName)); string str1 = string.Concat(configFileName, ".", ProjectExtensions.GetCodeLanguage(this.Context.ActiveProject).CodeFileExtension); string str2 = Path.Combine(ProjectExtensions.GetFullPath(this.Context.ActiveProject), "App_Start", str1); if (!File.Exists(Path.Combine(ProjectExtensions.GetFullPath(this.Context.ActiveProject), "App_Start", str1)) && codeType == null) { this.AppStartFileNames.Add(str, configFileName); this.GenerateT4File(str, configFileName, "App_Start"); return; } if (codeType != null && !codeType.Name.StartsWith("BundleConfig", StringComparison.OrdinalIgnoreCase) && CodeTypeFilter.IsProductNamespaceImported(codeType, productNamespace)) { this.AppStartFileNames.Add(str, configFileName); return; } if (codeType != null && codeType.Name.StartsWith("BundleConfig", StringComparison.OrdinalIgnoreCase) && AddDependencyUtil.IsSearchTextPresent(str2, "ScriptBundle(\"~/bundles/jquery\")")) { break; } configFileName = string.Concat(str, num); num++; } this.AppStartFileNames.Add(str, configFileName); }