コード例 #1
0
ファイル: ProgramInfo.cs プロジェクト: keutmann/wspbuilder
        public string InfoString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Environment.NewLine);

            AssemblyTitleAttribute titleAttrib = (AssemblyTitleAttribute)GetAttribute(typeof(AssemblyTitleAttribute));

            sb.Append(titleAttrib.Title + Environment.NewLine);

            AssemblyFileVersionAttribute versionAttrib = (AssemblyFileVersionAttribute)GetAttribute(typeof(AssemblyFileVersionAttribute));

            if (versionAttrib != null)
            {
                sb.Append("Version: " + versionAttrib.Version.ToString() + Environment.NewLine);
            }

            AssemblyDescriptionAttribute descriptionAttrib = (AssemblyDescriptionAttribute)GetAttribute(typeof(AssemblyDescriptionAttribute));

            sb.Append(descriptionAttrib.Description + Environment.NewLine);

            AssemblyCompanyAttribute companyAttrib = (AssemblyCompanyAttribute)GetAttribute(typeof(AssemblyCompanyAttribute));

            sb.Append(companyAttrib.Company + Environment.NewLine);

            AssemblyCopyrightAttribute copyrightAttrib = (AssemblyCopyrightAttribute)GetAttribute(typeof(AssemblyCopyrightAttribute));

            sb.Append(copyrightAttrib.Copyright + Environment.NewLine);

            sb.Append(Environment.NewLine);

            return(sb.ToString());
        }
コード例 #2
0
        /// <summary>
        /// AppData\Roamingディレクトリの取得
        /// </summary>
        /// <returns></returns>
        public static string GetUserAppDataPath()
        {
            string   path = string.Empty;
            Assembly assembly;
            Type     at;

            object[] r;

            // Get the .EXE assembly
            assembly = Assembly.GetEntryAssembly();
            // Get a 'Type' of the AssemblyCompanyAttribute
            at = typeof(AssemblyCompanyAttribute);
            // Get a collection of custom attributes from the .EXE assembly
            r = assembly.GetCustomAttributes(at, false);
            // Get the Company Attribute
            AssemblyCompanyAttribute ct =
                ((AssemblyCompanyAttribute)(r[0]));

            // Build the User App Data Path
            path = Environment.GetFolderPath(
                Environment.SpecialFolder.ApplicationData);
            //path += @"\" + ct.Company;
            //path += @"\" + assembly.GetName().Version.ToString();
            return(path);
        }
コード例 #3
0
ファイル: Attributes.cs プロジェクト: layomia/dotnet_runtime
        public static void PositiveTest2()
        {
            Assembly element       = typeof(AttributeGetCustomAttributes).Assembly;
            Type     attributeType = typeof(AssemblyDescriptionAttribute);
            AssemblyDescriptionAttribute attributeVal = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(element, attributeType, false);

            Assert.True(attributeVal != null);

            attributeType = typeof(AssemblyCopyrightAttribute);
            AssemblyCopyrightAttribute attributeVal1 = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(element, attributeType, false);

            Assert.True(attributeVal1 != null);

            attributeType = typeof(AssemblyCompanyAttribute);
            AssemblyCompanyAttribute attributeVal2 = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(element, attributeType, false);

            Assert.True(attributeVal2 != null);

            attributeType = typeof(AssemblyKeyNameAttribute);
            Attribute attributeVal3 = Attribute.GetCustomAttribute(element, attributeType, false);

            Assert.True(attributeVal3 == null);

            attributeType = typeof(AssemblyInformationalVersionAttribute);
            attributeVal3 = Attribute.GetCustomAttribute(element, attributeType, false);
            Assert.True(attributeVal3 != null);
        }
コード例 #4
0
        public AboutControlViewModel()
        {
            Window = new Window();
            Window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            Window.SizeToContent         = SizeToContent.WidthAndHeight;
            Window.ResizeMode            = ResizeMode.NoResize;
            Window.WindowStyle           = WindowStyle.None;

            Window.ShowInTaskbar = false;
            Window.Title         = "About";
            Window.Deactivated  += Window_Deactivated;

            Assembly assembly = Assembly.GetEntryAssembly();

            Version = assembly.GetName().Version.ToString() + "  (For So-an)";
            Title   = assembly.GetName().Name;

#if NET35 || NET40
            AssemblyCopyrightAttribute   copyright   = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;
            AssemblyDescriptionAttribute description = Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;
            AssemblyCompanyAttribute     company     = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
#else
            AssemblyCopyrightAttribute   copyright   = assembly.GetCustomAttribute <AssemblyCopyrightAttribute>();
            AssemblyDescriptionAttribute description = assembly.GetCustomAttribute <AssemblyDescriptionAttribute>();
            AssemblyCompanyAttribute     company     = assembly.GetCustomAttribute <AssemblyCompanyAttribute>();
#endif
            Copyright   = copyright.Copyright;
            Description = description.Description;
            Publisher   = company.Company;

            AdditionalNotes = "Further information about ... InformationInformationInformationInformationInformationInformationInformationInformation";
        }
コード例 #5
0
        private void InitializeAssemblyInfo()
        {
            var assembly = Assembly.GetExecutingAssembly();

            Title   = assembly.GetName().Name;
            Version = assembly.GetName().Version.ToString();

            AssemblyCopyrightAttribute copyRightAttribute =
                GetAssemblyAttribute <AssemblyCopyrightAttribute>(assembly);

            if (copyRightAttribute != null)
            {
                CopyRight = copyRightAttribute.Copyright;
            }

            AssemblyCompanyAttribute companyNameAttribute =
                GetAssemblyAttribute <AssemblyCompanyAttribute>(assembly);

            if (companyNameAttribute != null)
            {
                CompanyName = companyNameAttribute.Company;
            }

            Location = assembly.Location;
        }
コード例 #6
0
        public string ReadAssemblyCompany()
        {
            Type t = typeof(Program);
            AssemblyCompanyAttribute productAttr = t.Assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true)[0] as AssemblyCompanyAttribute;

            return(productAttr.Company);
        }
コード例 #7
0
        public static string GetAssemblyCompany()
        {
            Assembly assembly = HttpContext.Current.ApplicationInstance.GetType().BaseType.Assembly;
            AssemblyCompanyAttribute assemblyCompanyAttribute = (AssemblyCompanyAttribute)(Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute), false));

            return(assemblyCompanyAttribute.Company);
        }
コード例 #8
0
        private static string ConstructPath(System.Environment.SpecialFolder baseFolder)
        {
            string companyPart = string.Empty;
            string appNamePart = string.Empty;

            Assembly entryAssembly = Assembly.GetEntryAssembly();

            if (entryAssembly != null)//for unit tests entryAssembly == null
            {
                AssemblyCompanyAttribute companyAttribute = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyCompanyAttribute));
                if (!string.IsNullOrEmpty(companyAttribute.Company))
                {
                    companyPart = string.Format("{0}\\", companyAttribute.Company);
                }
                AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyTitleAttribute));
                if (!string.IsNullOrEmpty(titleAttribute.Title))
                {
                    appNamePart = string.Format("{0}\\", titleAttribute.Title);
                }
            }

            string backingFilePath = Path.Combine(
                Environment.GetFolderPath(baseFolder),
                string.Format(@"{0}{1}tracked_settings.xml", companyPart, appNamePart)
                );

            return(backingFilePath);
        }
コード例 #9
0
        private static bool HasAemManagerRegistrySettings()
        {
            Assembly assembly = Assembly.GetEntryAssembly();
            AssemblyCompanyAttribute attrCompany = (AssemblyCompanyAttribute)assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true)[0];
            AssemblyTitleAttribute   attrTitle   = (AssemblyTitleAttribute)assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true)[0];

            RegistryKey keyUser     = Registry.CurrentUser;
            RegistryKey keySoftware = keyUser.OpenSubKey("Software", false);
            RegistryKey keyCompany  = keySoftware.OpenSubKey(attrCompany.Company, false);

            if (keyCompany == null)
            {
                return(false);
            }
            RegistryKey keyApplication = keyCompany.OpenSubKey(attrTitle.Title, false);

            if (keyApplication == null)
            {
                return(false);
            }

            RegistryKey keyInstances = keyApplication.OpenSubKey("Instances", false);

            return(keyInstances != null);
        }
コード例 #10
0
        private void FillInInfo()
        {
            Assembly app = Assembly.GetExecutingAssembly();

            AssemblyTitleAttribute       title       = (AssemblyTitleAttribute)app.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0];
            AssemblyProductAttribute     product     = (AssemblyProductAttribute)app.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];
            AssemblyCopyrightAttribute   copyright   = (AssemblyCopyrightAttribute)app.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0];
            AssemblyCompanyAttribute     company     = (AssemblyCompanyAttribute)app.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0];
            AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)app.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0];

            System.Version version = app.GetName().Version;

            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                version = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion;
            }

            SetCurrentValue(TitleProperty, System.String.Format("About {0}", title.Title));
            lblName.SetCurrentValue(TextBlock.TextProperty, title.Title);
            lblDescription.SetCurrentValue(TextBlock.TextProperty, description.Description);
            lblVersion.SetCurrentValue(TextBlock.TextProperty, System.String.Format("Version {0}", version.ToString()));
            lblCopyright.SetCurrentValue(TextBlock.TextProperty, copyright.Copyright.ToString());
            lblCompany.SetCurrentValue(TextBlock.TextProperty, company.Company);
            lblDisclaimer.SetCurrentValue(TextBlock.TextProperty, "All rights reserved.");
        }
コード例 #11
0
ファイル: AboutForm.cs プロジェクト: abbazs/SolidEdgeSpy
        private void AboutForm_Load(object sender, EventArgs e)
        {
            LinkLabel.Link link = new LinkLabel.Link();
            link.LinkData = Resources.ProjectUrl;
            linkCodeplex.Links.Add(link);

            Assembly     assembly     = Assembly.GetExecutingAssembly();
            AssemblyName assemblyName = assembly.GetName();

            AssemblyCompanyAttribute     asemblyCompanyAttribute      = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false).OfType <AssemblyCompanyAttribute>().FirstOrDefault();
            AssemblyDescriptionAttribute assemblyDescriptionAttribute = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false).OfType <AssemblyDescriptionAttribute>().FirstOrDefault();

            List <ListViewItem> items = new List <ListViewItem>();

            if (assemblyDescriptionAttribute != null)
            {
                items.Add(new ListViewItem(new string[] { "Description", assemblyDescriptionAttribute.Description }));
            }

            if (asemblyCompanyAttribute != null)
            {
                items.Add(new ListViewItem(new string[] { "Author", asemblyCompanyAttribute.Company }));
            }

            items.Add(new ListViewItem(new string[] { "Version", assemblyName.Version.ToString() }));
            items.Add(new ListViewItem(new string[] { "Website", Resources.ProjectUrl }));
            items.Add(new ListViewItem(new string[] { ".NET Runtime Version", assembly.ImageRuntimeVersion }));
            items.Add(new ListViewItem(new string[] { "Solid Edge Version", GetSolidEdgeVersion() }));

            listView.Items.AddRange(items.ToArray());
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }
コード例 #12
0
        /// <summary>
        /// Gets the usage text. Usage text is generated by obtaining the assembly's properties and displaying the
        /// validation <see cref="Argument"/> descriptions.
        /// </summary>
        /// <returns>Usage</returns>
        protected virtual string Usage()
        {
            StringBuilder usageTxt = new StringBuilder();
            Assembly      asm      = Assembly.GetEntryAssembly();

            // This was added for unit tests. For some reason there isn't an EntryAssembly so use
            if (asm == null)
            {
                asm = Assembly.GetCallingAssembly();
            }

            AssemblyDescriptionAttribute ada  = ((AssemblyDescriptionAttribute)asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]);
            AssemblyCopyrightAttribute   acra = ((AssemblyCopyrightAttribute)asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]);
            AssemblyCompanyAttribute     aca  = ((AssemblyCompanyAttribute)asm.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]);

            usageTxt.AppendFormat($"{ada.Description} version {asm.GetName().Version.ToString()}\n");
            usageTxt.AppendLine(acra.Copyright);
            usageTxt.AppendLine();
            usageTxt.AppendFormat($"  {Path.GetFileNameWithoutExtension(asm.ManifestModule.Name)}");

            this.Sort((a, b) => b.IsRequired.CompareTo(a.IsRequired));
            this.ForEach(p => usageTxt.AppendFormat($" {p.Syntax}"));
            usageTxt.AppendLine();
            usageTxt.AppendLine();
            this.ForEach(p => usageTxt.AppendLine(p.GetUsage()));

            return(usageTxt.ToString());
        }
コード例 #13
0
        /// <summary>
        /// Fixes the license placeholder.
        /// </summary>
        /// <remarks>
        /// This method fixes the license placeholder if necessary.
        /// </remarks>
        /// <param name="value">
        /// The help license attribute to be fixed.
        /// </param>
        /// <returns>
        /// The fixed help license attribute.
        /// </returns>
        private HelpLicenseAttribute FixupLicense(HelpLicenseAttribute value)
        {
            if (value.IsContent)
            {
                if (value.Content.Contains(Placeholders.Copyright))
                {
                    try
                    {
                        AssemblyCopyrightAttribute copyright = Assembly.GetEntryAssembly().GetCustomAttributes()
                                                               .Where(x => x is AssemblyCopyrightAttribute).FirstOrDefault() as AssemblyCopyrightAttribute;

                        if (copyright != null && !String.IsNullOrWhiteSpace(copyright.Copyright))
                        {
                            value.Content = value.Content.Replace(Placeholders.Copyright, copyright.Copyright);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception);
                    }
                }

                if (value.Content.Contains(Placeholders.Company))
                {
                    try
                    {
                        AssemblyCompanyAttribute company = Assembly.GetEntryAssembly().GetCustomAttributes()
                                                           .Where(x => x is AssemblyCompanyAttribute).FirstOrDefault() as AssemblyCompanyAttribute;

                        if (company != null && !String.IsNullOrWhiteSpace(company.Company))
                        {
                            value.Content = value.Content.Replace(Placeholders.Company, company.Company);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception);
                    }
                }

                if (value.Content.Contains(Placeholders.Version))
                {
                    try
                    {
                        String version = Assembly.GetEntryAssembly().GetName().Version.ToString();

                        if (!String.IsNullOrWhiteSpace(version))
                        {
                            value.Content = value.Content.Replace(Placeholders.Version, version);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception);
                    }
                }
            }

            return(value);
        }
コード例 #14
0
        private void Itm_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string   path        = e.Item.Tag.ToString();
            Assembly DllAssembly = Assembly.LoadFrom(path);
            AssemblyFileVersionAttribute VersionInfo     = DllAssembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0] as AssemblyFileVersionAttribute;
            AssemblyCompanyAttribute     CompanyInfo     = DllAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0] as AssemblyCompanyAttribute;
            AssemblyProductAttribute     ProductInfo     = DllAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0] as AssemblyProductAttribute;
            AssemblyTitleAttribute       TitleInfo       = DllAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute;
            AssemblyCopyrightAttribute   CopyrightInfo   = DllAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute;
            AssemblyDescriptionAttribute DescriptionInfo = DllAssembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute;

            Type[] type_list = DllAssembly.GetExportedTypes();
            foreach (Type outerForm in type_list)
            {
                //Type outerForm = DllAssembly.GetTypes()[3];
                if (outerForm.BaseType.Name == "XtraUserControl")
                {
                    var obj = (Activator.CreateInstance(outerForm) as XtraUserControl);
                    obj.Dock = DockStyle.Fill;
                    this.panelControl1.Controls.Clear();
                    this.panelControl1.Controls.Add(obj);
                    break;
                }
                else if (outerForm.BaseType.Name == "ToolbarForm")
                {
                    var obj = (Activator.CreateInstance(outerForm) as ToolbarForm);
                    obj.ShowDialog();
                    break;
                }
            }
        }
コード例 #15
0
        public static RegistryKey GetRootKey(ref string ErrorMessage)
        {
            RegistryKey currentUser = Registry.CurrentUser;

            try
            {
                Assembly entryAssembly              = Assembly.GetEntryAssembly();
                AssemblyCompanyAttribute attribute  = (AssemblyCompanyAttribute)GetAttribute(entryAssembly, typeof(AssemblyCompanyAttribute));
                AssemblyTitleAttribute   attribute2 = (AssemblyTitleAttribute)GetAttribute(entryAssembly, typeof(AssemblyTitleAttribute));
                string      str  = (attribute2 != null) ? attribute2.Title : entryAssembly.GetName().Name;
                string      str2 = (attribute != null) ? attribute.Company : "";
                string      name = $"Software\\{str2}\\{str}";
                RegistryKey key2 = currentUser.OpenSubKey(name, true);
                if (key2 == null)
                {
                    return(currentUser.CreateSubKey(name));
                }
                currentUser = key2;
            }
            catch (Exception exception)
            {
                ErrorMessage = exception.Message;
            }
            return(currentUser);
        }
コード例 #16
0
ファイル: ExportHelper.cs プロジェクト: VsPun/pyExcel
        public ExportHelper()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();

            _companyAttribute = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute));
            _productAttribute = (AssemblyProductAttribute)Attribute.GetCustomAttribute(assembly, typeof(AssemblyProductAttribute));
        }
コード例 #17
0
ファイル: Help.cs プロジェクト: keutmann/wspbuilder
        public string Copyleft()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(LINEBREAK);

            AssemblyTitleAttribute titleAttrib = (AssemblyTitleAttribute)GetAttribute(typeof(AssemblyTitleAttribute));

            sb.Append(titleAttrib.Title + LINEBREAK + LINEBREAK);

            AssemblyFileVersionAttribute versionAttrib = (AssemblyFileVersionAttribute)GetAttribute(typeof(AssemblyFileVersionAttribute));

            if (versionAttrib != null)
            {
                sb.Append("Version: " + versionAttrib.Version.ToString() + LINEBREAK);
            }

            AssemblyCompanyAttribute companyAttrib = (AssemblyCompanyAttribute)GetAttribute(typeof(AssemblyCompanyAttribute));

            sb.Append(companyAttrib.Company + LINEBREAK);
            AssemblyCopyrightAttribute copyrightAttrib = (AssemblyCopyrightAttribute)GetAttribute(typeof(AssemblyCopyrightAttribute));

            sb.Append(copyrightAttrib.Copyright + LINEBREAK);

            return(sb.ToString());
        }
コード例 #18
0
        /// <summary>
        /// The GetUserAppDataPath
        /// </summary>
        /// <returns>The <see cref="string"/></returns>
        public static string GetUserAppDataPath()
        {
            Assembly assm;
            Type     at;

            object[] r;

            // Get the .EXE assembly
            assm = Assembly.GetEntryAssembly();

            // Get a 'Type' of the AssemblyCompanyAttribute
            at = typeof(AssemblyCompanyAttribute);

            // Get a collection of custom attributes from the .EXE assembly
            r = assm.GetCustomAttributes(at, false);

            // Get the Company Attribute
            AssemblyCompanyAttribute ct =
                (AssemblyCompanyAttribute)r[0];

            // Build the User App Data Path
            return(System.IO.Path.Combine(
                       Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                       ct.Company,
                       assm.GetName().Name,
                       assm.GetName().Version.ToString()));
        }
コード例 #19
0
        public static string GetUserAppDataPath()
        {
            string   path = string.Empty;
            Assembly assm;
            Type     at;

            object[] r;

            // Get the .EXE assembly
            assm = Assembly.GetEntryAssembly();
            // Get a 'Type' of the AssemblyCompanyAttribute
            at = typeof(AssemblyCompanyAttribute);
            // Get a collection of custom attributes from the .EXE assembly
            r = assm.GetCustomAttributes(at, false);
            // Get the Company Attribute
            AssemblyCompanyAttribute ct =
                ((AssemblyCompanyAttribute)(r[0]));

            // Build the User App Data Path
            path = Environment.GetFolderPath(
                Environment.SpecialFolder.LocalApplicationData);
            path += @"\NovaSFTP2";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return(path);
        }
コード例 #20
0
        private string GetEULA(string eula)
        {
            Stream       resStream = Application.GetResourceStream(new Uri("pack://application:,,,/DavuxLib2;component/EULAs/" + eula + ".txt")).Stream;
            StreamReader sr        = new StreamReader(resStream);
            string       ret       = sr.ReadToEnd();

            Assembly assembly = Assembly.GetEntryAssembly();

            AssemblyTitleAttribute       assemblyTitle       = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0] as AssemblyTitleAttribute;
            AssemblyDescriptionAttribute assemblyDescription = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0] as AssemblyDescriptionAttribute;
            AssemblyCompanyAttribute     assemblyCompany     = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0] as AssemblyCompanyAttribute;
            AssemblyCopyrightAttribute   assemblyCopyright   = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute;
            AssemblyProductAttribute     assemblyProduct     = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0] as AssemblyProductAttribute;

            string company = assemblyCompany.Company;


            if (company == "Dave Amenta")
            {
                company = "Dave Amenta Software, LLC";
            }
            //ret = ret.Replace("[SOFTWARE TITLE]", assemblyTitle.Title);
            ret = ret.Replace("[COMPANY_NAME]", company);
            //ret = ret.Replace("[YOUR COUNTRY]", "USA");


            return(ret);
        }
コード例 #21
0
            public AssemblyListViewItem(Assembly assembly)
                : base(assembly.GetName().Name)
            {
                this.Assembly = assembly;
                object[] attrs  = this.Assembly.GetCustomAttributes(true);
                string   author = "Unknown";

                for (int i = 0; i < attrs.Length; ++i)
                {
                    if (attrs[i].GetType() == typeof(UpdateFeedAttribute))
                    {
                        UpdateFeedAttribute ufa = attrs[i] as UpdateFeedAttribute;
                        this.HasUpdateUrl = true;
                        this.UpdateUrl    = ufa.Url;
                    }
                    else if (attrs[i].GetType() == typeof(AssemblyCompanyAttribute))
                    {
                        AssemblyCompanyAttribute aca = attrs[i] as AssemblyCompanyAttribute;
                        author = string.IsNullOrEmpty(aca.Company) ? "Unknown" : aca.Company;
                    }
                }

                this.Version = assembly.GetName().Version;

                this.SubItems.Add(author);
            }
コード例 #22
0
        private bool TryGetSettingsLocationInfoFromEntryAssembly(out string settingsLocation, out string softwareName)
        {
            settingsLocation = null;
            softwareName     = null;

            var entryAssembly = Assembly.GetEntryAssembly(); // the main exe assembly

            if (entryAssembly == null)                       // Called from unmanaged code?
            {
                return(false);
            }
            softwareName = Path.GetFileNameWithoutExtension(entryAssembly.Location);
            AssemblyCompanyAttribute companyAttribute = Attribute.GetCustomAttribute(entryAssembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;

            if (companyAttribute == null || string.IsNullOrEmpty(softwareName))
            {
                return(false);
            }
            string companyName = companyAttribute.Company;

            if (companyName == null)
            {
                return(false);
            }
            settingsLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                            companyName);
            return(true);
        }
コード例 #23
0
        // ******************************************************************

        /// <summary>
        /// Reads the value of the <see cref="AssemblyCompanyAttribute"/>
        /// attribute for the given assembly.
        /// </summary>
        /// <param name="assembly">The assembly to read from.</param>
        /// <returns>The value of the given assembly's company attribute.</returns>
        public static string ReadCompany(this Assembly assembly)
        {
            // Attempt to read the assembly's company attribute.
            object[] attributes = assembly.GetCustomAttributes(
                typeof(AssemblyCompanyAttribute),
                true
                );

            // Did we fail?
            if (attributes.Length == 0)
            {
                return(string.Empty);
            }

            // Attempt to recover a reference to the attribute.
            AssemblyCompanyAttribute attr =
                attributes[0] as AssemblyCompanyAttribute;

            // Did we fail?
            if (attr == null || attr.Company.Length == 0)
            {
                return(string.Empty);
            }

            // Return the text for the attribute.
            return(attr.Company);
        }
コード例 #24
0
        public AssemblyCompanyAttributeTest()
        {
            //create a dynamic assembly with the required attribute
            //and check for the validity

            dynAsmName.Name = "TestAssembly";

            dynAssembly = Thread.GetDomain().DefineDynamicAssembly(
                dynAsmName, AssemblyBuilderAccess.Run
                );

            // Set the required Attribute of the assembly.
            Type            attribute = typeof(AssemblyCompanyAttribute);
            ConstructorInfo ctrInfo   = attribute.GetConstructor(
                new Type [] { typeof(string) }
                );
            CustomAttributeBuilder attrBuilder =
                new CustomAttributeBuilder(ctrInfo, new object [1] {
                "Xamarin"
            });

            dynAssembly.SetCustomAttribute(attrBuilder);
            object [] attributes = dynAssembly.GetCustomAttributes(true);
            attr = attributes [0] as AssemblyCompanyAttribute;
        }
コード例 #25
0
        /// <summary>
        /// Indicates whether an <see cref="Assembly" /> is a system assembly.
        /// </summary>
        /// <param name="assembly"></param>
        /// <returns></returns>
        public static bool IsSystemAssembly(this Assembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            // Check assembly name
            if (IsSystemAssemblyName(assembly.FullName))
            {
                return(true);
            }

            // If the name does not show it is a system assembly, then check the company assembly attribute
            AssemblyCompanyAttribute assemblyCompanyAttribute =
                Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute), false) as
                AssemblyCompanyAttribute;

            if (assemblyCompanyAttribute == null)
            {
                return(false);
            }

            string company = assemblyCompanyAttribute.Company;

            return(!string.IsNullOrEmpty(company) &&
                   (company.Contains("Microsoft") || string.Equals(company, "The Apache Software Foundation")));
        }
コード例 #26
0
        public AboutControlViewModel()
        {
            Window = new Window();
            Window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            Window.SizeToContent         = SizeToContent.WidthAndHeight;
            Window.ResizeMode            = ResizeMode.NoResize;
            Window.WindowStyle           = WindowStyle.None;

            Window.ShowInTaskbar = false;
            Window.Title         = "About";
            Window.Deactivated  += Window_Deactivated;

            Assembly assembly = Assembly.GetEntryAssembly();

            Version = assembly.GetName().Version.ToString();
            Title   = assembly.GetName().Name;

            AssemblyCopyrightAttribute   copyright   = assembly.GetCustomAttribute <AssemblyCopyrightAttribute>();
            AssemblyDescriptionAttribute description = assembly.GetCustomAttribute <AssemblyDescriptionAttribute>();
            AssemblyCompanyAttribute     company     = assembly.GetCustomAttribute <AssemblyCompanyAttribute>();

            Copyright   = copyright.Copyright;
            Description = description.Description;
            Publisher   = company.Company;

            AdditionalNotes = "This is a test assignment app from Head First C# 3rd edition book." + Environment.NewLine +
                              $"Survive {InvadersViewModel.TotalWaves} waves of evil invaders to save the earth!" + Environment.NewLine +
                              "Special thanks to @annliseevnaart";
        }
コード例 #27
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;
        }
コード例 #28
0
        internal void Initialize(Assembly assembly)
        {
            this.Name    = assembly.GetName().Name;
            this.Version = assembly.GetName().Version.ToString();

            AssemblyDescriptionAttribute descriptionAttribute = assembly.GetCustomAttributes <AssemblyDescriptionAttribute>().FirstOrDefault();

            this.Description = (descriptionAttribute != null) ? descriptionAttribute.Description : "";

            AssemblyCompanyAttribute companyAttribute = assembly.GetCustomAttributes <AssemblyCompanyAttribute>().FirstOrDefault();

            this.Author = (descriptionAttribute != null) ? companyAttribute.Company : "";

            AssemblyCopyrightAttribute copyrightAttribute = assembly.GetCustomAttributes <AssemblyCopyrightAttribute>().FirstOrDefault();

            this.Copyright = (copyrightAttribute != null) ? copyrightAttribute.Copyright : "";

            try
            {
                this.Icon = Icon.ExtractAssociatedIcon(assembly.Location);
            }
            catch (ArgumentException ex)
            {
                Debugger.Debug.WriteLine(ex);
            }
        }
コード例 #29
0
        /// <summary>
        /// Ctor
        /// </summary>
        public About(Assembly assembly)
        {
            AssemblyName name = assembly.GetName();

            this.FullName = assembly.FullName;
            this.Version  = name.Version;
            this.Name     = name.Name;

            AssemblyCopyrightAttribute copyright = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;

            this.Copyright = (copyright != null) ? copyright.Copyright : String.Empty;

            AssemblyDescriptionAttribute description = Attribute.GetCustomAttribute(assembly, typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;

            this.Description = (description != null) ? description.Description : String.Empty;

            AssemblyTitleAttribute title = Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;

            this.Title = (title != null) ? title.Title : String.Empty;

            AssemblyCompanyAttribute company = Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;

            this.Company = (company != null) ? company.Company : String.Empty;

            AssemblyConfigurationAttribute config = Attribute.GetCustomAttribute(assembly, typeof(AssemblyConfigurationAttribute)) as AssemblyConfigurationAttribute;

            this.Configuration = (config != null) ? config.Configuration : String.Empty;
        }
コード例 #30
0
        /// <summary>
        /// Initializes the server properties from the assembly properties.
        /// </summary>
        private void Initialize(Assembly assembly)
        {
            m_productUri = assembly.FullName;

            AssemblyTitleAttribute attribute1 =
                Attribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;

            if (attribute1 != null)
            {
                m_productName = attribute1.Title;
            }

            AssemblyCompanyAttribute attribute2 =
                Attribute.GetCustomAttribute(assembly, typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;

            if (attribute2 != null)
            {
                m_manufacturerName = attribute2.Company;
            }

            Version version = assembly.GetName().Version;

            m_softwareVersion = Utils.Format("{0}.{1}", version.Major, version.Minor);
            m_buildNumber     = Utils.Format("{0}.{1}", version.Revision, version.Build);
            m_buildDate       = new FileInfo(assembly.Location).CreationTimeUtc;
        }