Provides information about the current product.
Esempio n. 1
0
        private static ProductInfo GetProductInfo(Assembly assembly)
        {
            ProductInfo productInfo = new ProductInfo();

            object[] attributes = assembly.GetCustomAttributes(false);
            for (int i = 0; i < attributes.Length; i++) {
                object attr = attributes[i];
                if (attr is AssemblyCopyrightAttribute)
                    productInfo.Copyright = ((AssemblyCopyrightAttribute)attr).Copyright;
                else if (attr is AssemblyVersionAttribute)
                    productInfo.Version = new Version(((AssemblyVersionAttribute)attr).Version);
                else if (attr is AssemblyCompanyAttribute)
                    productInfo.Company = ((AssemblyCompanyAttribute)attr).Company;
                else if (attr is AssemblyTitleAttribute)
                    productInfo.Title = ((AssemblyTitleAttribute)attr).Title;
                else if (attr is AssemblyDescriptionAttribute)
                    productInfo.Description = ((AssemblyDescriptionAttribute)attr).Description;
            }

            return productInfo;
        }
Esempio n. 2
0
        private static ProductInfo GetProductInfo(Assembly assembly)
        {
            ProductInfo productInfo = new ProductInfo();

            #if PCL
            var attributes = assembly.GetCustomAttributes().ToArray();
            #else
            var attributes = assembly.GetCustomAttributes(true).ToArray();
            #endif
            for (int i = 0; i < attributes.Length; i++) {
                object attr = attributes[i];
                if (attr is AssemblyCopyrightAttribute)
                    productInfo.Copyright = ((AssemblyCopyrightAttribute)attr).Copyright;
                else if (attr is AssemblyVersionAttribute)
                    productInfo.Version = new Version(((AssemblyVersionAttribute)attr).Version);
                else if (attr is AssemblyCompanyAttribute)
                    productInfo.Company = ((AssemblyCompanyAttribute)attr).Company;
                else if (attr is AssemblyTitleAttribute)
                    productInfo.Title = ((AssemblyTitleAttribute)attr).Title;
                else if (attr is AssemblyDescriptionAttribute)
                    productInfo.Description = ((AssemblyDescriptionAttribute)attr).Description;
                else if (attr is AssemblyFileVersionAttribute)
                    productInfo.FileVersion = new Version(((AssemblyFileVersionAttribute) attr).Version);
                else if (attr is DataVersionAttribute)
                    productInfo.DataVersion = ((DataVersionAttribute)attr).Version;
            }

            return productInfo;
        }