| 1234567891011121314151617181920212223242526272829303132333435363738 |
- namespace IndexFormula.Finance
- {
- using System;
- using System.ComponentModel;
- using System.Globalization;
- public class DataCycleConverter : ExpandableObjectConverter
- {
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
- {
- return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
- }
- public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
- {
- return ((destinationType == typeof(string)) || base.CanConvertTo(context, destinationType));
- }
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
- {
- if (value is string)
- {
- return DataCycle.Parse((string) value);
- }
- return base.ConvertFrom(context, culture, value);
- }
- public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
- {
- if (destinationType == typeof(string))
- {
- return value.ToString();
- }
- return base.ConvertTo(context, culture, value, destinationType);
- }
- }
- }
|