Example #1
0
        public static double GetMiniConversionConstant(this YarnType yarnType)
        {
            YarnTypePropertiesAttribute yarnTypePropertiesAttribute = GetYarnTypeProperties(yarnType);
            double conversionConstant = yarnTypePropertiesAttribute.MiniConversionConstant;

            return(conversionConstant);
        }
Example #2
0
        public static YarnType GetCorrespondingMiniType(this YarnType yarnType)
        {
            YarnTypePropertiesAttribute yarnTypePropertiesAttribute = GetYarnTypeProperties(yarnType);
            YarnType miniType = yarnTypePropertiesAttribute.CorrespondingMiniType;

            return(miniType);
        }
Example #3
0
        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());
            }
        }
Example #4
0
        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();
        }