public AddViewDialog(DotNetProject project) { this.project = project; aspFlavor = project.GetService <AspNetAppProjectFlavor> (); Build(); provider = project.LanguageBinding.GetCodeDomProvider(); var viewEngines = GetProperViewEngines(); loadedTemplateList = new Dictionary <string, IList <string> > (); foreach (var engine in viewEngines) { viewEngineCombo.AppendText(engine); loadedTemplateList[engine] = aspFlavor.GetCodeTemplates("AddView", engine); } viewEngineCombo.Active = 0; InitializeTemplateStore(loadedTemplateList); ContentPlaceHolders = new List <string> (); string siteMaster = aspFlavor.VirtualToLocalPath("~/Views/Shared/Site.master", null); if (project.Files.GetFile(siteMaster) != null) { masterEntry.Text = "~/Views/Shared/Site.master"; } placeholderCombo.Model = primaryPlaceholderStore; UpdateTypePanelSensitivity(null, null); UpdateMasterPanelSensitivity(null, null); Validate(); }
/// <summary> /// Returns the IConnectedServicesBinding instance that is attached to the project. /// Use this to query state about connected services for a given project. /// </summary> public static IConnectedServicesBinding GetConnectedServicesBinding(this DotNetProject project) { if (project == null) { return(NullConnectedServicesBinding.Null); } // we should always have a binding for any given project because the extension loads for all projects return(project.GetService <IConnectedServicesBinding> ()); }
public AddControllerDialog(DotNetProject project) { Build(); var ext = project.GetService <AspNetAppProjectFlavor> (); provider = project.LanguageBinding.GetCodeDomProvider(); loadedTemplateList = ext.GetCodeTemplates("AddController"); bool foundEmptyTemplate = false; int templateIndex = 0; foreach (string file in loadedTemplateList) { string name = System.IO.Path.GetFileNameWithoutExtension(file); templateCombo.AppendText(name); if (!foundEmptyTemplate) { if (name == "Empty") { templateCombo.Active = templateIndex; foundEmptyTemplate = true; } else { templateIndex++; } } } if (!foundEmptyTemplate) { throw new Exception("The Empty.tt template is missing."); } nameEntry.Text = "Controller"; nameEntry.Position = 0; Validate(); }
public static BuildResult GenerateCodeBehind( DotNetProject project, string filename, WebFormsParsedDocument document, out CodeCompileUnit ccu) { ccu = null; var result = new BuildResult(); string className = document.Info.InheritedClass; AddErrorsToResult(result, filename, document.GetErrorsAsync().Result); if (result.ErrorCount > 0) { return(result); } if (string.IsNullOrEmpty(className)) { return(result); } var refman = new WebFormsTypeContext { Project = project, Doc = document }; refman.CreateCompilation(default(CancellationToken)).Wait(); var memberList = new WebFormsMemberListBuilder(refman, document.XDocument); memberList.Build(); AddErrorsToResult(result, filename, memberList.Errors); if (result.ErrorCount > 0) { return(result); } //initialise the generated type ccu = new CodeCompileUnit(); var namespac = new CodeNamespace(); ccu.Namespaces.Add(namespac); var typeDecl = new CodeTypeDeclaration { IsClass = true, IsPartial = true, }; namespac.Types.Add(typeDecl); //name the class and namespace int namespaceSplit = className.LastIndexOf('.'); if (namespaceSplit > -1) { namespac.Name = project.StripImplicitNamespace(className.Substring(0, namespaceSplit)); typeDecl.Name = className.Substring(namespaceSplit + 1); } else { typeDecl.Name = className; } string masterTypeName = null; if (!String.IsNullOrEmpty(document.Info.MasterPageTypeName)) { masterTypeName = document.Info.MasterPageTypeName; } else if (!String.IsNullOrEmpty(document.Info.MasterPageTypeVPath)) { try { var ext = project.GetService <AspNetAppProjectFlavor> (); ProjectFile resolvedMaster = ext.ResolveVirtualPath(document.Info.MasterPageTypeVPath, document.FileName); WebFormsParsedDocument masterParsedDocument = null; if (resolvedMaster != null) { masterParsedDocument = IdeApp.TypeSystemService.ParseFile(project, resolvedMaster.FilePath).Result as WebFormsParsedDocument; } if (masterParsedDocument != null && !String.IsNullOrEmpty(masterParsedDocument.Info.InheritedClass)) { masterTypeName = masterParsedDocument.Info.InheritedClass; } } catch (Exception ex) { LoggingService.LogWarning("Error resolving master page type", ex); } if (string.IsNullOrEmpty(masterTypeName)) { var msg = GettextCatalog.GetString("Could not find type for master '{0}'", document.Info.MasterPageTypeVPath); result.AddError(filename, msg); return(result); } } if (masterTypeName != null) { var masterProp = new CodeMemberProperty { Name = "Master", Type = new CodeTypeReference(masterTypeName), HasGet = true, HasSet = false, Attributes = MemberAttributes.Public | MemberAttributes.New | MemberAttributes.Final, }; masterProp.GetStatements.Add(new CodeMethodReturnStatement( new CodeCastExpression(masterTypeName, new CodePropertyReferenceExpression( new CodeBaseReferenceExpression(), "Master")))); typeDecl.Members.Add(masterProp); } //shortcut building the existing members type map if (memberList.Members.Count == 0) { return(result); } var cls = refman.GetTypeByMetadataName(className); var members = GetDesignerMembers(memberList.Members.Values, cls, filename); //add fields for each control in the page foreach (var member in members) { var type = new CodeTypeReference(member.Type.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat)); typeDecl.Members.Add(new CodeMemberField(type, member.Name) { Attributes = MemberAttributes.Family }); } return(result); }
public static IEnumerable <WebReferenceItem> GetWebReferenceItemsWCF(DotNetProject project) { var ext = project.GetService <WebReferencesProjectExtension> (); return(ext.GetWebReferenceItemsWCF()); }