コード例 #1
0
        public AboutBox()
        {
            InitializeComponent();

            foreach (Assembly s in AppDomain.CurrentDomain.GetAssemblies())
            {
                string[] lvsi = new string[3];
                lvsi[0] = s.GetName().Name;
                lvsi[1] = s.GetName().FullName;
                lvsi[2] = s.GetName().Version.ToString();
                ListViewItem lvi = new ListViewItem(lvsi, 0);
                this.ListOfAssemblies.Items.Add(lvi);
            }

            AssemblyCopyrightAttribute   objCopyright   = AssemblyCopyrightAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;
            AssemblyDescriptionAttribute objDescription = AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;
            AssemblyCompanyAttribute     objCompany     = AssemblyCompanyAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
            AssemblyTrademarkAttribute   objTrademark   = AssemblyTrademarkAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTrademarkAttribute)) as AssemblyTrademarkAttribute;
            AssemblyProductAttribute     objProduct     = AssemblyProductAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)) as AssemblyProductAttribute;
            AssemblyTitleAttribute       objTitle       = AssemblyTitleAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;
            GuidAttribute         objGuid         = GuidAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(GuidAttribute)) as GuidAttribute;
            DebuggableAttribute   objDebuggable   = DebuggableAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DebuggableAttribute)) as DebuggableAttribute;
            CLSCompliantAttribute objCLSCompliant = CLSCompliantAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(CLSCompliantAttribute)) as CLSCompliantAttribute;

            AppName.Text        = objProduct.Product;
            BigTitle.Text       = objTitle.Title;
            ProdVer.Text        = QuestDesignerMain.Version;
            AppDesc.Text        = objDescription.Description;
            CopyrightLabel.Text = objCopyright.Copyright;
            SerialNo.Text       = objGuid.Value;
            Company.Text        = objCompany.Company;
        }
コード例 #2
0
        private void ShowVersion()
        {
            AssemblyCompanyAttribute objCompany = (AssemblyCompanyAttribute)
                                                  AssemblyCompanyAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
                                                                                              typeof(AssemblyCompanyAttribute));
            AssemblyDescriptionAttribute objDescription = (AssemblyDescriptionAttribute)
                                                          AssemblyDescriptionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
                                                                                                          typeof(AssemblyDescriptionAttribute));
            AssemblyProductAttribute objProduct = (AssemblyProductAttribute)
                                                  AssemblyProductAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
                                                                                              typeof(AssemblyProductAttribute));
            AssemblyTitleAttribute objTitle = (AssemblyTitleAttribute)
                                              AssemblyTitleAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
                                                                                        typeof(AssemblyTitleAttribute));

            /*
             * AssemblyVersionAttribute objVersion = (AssemblyVersionAttribute)
             *  AssemblyVersionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
             *  typeof(AssemblyVersionAttribute));
             */
            StringBuilder sb = new StringBuilder();

            sb.Append("Product: ");
            sb.AppendLine(objProduct.Product);
            sb.Append("Title: ");
            sb.AppendLine(objTitle.Title);
            sb.Append("Company: ");
            sb.AppendLine(objCompany.Company);
            sb.Append("Description: ");
            sb.AppendLine(objDescription.Description);
            sb.Append("Version: ");
            sb.AppendLine(Assembly.GetExecutingAssembly().GetName().Version.ToString());
            this.AboutText.Text = sb.ToString();
        }
コード例 #3
0
    public static string GetAssemblyAuthor(Assembly asm)
    {
        if (asm == null)
        {
            return(string.Empty);
        }

        if (AssemblyCompanyAttribute.IsDefined(asm, typeof(AssemblyCompanyAttribute)))
        {
            AssemblyCompanyAttribute company = (AssemblyCompanyAttribute)
                                               AssemblyCompanyAttribute.GetCustomAttribute(asm, typeof(AssemblyCompanyAttribute));
            return(company.Company);
        }
        return(string.Empty);
    }
コード例 #4
0
        /// <summary>
        /// Gets the User's Application Data Folder for this application. Creates the folder if it does not exist, specifically the company name and application levels.
        /// </summary>
        /// <param name="productName">The name of the product.</param>
        /// <returns>Company and application user application data folder path.</returns>
        /// <remarks>
        /// Function returns base SpecialFolder.ApplicationData folder, 'C:\Documents and Settings\[User Name]\Application Data'
        /// but also includes CompanyFolderName constant and Product Name specified, e.g.
        ///     C:\Documents and Settings\My Name\Application Data\Konesans\ProductName
        /// </remarks>
        public static string ApplicationDataFolder(string productName)
        {
            string common = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            if (Directory.Exists(common))
            {
                AssemblyCompanyAttribute companyAttribute = (AssemblyCompanyAttribute)AssemblyCompanyAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute));
                string fullPath = Path.Combine(common, companyAttribute.Company);
                fullPath = Path.Combine(fullPath, productName);

                if (!Directory.Exists(fullPath))
                {
                    System.Diagnostics.Debug.WriteLine("Creating AppData Folder : " + fullPath);
                    Directory.CreateDirectory(fullPath);
                }

                return(fullPath);
            }
            else
            {
                throw new DirectoryNotFoundException(
                          String.Format(CultureInfo.CurrentCulture, "Directory for SpecialFolder.CommonApplicationData was not found, '{0}'", common));
            }
        }
コード例 #5
0
        private static void ReadGeneratorSettings()
        {
            var assembly         = typeof(Settings).Assembly;
            var companyAttribute = AssemblyCompanyAttribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
            var productAttribute = AssemblyProductAttribute.GetCustomAttribute(assembly, typeof(AssemblyProductAttribute)) as AssemblyProductAttribute;
            var companyName      = companyAttribute?.Company;
            var productName      = productAttribute?.Product;
            var specialPath      = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            if (!string.IsNullOrWhiteSpace(companyName) && !string.IsNullOrWhiteSpace(productName) && !string.IsNullOrWhiteSpace(specialPath))
            {
                var folder = Path.Combine(specialPath, companyName, productName);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                var filename = Path.Combine(folder, "settings.xml");
                if (!File.Exists(filename))
                {
                    new XDocument(new XElement("Settings")).Save(filename);
                    return;
                }

                var doc = XDocument.Load(filename);

                var requiredExtensions           = doc.Element("Settings").Elements("RequiredExtensions");
                var generatorExtensionDictionary =
                    requiredExtensions.Elements("Generator").Select(x =>
                {
                    Guid.TryParse(x.Element("Extension").Attribute("Guid").Value, out var guid);
                    return(new
                    {
                        ExtGuid = guid,
                        Generator = x.Attribute("Name"),
                        Command = x.Element("Extension").Attribute("Command").Value,
                        Param1 = x.Element("Extension").Attribute("Param1")?.Value,
                        Param2 = x.Element("Extension").Attribute("Param2")?.Value,
                        Param3 = x.Element("Extension").Attribute("Param3")?.Value,
                        Param4 = x.Element("Extension").Attribute("Param4")?.Value
                    });
                }).ToDictionary(g => g.Generator, g => new ExtensionCommand {
                    ExtensionGuid = g.ExtGuid,
                    Command       = g.Command,
                    Param1        = g.Param1,
                    Param2        = g.Param2,
                    Param3        = g.Param3,
                    Param4        = g.Param4
                });

                var lg = new List <Guid>();

                var stuff0 = (from element in doc.Element("Settings").Elements("RequiredExtensions")
                              .Elements("Generator").Elements("Extension")
                              select element
                              );


                var stuff = (from element in doc.Element("Settings").Elements("RequiredExtensions")
                             let gen = element.Elements("Generator").Elements("Extension")
                                       select gen
                             );

                var stuff2 = doc.Elements("Settings").Elements("RequiredExtensions")
                             .Elements("Generator").Elements("Extension").Select(e => (string)e.Attribute("Guid"));

                //Console.WriteLine($"stuff.Count is {stuff.Count()}");

                var r1 = doc.Element("Settings").Elements("RequiredExtensions");
                var r2 = r1.Elements("Generator").Elements("Extension");
                var r3 = r2.Attributes("Guid");

                //foreach (var p in generatorExtensionDictionary)
                //{
                //    var generatorName = p.Key;
                //    var guid = p.Value.Guid;
                //    Console.WriteLine($"key:{generatorName} guid:{guid}");
                //}
            }
            //var docPath =
            //XDocument xd = XDocument
        }