1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- using System.Linq;
- using YUR.Fit.Core.Models;
- namespace BsYurHttpStatus
- {
- internal static class AccessHelper
- {
- public static float SuckFloatProperty(this OverlayStatusUpdate instance, string propertyName)
- {
- Type t;
- try
- {
- t = instance.CalculationMetrics.GetType();
- }
- catch
- {
- return -1;
- }
- var propertyInfos = t.GetProperties();
- var i = propertyInfos.FirstOrDefault(x => x.Name == propertyName && x.PropertyType == typeof(float));
- if (i == null) return -2;
- try
- {
- return (float)i.GetValue(instance.CalculationMetrics);
- }
- catch
- {
- return -3;
- }
- }
- }
- }
|