예제 #1
0
        private static void OutputProperties(StringBuilder output, EnvDTE.Properties properties, string indent)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            foreach (Property property in properties.Cast <Property>().OrderBy(p =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                return(p.Name);
            }))
            {
                OutputString(output, indent);
                OutputString(output, property.Name);
                OutputString(output, " = ");
                try
                {
                    object value = property.Value;
                    OutputString(output, Convert.ToString(value));
                }
                catch (Exception ex)
                {
                    // Pulling the value of any of the web properties (e.g., "WebServer")
                    // on a C# project will throw an exception if it isn't a web project.
                    OutputString(output, "*** " + ex.Message);
                }

                OutputString(output, Environment.NewLine);
            }
        }
예제 #2
0
        public static object GetProperty(EnvDTE.Properties properties, string name)
        {
            if (properties == null || string.IsNullOrEmpty(name))
            {
                return(null);
            }

            try
            {
                EnvDTE.Property property = properties.Cast <EnvDTE.Property>().FirstOrDefault(p => p.Name == name);
                if (property == null)
                {
                    return(null);
                }

                return(property.Value);
            }
            catch (InvalidCastException)
            {
                return(null);
            }
        }