From: Michael D. <mik...@us...> - 2004-11-12 22:08:37
|
Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables/TypeConverters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21720/src/Nullables/TypeConverters Added Files: NullableBooleanConverter.cs NullableByteConverter.cs NullableDateTimeConverter.cs NullableDecimalConverter.cs NullableDoubleConverter.cs NullableGuidConverter.cs NullableInt16Converter.cs NullableInt32Converter.cs NullableInt64Converter.cs NullableSingleConverter.cs Log Message: NH-15: created a NHibernateContrib folder in cvs --- NEW FILE: NullableGuidConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableGuidConverter : TypeConverter { public NullableGuidConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableGuid.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableGuid.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Guid)); Guid newValue = (Guid)converter.ConvertFromString(context, culture, stringValue); return new NullableGuid(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableGuid) { NullableGuid nullable = (NullableGuid)value; Type[] constructorArgTypes = new Type[1] { typeof(Guid) } ; ConstructorInfo constructor = typeof(NullableGuid).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableGuid((Guid)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableGuid), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableDateTimeConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableDateTimeConverter : TypeConverter { public NullableDateTimeConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableDateTime.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableDateTime.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(DateTime)); DateTime newValue = (DateTime)converter.ConvertFromString(context, culture, stringValue); return new NullableDateTime(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableDateTime) { NullableDateTime nullable = (NullableDateTime)value; Type[] constructorArgTypes = new Type[1] { typeof(DateTime) } ; ConstructorInfo constructor = typeof(NullableDateTime).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableDateTime((DateTime)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableDateTime), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableDecimalConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableDecimalConverter : TypeConverter { public NullableDecimalConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableDecimal.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableDecimal.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Decimal)); Decimal newValue = (Decimal)converter.ConvertFromString(context, culture, stringValue); return new NullableDecimal(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableDecimal) { NullableDecimal nullable = (NullableDecimal)value; Type[] constructorArgTypes = new Type[1] { typeof(Decimal) } ; ConstructorInfo constructor = typeof(NullableDecimal).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableDecimal((Decimal)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableDecimal), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableSingleConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableSingleConverter : TypeConverter { public NullableSingleConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableSingle.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableSingle.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Single)); Single newValue = (Single)converter.ConvertFromString(context, culture, stringValue); return new NullableSingle(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableSingle) { NullableSingle nullable = (NullableSingle)value; Type[] constructorArgTypes = new Type[1] { typeof(Single) } ; ConstructorInfo constructor = typeof(NullableSingle).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableSingle((Single)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableSingle), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableBooleanConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableBooleanConverter : TypeConverter { public NullableBooleanConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableBoolean.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableBoolean.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Boolean)); Boolean newValue = (Boolean)converter.ConvertFromString(context, culture, stringValue); return new NullableBoolean(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableBoolean) { NullableBoolean nullable = (NullableBoolean)value; Type[] constructorArgTypes = new Type[1] { typeof(Boolean) } ; ConstructorInfo constructor = typeof(NullableBoolean).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableBoolean((Boolean)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableBoolean), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableInt64Converter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableInt64Converter : TypeConverter { public NullableInt64Converter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableInt64.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableInt64.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Int64)); Int64 newValue = (Int64)converter.ConvertFromString(context, culture, stringValue); return new NullableInt64(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableInt64) { NullableInt64 nullable = (NullableInt64)value; Type[] constructorArgTypes = new Type[1] { typeof(Int64) } ; ConstructorInfo constructor = typeof(NullableInt64).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableInt64((Int64)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableInt64), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableInt32Converter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableInt32Converter : TypeConverter { public NullableInt32Converter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableInt32.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableInt32.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Int32)); Int32 newValue = (Int32)converter.ConvertFromString(context, culture, stringValue); return new NullableInt32(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableInt32) { NullableInt32 nullable = (NullableInt32)value; Type[] constructorArgTypes = new Type[1] { typeof(Int32) } ; ConstructorInfo constructor = typeof(NullableInt32).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableInt32((Int32)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableInt32), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableByteConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableByteConverter : TypeConverter { public NullableByteConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableByte.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableByte.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Byte)); Byte newValue = (Byte)converter.ConvertFromString(context, culture, stringValue); return new NullableByte(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableByte) { NullableByte nullable = (NullableByte)value; Type[] constructorArgTypes = new Type[1] { typeof(Byte) } ; ConstructorInfo constructor = typeof(NullableByte).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableByte((Byte)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableByte), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableDoubleConverter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableDoubleConverter : TypeConverter { public NullableDoubleConverter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableDouble.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableDouble.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Double)); Double newValue = (Double)converter.ConvertFromString(context, culture, stringValue); return new NullableDouble(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableDouble) { NullableDouble nullable = (NullableDouble)value; Type[] constructorArgTypes = new Type[1] { typeof(Double) } ; ConstructorInfo constructor = typeof(NullableDouble).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableDouble((Double)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableDouble), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } --- NEW FILE: NullableInt16Converter.cs --- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Reflection; namespace Nullables.TypeConverters { public class NullableInt16Converter : TypeConverter { public NullableInt16Converter() { } public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { Console.WriteLine("CanConvertFrom? " + sourceType.ToString()); if (sourceType == typeof(string)) return true; else return base.CanConvertFrom (context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { Console.WriteLine("CanConvertTo? " + destinationType.ToString()); if (destinationType == typeof(InstanceDescriptor)) return true; else return base.CanConvertTo (context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value == null) { return NullableInt16.Default; } if (value is string) { string stringValue = ((string)value).Trim(); if (stringValue == string.Empty) return NullableInt16.Default; //get underlying types converter TypeConverter converter = TypeDescriptor.GetConverter(typeof(Int16)); Int16 newValue = (Int16)converter.ConvertFromString(context, culture, stringValue); return new NullableInt16(newValue); } else { return base.ConvertFrom (context, culture, value); } } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor) && value is NullableInt16) { NullableInt16 nullable = (NullableInt16)value; Type[] constructorArgTypes = new Type[1] { typeof(Int16) } ; ConstructorInfo constructor = typeof(NullableInt16).GetConstructor(constructorArgTypes); if (constructor != null) { object[] constructorArgValues = new object[1] { nullable.Value } ; return new InstanceDescriptor(constructor, constructorArgValues); } } return base.ConvertTo (context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return new NullableInt16((Int16)propertyValues["Value"]); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { return TypeDescriptor.GetProperties(typeof(NullableInt16), attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } } |