mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2025-01-01 11:13:19 +00:00
23 lines
773 B
C#
23 lines
773 B
C#
|
using System.Reflection;
|
||
|
using Android.App;
|
||
|
|
||
|
namespace MonoStockPortfolio.Framework
|
||
|
{
|
||
|
public class ManifestNames
|
||
|
{
|
||
|
public static string GetName<T>()
|
||
|
{
|
||
|
var attrs = typeof(T).GetCustomAttributes(typeof(ActivityAttribute), false);
|
||
|
if (attrs.Length == 0) throw new CustomAttributeFormatException("Activity attribute must specify name");
|
||
|
foreach (var attr in attrs)
|
||
|
{
|
||
|
var activityAttr = attr as ActivityAttribute;
|
||
|
if (activityAttr != null)
|
||
|
{
|
||
|
return activityAttr.Name;
|
||
|
}
|
||
|
}
|
||
|
throw new CustomAttributeFormatException("Activity attribute name not found");
|
||
|
}
|
||
|
}
|
||
|
}
|