/// <summary>
        ///     Creates instance
        /// </summary>
        /// <param name="value">Name of type that contains value and unit i.e. Length</param>
        /// <param name="unit">Name of type that represents unit i.e. LengthUnit</param>
        /// <param name="container">Name of static type that contains fields with known unit names i.e. LengthUnits</param>
        public TypesGroup(XValueTypeName value, XUnitTypeName unit = null, XUnitContainerTypeName container = null)
        {
            Value = value ?? throw new ArgumentException(nameof(value));

            ValueKind = Value.Kind;
            Unit      = unit ?? value.ToUnitTypeName();
            Container = container ?? Unit.ToUnitContainerTypeName();
        }
Example #2
0
 private static string GetUnitname(XUnitContainerTypeName typeName, string fieldName)
 {
     try
     {
         var type  = typeof(LengthUnit).Assembly.GetTypes().Single(q => q.Name == typeName.TypeName);
         var field = type.GetField(fieldName);
         var value = field.GetValue(null);
         return(((IUnitNameContainer)value).UnitName);
     }
     catch
     {
         return("");
     }
 }
Example #3
0
 public bool Equals(XUnitContainerTypeName other)
 {
     return(TypeName.Equals(other.TypeName));
 }