コード例 #1
0
 /// <summary>
 ///  Uint32 -> String
 /// </summary>
 /// <param name="context"></param>
 /// <param name="culture"></param>
 /// <param name="value">UInt32:0</param>
 /// <param name="destinationType"></param>
 /// <returns>Type: String: "00000000"</returns>
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string) && value is UInt32)
     {
         return(CustomDataConversion.UInt32ToStringHighSpeed((UInt32)value));
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
コード例 #2
0
 /// <summary>
 /// value:byte[] -> destinationType:String (return)
 /// </summary>
 /// <param name="context"></param>
 /// <param name="culture"></param>
 /// <param name="value">byte[]{0x00, 0x0A, 0x0B }</param>
 /// <param name="destinationType"></param>
 /// <returns>00 0A 0B 0C</returns>
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string) && value is byte[])
     {
         return(CustomDataConversion.ByteArrayToString(value as byte[], _format));
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
コード例 #3
0
 /// <summary>
 ///  String -> Uint32
 /// </summary>
 /// <param name="context"></param>
 /// <param name="culture"></param>
 /// <param name="value">Type: String: "0000000000"</param>
 /// <returns>UInt32:0</returns>
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         return(CustomDataConversion.StringToUInt32(value as string));
     }
     else
     {
         return(base.ConvertFrom(context, culture, value));
     }
 }
コード例 #4
0
        /// <summary>
        /// value:String -> return byte[]
        /// Overrides the ConvertFrom method of TypeConverter.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value">String</param>
        /// <returns>byte[]</returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            byte[] retval = new byte[0];

            if (value is string)
            {
                return(CustomDataConversion.StringToByteArray(value as string));
            }
            else
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }