ExtensionMethod.NET Home of 829 C#, Visual Basic, F# and Javascript extension methods

Get Assembly Attributes For About Window

Get Specific Assembly Attributes For About Window

Source

using System;
using System.Linq;
using static System.IO.Path;
using static System.Reflection.Assembly;


private static T G<T>() where T : class => GetExecutingAssembly().GetCustomAttributes(typeof(T), false).OfType<T>().FirstOrDefault(x => x != null);

Example

using static System.IO.Path;
using static System.Reflection.Assembly;
using CA = System.Reflection.AssemblyCopyrightAttribute;
using CO = System.Reflection.AssemblyCompanyAttribute;
using DA = System.Reflection.AssemblyDescriptionAttribute;
using PA = System.Reflection.AssemblyProductAttribute;
using TA = System.Reflection.AssemblyTitleAttribute;

Text = $"About {G<TA>().Title ?? GetFileNameWithoutExtension(GetExecutingAssembly().CodeBase)}";
labelProductName.Text = G<PA>().Product ?? "";
labelVersion.Text = $"Версия {ApplicationVersion}";
labelCopyright.Text = G<CA>().Copyright ?? "Copyright © 2014";
labelCompanyName.Text = G<CO>().Company ?? "My Company";
textBoxDescription.Text = G<DA>().Description ?? "терминал ОРТК CHIP";

Author: mikelgusev

Submitted on: 28 jul 2020

Language: csharp

Type: System.Reflection.Assembly

Views: 92