MissionPlanner.CurrentState.GetNameandUnit C# (CSharp) Method

GetNameandUnit() public method

public GetNameandUnit ( string name ) : string
name string
return string
        public string GetNameandUnit(string name)
        {
            string desc = name;
            try
            {
                var typeofthing = typeof (CurrentState).GetProperty(name);
                if (typeofthing != null)
                {
                    var attrib = typeofthing.GetCustomAttributes(false);
                    if (attrib.Length > 0)
                        desc = ((Attributes.DisplayTextAttribute) attrib[0]).Text;
                }
            }
            catch
            {
            }

            if (desc.Contains("(dist)"))
            {
                desc = desc.Replace("(dist)", "(" + CurrentState.DistanceUnit + ")");
            }
            else if (desc.Contains("(speed)"))
            {
                desc = desc.Replace("(speed)", "(" + CurrentState.SpeedUnit + ")");
            }

            return desc;
        }