Adding support for sending co-ordinates when scope is parked.

This commit is contained in:
2021-04-24 19:16:36 +01:00
parent eaeae4d66b
commit fdd008fcfb
11 changed files with 492 additions and 56 deletions
+39
View File
@@ -0,0 +1,39 @@
using System;
using System.Linq;
using System.Reflection;
namespace ASCOM.Meade.net
{
public static class EnumExtensionMethods
{
public static string GetDescription(this Enum GenericEnum)
{
Type genericEnumType = GenericEnum.GetType();
MemberInfo[] memberInfo = genericEnumType.GetMember(GenericEnum.ToString());
if ((memberInfo != null && memberInfo.Length > 0))
{
var _Attribs = memberInfo[0]
.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
if ((_Attribs != null && _Attribs.Count() > 0))
{
return ((System.ComponentModel.DescriptionAttribute) _Attribs.ElementAt(0)).Description;
}
}
return GenericEnum.ToString();
}
public static T GetValueFromDescription<T>( string description) where T : Enum
{
foreach (T value in Enum.GetValues(typeof(T)))
{
if (value.GetDescription() == description)
{
return value;
}
}
return default;
}
}
}