public static double GetMiniConversionConstant(this YarnType yarnType) { YarnTypePropertiesAttribute yarnTypePropertiesAttribute = GetYarnTypeProperties(yarnType); double conversionConstant = yarnTypePropertiesAttribute.MiniConversionConstant; return(conversionConstant); }
public static YarnType GetCorrespondingMiniType(this YarnType yarnType) { YarnTypePropertiesAttribute yarnTypePropertiesAttribute = GetYarnTypeProperties(yarnType); YarnType miniType = yarnTypePropertiesAttribute.CorrespondingMiniType; return(miniType); }
public static String GetTextRepresentation(this YarnType yarnType) { YarnTypePropertiesAttribute yarnTypePropertiesAttribute = GetYarnTypeProperties(yarnType); String textRepresentation = yarnTypePropertiesAttribute.TextRepresentation; if (textRepresentation != String.Empty) { return(textRepresentation); } else { return(yarnType.ToString()); } }
private static YarnTypePropertiesAttribute GetYarnTypeProperties(YarnType yarnType) { Type type = yarnType.GetType(); string name = Enum.GetName(type, yarnType); if (name != null) { FieldInfo field = type.GetField(name); if (field != null) { YarnTypePropertiesAttribute yarnTypeProperties = Attribute.GetCustomAttribute(field, typeof(YarnTypePropertiesAttribute)) as YarnTypePropertiesAttribute; if (yarnTypeProperties != null) { return(yarnTypeProperties); } } } throw new ArgumentException(); }