Пример #1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw GetConvertFromException(value);
            }

            var source = value as string;

            if (source != null)
            {
                var th     = new TokenizerHelper(source, CultureInfo.InvariantCulture);
                var result = new Quaternion(
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture),
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture),
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture),
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture));
                return(result);
            }

            return(base.ConvertFrom(context, culture, value));
        }
Пример #2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw GetConvertFromException(value);
            }

            var source = value as string;

            if (source != null)
            {
                var th = new TokenizerHelper(source, CultureInfo.InvariantCulture);
                var result = new Quaternion(
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture),
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture),
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture),
                    Convert.ToSingle(th.NextTokenRequired(), CultureInfo.InvariantCulture));
                return result;
            }

            return base.ConvertFrom(context, culture, value);
        }