Example #1
0
        private string ToString(object value)
        {
            string description = ExifTagDescriptionAttribute.GetDescription(Tag, value);

            if (description != null)
            {
                return(description);
            }

            switch (DataType)
            {
            case ExifDataType.Ascii:
                return((string)value);

            case ExifDataType.Byte:
                return(((byte)value).ToString("X2", CultureInfo.InvariantCulture));

            case ExifDataType.DoubleFloat:
                return(((double)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.Long:
                return(((uint)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.Rational:
                return(((Rational)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.Short:
                return(((ushort)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.SignedByte:
                return(((sbyte)value).ToString("X2", CultureInfo.InvariantCulture));

            case ExifDataType.SignedLong:
                return(((int)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.SignedRational:
                return(((SignedRational)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.SignedShort:
                return(((short)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.SingleFloat:
                return(((float)value).ToString(CultureInfo.InvariantCulture));

            case ExifDataType.Undefined:
                return(((byte)value).ToString("X2", CultureInfo.InvariantCulture));

            default:
                throw new NotSupportedException();
            }
        }
        public override string ToString()
        {
            if (Value == null)
            {
                return(null);
            }

            var description = ExifTagDescriptionAttribute.GetDescription(Tag, Value);

            if (description != null)
            {
                return(description);
            }

            return(StringValue);
        }