User Tools

Site Tools


notes:uwp:reflection

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

notes:uwp:reflection [2017/07/25]
leszek created
notes:uwp:reflection [2017/07/25] (current)
leszek
Line 115: Line 115:
     Abstract: False     Abstract: False
 ... ...
 +</​code>​
 +
 +Example: Obtain the assembly version:
 +<code csharp>
 +public string GetAssemblyVersion()
 +{
 +    // The typeof(.) argument could be any class in the App.
 +    Assembly asm = typeof(Book).GetTypeInfo().Assembly;​
 +
 +    // Method #1
 +    AssemblyFileVersionAttribute attr = 
 +        CustomAttributeExtensions.GetCustomAttribute<​AssemblyFileVersionAttribute>​(asm);​
 +  ​
 +    if (attr != null)
 +        return attr.Version;​
 +    else
 +        return "";​
 +
 +    // Method #2
 +    //return asm.GetName().Version.ToString();​
 +}
 </​code>​ </​code>​
  
notes/uwp/reflection.txt ยท Last modified: 2017/07/25 by leszek