public GetProjectProperty ( string propertyName ) : string | ||
propertyName | string | Name of Property to retrieve |
return | string |
public int get_CanonicalName(out string pbstrCanonicalName) { // Get the output assembly path (including the name) pbstrCanonicalName = project.GetProjectProperty(ProjectFileConstants.TargetPath); Debug.Assert(!String.IsNullOrEmpty(pbstrCanonicalName), "Output Assembly not defined"); // Make sure we have a full path if (!System.IO.Path.IsPathRooted(pbstrCanonicalName)) { pbstrCanonicalName = new Url(project.BaseURI, pbstrCanonicalName).AbsoluteUrl; } return(VSConstants.S_OK); }
// ========================================================================================= // Constructors // ========================================================================================= /// <summary> /// Initializes a new instance of the <see cref="XSharpBuildMacros"/> class. /// </summary> /// <param name="project">The project from which to read the properties.</param> public XBuildMacroCollection(ProjectNode project) { XHelperMethods.VerifyNonNullArgument(project, "project"); // get the global SolutionX properties XBuildMacroCollection.DefineSolutionProperties(project); foreach (string globalMacroName in globalMacroNames) { string property = null; project.BuildProject.GlobalProperties.TryGetValue(globalMacroName, out property); if (null == property) { this.list.Add(globalMacroName, "*Undefined*"); } else { this.list.Add(globalMacroName, property); } } // we need to call GetTargetPath first so that TargetDir and TargetPath are resolved correctly ConfigCanonicalName configCanonicalName; if (!Utilities.TryGetActiveConfigurationAndPlatform(project.Site, project, out configCanonicalName)) { throw new InvalidOperationException(); } BuildResult res = project.Build(configCanonicalName, XProjectFileConstants.GetTargetPath); // get the ProjectX and TargetX variables foreach (string macroName in macroNames) { string value; ThreadHelper.ThrowIfNotOnUIThread(); if (res.ProjectInstance != null) { value = res.ProjectInstance.GetPropertyValue(macroName); } else { value = project.GetProjectProperty(macroName); } this.list.Add(macroName, value); } }
public string GetFileNamespace(string fileFullPath, ProjectNode node) { if (node == null) { throw new ArgumentNullException("node"); } // Get base namespace from the project string namespce = node.GetProjectProperty("RootNamespace"); if(String.IsNullOrEmpty(namespce)) namespce = Path.GetFileNameWithoutExtension(fileFullPath); ; // If the item is added to a subfolder, the name space should reflect this. // This is done so that class names from 2 files with the same name but different // directories don't conflict. string relativePath = Path.GetDirectoryName(fileFullPath); string projectPath = Path.GetDirectoryName(node.GetMkDocument()); // Our project system only support adding files that are sibling of the project file or that are in subdirectories. if(String.Compare(projectPath, 0, relativePath, 0, projectPath.Length, true, CultureInfo.CurrentCulture) == 0) { relativePath = relativePath.Substring(projectPath.Length); } else { Debug.Fail("Adding an item to the project that is NOT under the project folder."); // We are going to use the full file path for generating the namespace } // Get the list of parts int index = 0; string[] pathParts; pathParts = relativePath.Split(Path.DirectorySeparatorChar); // Use a string builder with default size being the expected size StringBuilder result = new StringBuilder(namespce, namespce.Length + relativePath.Length + 1); // For each path part while(index < pathParts.Length) { string part = pathParts[index]; ++index; // This could happen if the path had leading/trailing slash, we want to ignore empty pieces if(String.IsNullOrEmpty(part)) continue; // If we reach here, we will be adding something, so add a namespace separator '.' result.Append('.'); // Make sure it starts with a letter if(!char.IsLetter(part, 0)) result.Append('N'); // Filter invalid namespace characters foreach(char c in part) { if(char.IsLetterOrDigit(c)) result.Append(c); } } return result.ToString(); }
public string GetFileNamespace(string fileFullPath, ProjectNode node) { if (node == null) { throw new ArgumentNullException("node"); } // Get base namespace from the project string namespce = node.GetProjectProperty("RootNamespace"); if (String.IsNullOrEmpty(namespce)) { namespce = Path.GetFileNameWithoutExtension(fileFullPath); } ; // If the item is added to a subfolder, the name space should reflect this. // This is done so that class names from 2 files with the same name but different // directories don't conflict. string relativePath = Path.GetDirectoryName(fileFullPath); string projectPath = Path.GetDirectoryName(node.GetMkDocument()); // Our project system only support adding files that are sibling of the project file or that are in subdirectories. if (String.Compare(projectPath, 0, relativePath, 0, projectPath.Length, true, CultureInfo.CurrentCulture) == 0) { relativePath = relativePath.Substring(projectPath.Length); } else { Debug.Fail("Adding an item to the project that is NOT under the project folder."); // We are going to use the full file path for generating the namespace } // Get the list of parts int index = 0; string[] pathParts; pathParts = relativePath.Split(Path.DirectorySeparatorChar); // Use a string builder with default size being the expected size StringBuilder result = new StringBuilder(namespce, namespce.Length + relativePath.Length + 1); // For each path part while (index < pathParts.Length) { string part = pathParts[index]; ++index; // This could happen if the path had leading/trailing slash, we want to ignore empty pieces if (String.IsNullOrEmpty(part)) { continue; } // If we reach here, we will be adding something, so add a namespace separator '.' result.Append('.'); // Make sure it starts with a letter if (!char.IsLetter(part, 0)) { result.Append('N'); } // Filter invalid namespace characters foreach (char c in part) { if (char.IsLetterOrDigit(c)) { result.Append(c); } } } return(result.ToString()); }
public virtual int get_Property(string pszProperty, out object pvar) { pvar = project.GetProjectProperty(pszProperty); return(VSConstants.S_OK); }
private string GetProperty( ProjectNode project, string name, string defaultValue ) { return project.GetProjectProperty( name ) ?? defaultValue; }
public virtual int get_Property(string pszProperty, out object pvar) { ThreadHelper.ThrowIfNotOnUIThread(); pvar = _project.GetProjectProperty(pszProperty); return(VSConstants.S_OK); }
public virtual int get_Property(string pszProperty, out object pvar) { pvar = project.GetProjectProperty(pszProperty, _PersistStorageType.PST_PROJECT_FILE); return(VSConstants.S_OK); }