/// <summary> /// Initializes a new instance of the <see cref="FormattingViewModel" /> class. /// </summary> /// <param name="package">The hosting package.</param> /// <param name="activeSettings">The active settings.</param> public FormattingViewModel(CodeMaidPackage package, Settings activeSettings) : base(package, activeSettings) { Mappings = new SettingsToOptionsList(ActiveSettings, this) { new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentRunDuringCleanup, x => CommentRunDuringCleanup), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentSkipWrapOnLastWord, x => CommentSkipWrapOnLastWord), new SettingToOptionMapping <int, int>(x => ActiveSettings.Formatting_CommentWrapColumn, x => CommentWrapColumn), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentXmlAlignParamTags, x => CommentXmlAlignParamTags), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentXmlKeepTagsTogether, x => CommentXmlKeepTagsTogether), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentXmlSpaceSingleTags, x => CommentXmlSpaceSingleTags), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentXmlSpaceTags, x => CommentXmlSpaceTags), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentXmlSplitAllTags, x => CommentXmlSplitAllTags), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentXmlSplitSummaryTagToMultipleLines, x => CommentXmlSplitSummaryTagToMultipleLines), new SettingToOptionMapping <bool, bool>(x => ActiveSettings.Formatting_CommentXmlTagsToLowerCase, x => CommentXmlTagsToLowerCase), new SettingToOptionMapping <int, int>(x => ActiveSettings.Formatting_CommentXmlValueIndent, x => CommentXmlValueIndent) }; _editorProperties = Package.IDE.Properties["FontsAndColors", "TextEditor"]; var property = _editorProperties.Item("FontsAndColorsItems"); var fontsAndColorsItems = (EnvDTE.FontsAndColorsItems)property.Object; _commentColors = fontsAndColorsItems.Item("Comment"); PropertyChanged += (sender, args) => UpdatePreviewText(); }
private static void SetMultiConfigArguments(EnvDTE.Project project, string arguments, string propertyName) { // Set the arguments only on the active configuration EnvDTE.Properties properties = project.ConfigurationManager?.ActiveConfiguration?.Properties; try { properties.Item(propertyName).Value = arguments; } catch (Exception ex) { Logger.Error($"Failed to set multi config arguments for project '{project.UniqueName}' with error '{ex}'"); } }
private static void UpdateCodeAnalysisRuleSetPropertyInConfiguration(EnvDTE.Configuration config, string oldRuleSetFilePath, string newRuleSetFilePath, string projectDirectoryFullPath) { EnvDTE.Properties properties = config.Properties; try { EnvDTE.Property codeAnalysisRuleSetFileProperty = properties?.Item("CodeAnalysisRuleSet"); if (codeAnalysisRuleSetFileProperty != null) { string codeAnalysisRuleSetFileName = codeAnalysisRuleSetFileProperty.Value as string; if (!string.IsNullOrWhiteSpace(codeAnalysisRuleSetFileName)) { string codeAnalysisRuleSetFullPath = FileUtilities.ResolveRelativePath(codeAnalysisRuleSetFileName, projectDirectoryFullPath); codeAnalysisRuleSetFullPath = FileUtilities.NormalizeAbsolutePath(codeAnalysisRuleSetFullPath); oldRuleSetFilePath = FileUtilities.NormalizeAbsolutePath(codeAnalysisRuleSetFullPath); if (codeAnalysisRuleSetFullPath.Equals(oldRuleSetFilePath, StringComparison.OrdinalIgnoreCase)) { string newRuleSetRelativePath = PathUtilities.GetRelativePath(projectDirectoryFullPath, newRuleSetFilePath); codeAnalysisRuleSetFileProperty.Value = newRuleSetRelativePath; } } } } catch (ArgumentException) { // Unfortunately the properties collection sometimes throws an ArgumentException // instead of returning null if the current configuration doesn't support CodeAnalysisRuleSet. // Ignore it and move on. } }
public static ValueType GetProjectProperty <ValueType>(EnvDTE.Project project, string propertyName, ValueType defaultValue) { ValueType returnValue = defaultValue; try { if (project != null) { EnvDTE.Properties properties = project.Properties; if (properties != null) { EnvDTE.Property property = properties.Item(propertyName); if (property != null) { object objValue = property.Value; if (objValue != null) { returnValue = (ValueType)objValue; } } } } } catch (Exception) { } return(returnValue); }
private EnvDTE.Properties TryGetStartupProjectProperties() { try { IVsSolutionBuildManager solutionBuildManager = GetGlobalService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager; if (solutionBuildManager == null) { return(null); } IVsHierarchy startupProject; if (ErrorHandler.Failed(solutionBuildManager.get_StartupProject(out startupProject)) || startupProject == null) { return(null); } EnvDTE.Properties properties = TryGetDtePropertiesFromHierarchy(startupProject); return(properties); } catch (Exception ex) { if (ErrorHandler.IsCriticalException(ex)) { throw; } return(null); } }
/// <summary> /// Parses the project-level properties, such as the project type /// and so on. /// </summary> private void parseProjectProperties() { // We convert the DTE properties to a map... EnvDTE.Properties dteProperties = Utils.call(() => (m_dteProject.Properties)); Dictionary <string, object> projectProperties = getProperties(dteProperties); // The project type (exe, library etc)... prjOutputType outputType = (prjOutputType)getIntProperty(projectProperties, "OutputType"); switch (outputType) { case prjOutputType.prjOutputTypeExe: m_projectInfo.ProjectType = ProjectInfo.ProjectTypeEnum.CSHARP_EXECUTABLE; break; case prjOutputType.prjOutputTypeLibrary: m_projectInfo.ProjectType = ProjectInfo.ProjectTypeEnum.CSHARP_LIBRARY; break; case prjOutputType.prjOutputTypeWinExe: m_projectInfo.ProjectType = ProjectInfo.ProjectTypeEnum.CSHARP_WINFORMS_EXECUTABLE; break; } // The output file name, e.g. TextLib.dll... m_projectInfo.OutputFileName = getStringProperty(projectProperties, "OutputFileName"); // The project folder, absolute and relative to the solution... m_projectInfo.RootFolderAbsolute = getStringProperty(projectProperties, "FullPath"); m_projectInfo.RootFolderRelative = Utils.makeRelativePath(m_solutionRootFolder, m_projectInfo.RootFolderAbsolute); }
private string TryGetStartupCommandArguments() { EnvDTE.Properties properties = TryGetStartupProjectProperties(); if (properties == null) { return(null); } try { // Iterating over the properties has proven much more reliable than calling Item() foreach (EnvDTE.Property property in properties) { foreach (var propertyName in KnownStartupProperties) { if (string.Equals(propertyName, property.Name, StringComparison.OrdinalIgnoreCase)) { return(property.Value as string); } } } return(null); } catch (Exception ex) { if (ErrorHandler.IsCriticalException(ex)) { throw; } return(null); } }
/// <summary> /// Initializes a new instance of the <see cref="FormattingViewModel" /> class. /// </summary> /// <param name="package">The hosting package.</param> /// <param name="activeSettings">The active settings.</param> public FormattingViewModel(CodeMaidPackage package, Settings activeSettings) : base(package, activeSettings) { Mappings = new SettingsToOptionsList(ActiveSettings, this) { new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentRunDuringCleanup, x => CommentRunDuringCleanup), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentSkipWrapOnLastWord, x => CommentSkipWrapOnLastWord), new SettingToOptionMapping<int, int>(x => ActiveSettings.Formatting_CommentWrapColumn, x => CommentWrapColumn), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentXmlAlignParamTags, x => CommentXmlAlignParamTags), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentXmlKeepTagsTogether, x => CommentXmlKeepTagsTogether), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentXmlSpaceSingleTags, x => CommentXmlSpaceSingleTags), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentXmlSpaceTags, x => CommentXmlSpaceTags), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentXmlSplitAllTags, x => CommentXmlSplitAllTags), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentXmlSplitSummaryTagToMultipleLines, x => CommentXmlSplitSummaryTagToMultipleLines), new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Formatting_CommentXmlTagsToLowerCase, x => CommentXmlTagsToLowerCase), new SettingToOptionMapping<int, int>(x => ActiveSettings.Formatting_CommentXmlValueIndent, x => CommentXmlValueIndent) }; _editorProperties = Package.IDE.Properties["FontsAndColors", "TextEditor"]; var property = _editorProperties.Item("FontsAndColorsItems"); var fontsAndColorsItems = (EnvDTE.FontsAndColorsItems)property.Object; _commentColors = fontsAndColorsItems.Item("Comment"); PropertyChanged += (sender, args) => UpdatePreviewText(); }
public static List <string> GetTextEditorProperties() { System.Type t = Connect.settingsObject.VisualStudioVersion; object obj = Activator.CreateInstance(t, true); dte2 = (DTE2)obj; sln2 = (Solution2)dte2.Solution; // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.90).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1 // Nested node doesn't work in C# as done in article with VB. // Tried different separators but have not found the right C# syntax. // Other links: // http://msdn.microsoft.com/en-us/library/ms165644.aspx // http://www.mztools.com/articles/2005/mz2005008.aspx // http://dotnet.dzone.com/articles/structure-visual-studio?page=0,1 EnvDTE.Properties txtEdCS = dte2.get_Properties("TextEditor", "CSharp - Formatting"); EnvDTE.Property prop = null; string msg = null; List <string> propList = new List <string>(); foreach (EnvDTE.Property temp in txtEdCS) { prop = temp; msg = ("Prop Name: " + prop.Name + " VALUE: " + prop.Value) + "\n"; propList.Add(msg); } return(propList); }
/// <summary> /// Determines whether [has public key] [the specified project props]. /// </summary> /// <param name="projectProps">The project props.</param> /// <returns> /// <c>true</c> if [has public key] [the specified project props]; otherwise, <c>false</c>. /// </returns> private static bool HasPublicKey(EnvDTE.Properties projectProps) { if (projectProps.Item("AssemblyOriginatorKeyFile").Value == null) { return(projectProps.Item("AssemblyKeyContainerName").Value != null); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="FormattingViewModel" /> class. /// </summary> /// <param name="package">The hosting package.</param> public FormattingViewModel(CodeMaidPackage package) : base(package) { _editorProperties = Package.IDE.Properties["FontsAndColors", "TextEditor"]; var property = _editorProperties.Item("FontsAndColorsItems"); var fontsAndColorsItems = (EnvDTE.FontsAndColorsItems)property.Object; _commentColors = fontsAndColorsItems.Item("Comment"); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName); //string title = "Command1"; // Show a message box to prove we were here //VsShellUtilities.ShowMessageBox( // this.package, // message, // title, // OLEMSGICON.OLEMSGICON_INFO, // OLEMSGBUTTON.OLEMSGBUTTON_OK, // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)Marshal.GetActiveObject("VisualStudio.DTE.15.0"); int i = dte.Solution.Projects.Count; // Happy days ! string fullPath = ""; string ProjectName = ""; string dacpac = ""; string profileName = ""; if (i > 0) { foreach (EnvDTE.Project p in dte.Solution.Projects) { fullPath = p.Properties.Item("FullPath").Value.ToString(); ProjectName = p.Name; dacpac = ProjectName + ".dacpac"; profileName = ProjectName + ".publish.xml"; EnvDTE.Properties pr = p.Properties; } } ekaIkkuna eka = new ekaIkkuna(); if (fullPath.EndsWith("\\")) { eka.buildPath = fullPath + "bin\\debug\\"; } else { eka.buildPath = fullPath + "\\bin\\debug\\"; } if (fullPath.IndexOf(' ') > -1) { eka.buildPath = @"""" + eka.buildPath + @""""; } eka.dacpacName = dacpac; eka.profileName = profileName; eka.ShowDialog(); }
public T GetOption <T>(string category, string page, string option, T defaultValue) { EnvDTE.Properties properties = _dteServices.Dte.Properties[category, page]; if (properties != null) { return((T)properties.Item(option).Value); } return(defaultValue); }
/// <summary> /// Helper function to get the text from a project item /// </summary> private static string GetPropertyValue(EnvDTE.Properties source, string name) { if (source == null || string.IsNullOrEmpty(name)) { return(string.Empty); } EnvDTE.Property property = source.Item(name); return(property != null?property.Value.ToString() : String.Empty); }
/// <summary> /// Parses on configuration. /// </summary> private void parseConfiguration(EnvDTE.Configuration dteConfiguration) { // We create a new configuration-info object and fill it in... ProjectConfigurationInfo_CSharp configurationInfo = new ProjectConfigurationInfo_CSharp(); configurationInfo.ParentProjectInfo = m_projectInfo; configurationInfo.Name = Utils.call(() => dteConfiguration.ConfigurationName); configurationInfo.Platform = Utils.call(() => dteConfiguration.PlatformName); // We parse the configuration's properties, and set configuration // seetings from them... EnvDTE.Properties dteProperties = Utils.call(() => (dteConfiguration.Properties)); Dictionary <string, object> properties = getProperties(dteProperties); // Whether to optimize... configurationInfo.Optimize = getBoolProperty(properties, "Optimize"); // The output path and intermediate path... configurationInfo.OutputFolder = getStringProperty(properties, "OutputPath"); configurationInfo.IntermediateFolder = getStringProperty(properties, "IntermediatePath"); // Whether to treat warnings as errors... configurationInfo.ThreatWarningsAsErrors = getBoolProperty(properties, "TreatWarningsAsErrors"); // Defined constants (DEBUG, TRACE etc)... string definedConstants = getStringProperty(properties, "DefineConstants"); foreach (string definedConstant in Utils.split(definedConstants, ';')) { configurationInfo.addDefinedConstant(definedConstant); } // Whether to add debug symbols to the output... configurationInfo.Debug = getBoolProperty(properties, "DebugSymbols"); // Comma separated list of warnings to ignore... string warningsToIgnore = getStringProperty(properties, "NoWarn"); foreach (string warningToIgnore in Utils.split(warningsToIgnore, ',')) { configurationInfo.addWarningToIgnore(warningToIgnore); } // DebugInfo, e.g. "full"... configurationInfo.DebugInfo = getStringProperty(properties, "DebugInfo"); // File alignment... configurationInfo.FileAlignment = getIntProperty(properties, "FileAlignment"); // Warning level... configurationInfo.WarningLevel = getIntProperty(properties, "WarningLevel"); // We add the configuration-info to the project-info... m_projectInfo.addConfigurationInfo(configurationInfo); }
/// <summary> /// Initializes a new instance of the <see cref="FormattingViewModel" /> class. /// </summary> /// <param name="package">The hosting package.</param> public FormattingViewModel(CodeMaidPackage package) : base(package) { _editorProperties = Package.IDE.Properties["FontsAndColors", "TextEditor"]; var property = _editorProperties.Item("FontsAndColorsItems"); var fontsAndColorsItems = (EnvDTE.FontsAndColorsItems)property.Object; _commentColors = fontsAndColorsItems.Item("Comment"); PropertyChanged += (sender, args) => UpdatePreviewText(); }
private string GetProperty(EnvDTE.Properties properties, string name) { foreach (EnvDTE.Property property in properties) { if (property.Name == name && property.Value != null) { return(property.Value.ToString()); } } return(String.Empty); }
/// <summary> /// Adds the key file to project. /// </summary> /// <param name="project">The project.</param> internal void AddKeyFileToProject(EnvDTE.Project project) { if (this.key != null) { string destinationFileName = Path.Combine(Path.GetDirectoryName(project.FullName), "key.snk"); this.key.SaveTo(destinationFileName); project.ProjectItems.AddFromFile(destinationFileName); EnvDTE.Properties properties = project.Properties; properties.Item("SignAssembly").Value = true; properties.Item("AssemblyOriginatorKeyFile").Value = "key.snk"; } }
/// <summary> /// Read all the comment tokens from the application object /// </summary> public void GetCommentTokens() { // Variables to represent the properties collection and each property in the Options dialog box. properties = default(EnvDTE.Properties); // Represents the Task List Node under the Enviroment node. properties = ApplicationObject.get_Properties("Environment", "TaskList"); // Represents the items in the comment Token list and their priorities (1-3/low-high). EnvDTE.Property commentProperties = properties.Item("CommentTokens"); TokensFull = (Object[])commentProperties.Value; }
/// <summary> /// Initializes a new instance of the <see cref="NodeItemProperty"/> class. /// </summary> /// <param name="o">The o.</param> /// <param name="name">The name.</param> public NodeItemProperty(object o, string name) { Name = name; if ((o as EnvDTE.Solution) != null) this.properties = (o as EnvDTE.Solution).Properties; else if ((o as EnvDTE.Project) != null) this.properties = (o as EnvDTE.Project).Properties; else if ((o as EnvDTE.ProjectItem) != null) this.properties = (o as EnvDTE.ProjectItem).Properties; }
public static EnvDTE.Property GetProperty(EnvDTE.Properties properties, string propertyName) { if (properties != null) { foreach (EnvDTE.Property item in properties) { if (item != null && item.Name == propertyName) { return(item); } } } return(null); }
private bool HasProperty(EnvDTE.Properties properties, string name) { foreach (dynamic p in properties) { try { if (name == p.Name) { return(true); } } catch { continue; } } return(false); }
private object GetPropertyObject(EnvDTE.Properties properties, string name) { foreach (dynamic p in properties) { try { if (name == p.Name) { return(p.Object); } } catch { continue; } } return(null); }
public static bool GetPropertyString(EnvDTE.Properties properties, string propertyName, out string sValueOut) { if (properties != null) { foreach (EnvDTE.Property item in properties) { if (item != null && item.Name == propertyName) { sValueOut = (string)item.Value; return(true); } } } sValueOut = null; return(false); }
EnvDTE.Property GetPropertySave(string name, bool onConfig) { EnvDTE.Property property = null; EnvDTE.Properties props = null; ThreadHelper.ThrowIfNotOnUIThread(); try { if (onConfig) { EnvDTE.ConfigurationManager confManager = this.ReferencedProjectObject.ConfigurationManager; if (null != confManager) { // Get the active configuration. EnvDTE.Configuration config = confManager.ActiveConfiguration; if (null != config) { // Get the output path for the current configuration. var obj = config.Properties; EnvDTE.Properties props1 = obj; if (null != props1) { property = props1.Item(name); } } } } else { // Most project types should implement the OutputPath property on their // configuration-dependent Properties object above. But if it wasn't found // there, check the project node Properties. props = this.ReferencedProjectObject.Properties; if (null != props) { property = props.Item(name); } } } catch (COMException) { } catch (ArgumentException) { } return(property); }
/// <summary> /// The current comments are retrieved by obtaining the Properites object from the /// Tools Options window associated with the Academic toolset and walking down the /// set of registered file extensions looking for the one corresponding to /// the file type currently opened. /// </summary> private CommentPair GetCurrentComments() { EnvDTE.Document document = null; EnvDTE.TextDocument textDocument = null; EnvDTE.Properties extractorProperties = null; Extensions extensions = null; string extension; int lastIndex; try { // While we don't *do* anything with the document object, we check for its presence because // we only know how to do insertions on the TextDocument class of object. document = m_applicationObject.ActiveDocument; if ((document == null) || ((textDocument = document.Object("TextDocument") as EnvDTE.TextDocument) == null)) { return(null); } extension = m_applicationObject.ActiveDocument.Name; lastIndex = extension.LastIndexOf('.'); if (lastIndex == -1) { return(null); } extension = extension.Remove(0, lastIndex + 1); // Trim off the 'name.' part of 'name.ext' extractorProperties = m_applicationObject.get_Properties("Assignment Manager", "Code Extractor"); if (extractorProperties == null) { throw new Exception(AMResources.GetLocalizedString("CollapseMarkedInvalidInstallation")); } extensions = extractorProperties.Item("Extensions").Object as Extensions; if (extensions == null) { throw new Exception(AMResources.GetLocalizedString("CollapseMarkedInvalidInstallation")); } return(extensions[extension]); } catch (Exception) { return(null); } }
internal static EnvDTE.Property GetDTEProperty(EnvDTE.Properties pProperties, string propertyName) { StringBuilder str = new StringBuilder(); EnvDTE.Property prop = null; foreach (EnvDTE.Property p in pProperties) { str.AppendLine(p.Name); if (p.Name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase)) { prop = ((EnvDTE.Property)pProperties.Item(propertyName)); break; } } return(prop); }
/// <summary> /// Find all .cs files in the project, including sub-folders. /// </summary> private void findFiles(EnvDTE.ProjectItems projectItems, HashSet <FileInfo> files) { // We look through the items... int numProjectItems = Utils.call(() => (projectItems.Count)); for (int i = 1; i <= numProjectItems; ++i) { EnvDTE.ProjectItem projectItem = Utils.call(() => (projectItems.Item(i))); // We get the full-path... EnvDTE.Properties dteProperties = Utils.call(() => (projectItem.Properties)); Dictionary <string, object> properties = getProperties(dteProperties); string fullPath = getStringProperty(properties, "FullPath"); int copyToOutputFolder = getIntProperty(properties, "CopyToOutputDirectory"); // We check if it is a file (it could be a folder instead)... if (File.Exists(fullPath) == true) { // We add it to the list of files... FileInfo fileInfo = new FileInfo(); fileInfo.AbsolutePath = fullPath; fileInfo.RelativePath = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, fullPath); fileInfo.CopyToOutputFolder = (copyToOutputFolder != 0); files.Add(fileInfo); } // We see if the item itself has sub-items... EnvDTE.ProjectItems subItems = Utils.call(() => (projectItem.ProjectItems)); if (subItems != null) { findFiles(subItems, files); } // We see if this item has a sub-project... EnvDTE.Project subProject = Utils.call(() => (projectItem.SubProject)); if (subProject != null) { EnvDTE.ProjectItems subProjectItems = Utils.call(() => (subProject.ProjectItems)); findFiles(subProjectItems, files); } } }
public static T Get <T>(this PropertyCollection properties, string key) { if (properties != null) { foreach (Property property in properties) { if (property.Name == key) { var raw = property.Value; if (raw != null) { return((T)raw); } } } } return(default(T)); }
/// <summary> /// Gets the public key. /// </summary> /// <param name="project">The project.</param> /// <returns></returns> internal bool GetPublicKey(EnvDTE.Project project) { EnvDTE.Properties projectProps = project.Properties; if (!HasPublicKey(projectProps)) { return(false); } string str = (string)projectProps.Item("AssemblyOriginatorKeyFile").Value; if (str != null) { string fullPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(project.FileName), str)); this.key = StrongNameKey.Load(fullPath); } else { string keyContainer = (string)projectProps.Item("AssemblyKeyContainerName").Value; this.key = StrongNameKey.LoadContainer(keyContainer); } return(true); }
private string[] GetProperties(EnvDTE.Properties properties, params string[] names) { string[] values = new string[names.Length]; foreach (dynamic p in properties) { try { ShowMessage("Name: " + p.Name + ", Value: " + p.Value); for (int i = 0; i < names.Length; i++) { if (names[i] == p.Name) { values[i] = p.Value; break; } } } catch { continue; } } return(values); }
/// <summary> /// Converts the collection of properties passed in into a map /// of string -> object. /// </summary> private Dictionary <string, object> getProperties(EnvDTE.Properties dteProperties) { Dictionary <string, object> results = new Dictionary <string, object>(); // Some properties do not seem to have valid values. These are // the main ones we have trouble with, so we will ignore them and // not try to retrieve their values... HashSet <string> slowProperties = new HashSet <string> { "WebServer", "ServerExtensionsVersion", "OfflineURL", "WebServerVersion", "WebAccessMethod", "ActiveFileSharePath", "AspnetVersion", "FileSharePath" }; // We loop through the properties... int numProperties = Utils.call(() => (dteProperties.Count)); for (int i = 1; i <= numProperties; ++i) { try { EnvDTE.Property dteProperty = Utils.call(() => (dteProperties.Item(i))); string propertyName = Utils.call(() => (dteProperty.Name)); if (slowProperties.Contains(propertyName) == true) { // This is one of the properties to ignore... continue; } object propertyValue = Utils.call(() => (dteProperty.Value)); results[propertyName] = propertyValue; } catch (Exception) { // Some of the properties don't seem to have valid values. // I'm not really sure why this is. But we silently catch // the exception, as they don't seem to be the properties // we need anyway. } } return(results); }
private string TryGetStartupCommandArgumentsPropertyName() { try { EnvDTE.Properties properties = TryGetStartupProjectProperties(); if (properties == null) { return(null); } return(KnownStartupProperties.FirstOrDefault(i => properties.OfType <EnvDTE.Property>().Any(property => string.Equals(i, property.Name, StringComparison.OrdinalIgnoreCase)))); } catch (Exception ex) { if (ErrorHandler.IsCriticalException(ex)) { throw; } return(null); } }
public Options(EnvDTE.Properties properties) { _properties = properties; }