Пример #1
0
        private string GetName(FieldInfo fieldInfo, SimVarAttribute attr)
        {
            if (attr != null && attr.NameId != FsSimVar.None)
            {
                string theSimVarName = FsSimVarFactory.GetSimVarName(attr.NameId);

                return(attr.Instance > 0 ? $"{theSimVarName}:{attr.Instance}" : theSimVarName);
            }

            if (!string.IsNullOrEmpty(attr?.Name))
            {
                return(attr.Name);
            }

            // Find any instance put in the name.
            Regex re     = new Regex(@"([a-zA-Z]+)(\d+)");
            Match result = re.Match(fieldInfo.Name);

            string name     = fieldInfo.Name;
            int?   instance = attr?.Instance;

            if (result.Groups.Count > 1)
            {
                name     = result.Groups[1].Value;
                instance = int.Parse(result.Groups[2].Value);
            }

            // Try to lookup variations of the SimVar name using aNyCaSe and Under_Score
            string simVarName = FsSimVarFactory.GetSimVarName(name);

            if (simVarName != null)
            {
                name = simVarName;
            }

            if (instance > 0)
            {
                name = $"{name}:{instance}";
            }

            return(name);
        }
Пример #2
0
 /// <summary>
 /// Creates an initialized instance using enums for known values.
 /// </summary>
 /// <param name="simVar"></param>
 /// <param name="unit"></param>
 /// <param name="dataType"></param>
 public SimProperty(FsSimVar simVar, FsUnit unit, SIMCONNECT_DATATYPE dataType)
 {
     Name     = FsSimVarFactory.GetSimVarCode(simVar);
     Unit     = UnitFactory.GetUnitCode(unit);
     DataType = dataType;
 }
Пример #3
0
 /// <summary>
 /// Creates an initialized instance using enums for known values.
 /// </summary>
 /// <param name="simVarId"></param>
 /// <param name="unitId"></param>
 /// <param name="dataType"></param>
 public SimVar(FsSimVar simVarId, FsUnit unitId, SIMCONNECT_DATATYPE dataType)
 {
     Name     = FsSimVarFactory.GetSimVarName(simVarId);
     Unit     = FsUnitFactory.GetUnitName(unitId);
     DataType = dataType;
 }
Пример #4
0
 /// <summary>
 /// Creates an initialized instance of the <see cref="SimVar"/> class.
 /// </summary>
 /// <param name="simVarId"></param>
 /// <param name="unitName"></param>
 /// <param name="dataType"></param>
 public SimVar(FsSimVar simVarId, string unitName, SIMCONNECT_DATATYPE dataType)
 {
     Name     = FsSimVarFactory.GetSimVarName(simVarId);
     Unit     = unitName;
     DataType = dataType;
 }