예제 #1
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        // Returns non-null string if this value can be converted to a string,
        // null otherwise.
        internal static string GetStringValue(DependencyProperty property, object propertyValue)
        {
            string stringValue = null;

            // Special cases working around incorrectly implemented type converters
            if (property == UIElement.BitmapEffectProperty)
            {
                return(null); // Always treat BitmapEffects as complex value
            }

            if (property == Inline.TextDecorationsProperty)
            {
                stringValue = TextDecorationsFixup((TextDecorationCollection)propertyValue);
            }
            else if (typeof(CultureInfo).IsAssignableFrom(property.PropertyType)) //NumberSubstitution.CultureOverrideProperty
            {
                stringValue = CultureInfoFixup(property, (CultureInfo)propertyValue);
            }

            if (stringValue == null)
            {
                DPTypeDescriptorContext context = new DPTypeDescriptorContext(property, propertyValue);

                System.ComponentModel.TypeConverter typeConverter = System.ComponentModel.TypeDescriptor.GetConverter(property.PropertyType);
                Invariant.Assert(typeConverter != null);
                if (typeConverter.CanConvertTo(context, typeof(string)))
                {
                    stringValue = (string)typeConverter.ConvertTo(
                        context, System.Globalization.CultureInfo.InvariantCulture, propertyValue, typeof(string));
                }
            }
            return(stringValue);
        }
예제 #2
0
        public static T[] ConvertTo <T>(this Array ar)
        {
            T[] ret = new T[ar.Length];
            System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(typeof(T));
            if (tc.CanConvertFrom(ar.GetValue(0).GetType()))
            {
                for (int i = 0; i < ar.Length; i++)
                {
                    ret[i] = (T)tc.ConvertFrom(ar.GetValue(i));
                }
            }
            else
            {
                tc = System.ComponentModel.TypeDescriptor.GetConverter(ar.GetValue(0).GetType());
                if (tc.CanConvertTo(typeof(T)))
                {
                    for (int i = 0; i < ar.Length; i++)
                    {
                        ret[i] = (T)tc.ConvertTo(ar.GetValue(i), typeof(T));
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            return(ret);
        }
예제 #3
0
            private bool IsMethodValid(MethodInfo info)
            {
                ParameterInfo[] param = info.GetParameters();
                if (param.Length > 0)
                {
                    return(false);
                }

                if (info.ReturnType == null || info.ReturnType == typeof(void))
                {
                    return(false);
                }

#if !NETFX_CORE
                System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(info.ReturnType);
                if (!Type.IsAssignableFrom(info.ReturnType) && !converter.CanConvertTo(Type))
                {
                    return(false);
                }
#else
                if (!Type.GetTypeInfo().IsAssignableFrom(info.ReturnType.GetTypeInfo()))
                {
                    return(false);
                }
#endif

                return(true);
            }
예제 #4
0
        public static bool _CanConvertTo_System_ComponentModel_TypeConverter_System_ComponentModel_ITypeDescriptorContext_System_Type( )
        {
            //class object
            System.ComponentModel.TypeConverter _System_ComponentModel_TypeConverter = new System.ComponentModel.TypeConverter();

            //Parameters
            System.ComponentModel.ITypeDescriptorContext context = null;
            System.Type destinationType = null;

            //ReturnType/Value
            System.Boolean returnVal_Real        = false;
            System.Boolean returnVal_Intercepted = false;

            //Exception
            System.Exception exception_Real        = null;
            System.Exception exception_Intercepted = null;

            InterceptionMaintenance.disableInterception( );

            try
            {
                returnVal_Real = _System_ComponentModel_TypeConverter.CanConvertTo(context, destinationType);
            }

            catch (System.Exception e)
            {
                exception_Real = e;
            }


            InterceptionMaintenance.enableInterception( );

            try
            {
                returnVal_Intercepted = _System_ComponentModel_TypeConverter.CanConvertTo(context, destinationType);
            }

            catch (System.Exception e)
            {
                exception_Intercepted = e;
            }


            return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted));
        }
        public static bool _CanConvertTo_System_ComponentModel_TypeConverter_System_ComponentModel_ITypeDescriptorContext_System_Type( )
        {
            //class object
            System.ComponentModel.TypeConverter _System_ComponentModel_TypeConverter = new System.ComponentModel.TypeConverter();

               //Parameters
               System.ComponentModel.ITypeDescriptorContext context = null;
               System.Type destinationType = null;

               //ReturnType/Value
               System.Boolean returnVal_Real = false;
               System.Boolean returnVal_Intercepted = false;

               //Exception
               System.Exception exception_Real = null;
               System.Exception exception_Intercepted = null;

               InterceptionMaintenance.disableInterception( );

               try
               {
              returnVal_Real = _System_ComponentModel_TypeConverter.CanConvertTo(context,destinationType);
               }

               catch( System.Exception e )
               {
              exception_Real = e;
               }

               InterceptionMaintenance.enableInterception( );

               try
               {
              returnVal_Intercepted = _System_ComponentModel_TypeConverter.CanConvertTo(context,destinationType);
               }

               catch( System.Exception e )
               {
              exception_Intercepted = e;
               }

               return( ( exception_Real.Messsage == exception_Intercepted.Message ) && ( returnValue_Real == returnValue_Intercepted ) );
        }
예제 #6
0
 private static object _ChangeType(object obj, System.Type type)
 {
     System.ComponentModel.TypeConverter typeConverter = System.ComponentModel.TypeDescriptor.GetConverter(obj);
     if (((null == typeConverter) ||
          (false == typeConverter.CanConvertTo(type))))
     {
         return(System.Convert.ChangeType(obj, type));
     }
     return(typeConverter.ConvertTo(obj, type));
 }
예제 #7
0
 public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context,
                                   Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         return(true);
     }
     else
     {
         return(m_BaseTypeConverter.CanConvertTo(context, destinationType));
     }
 }
예제 #8
0
        public static System.Boolean CanConvertToMSS(
            System.ComponentModel.TypeConverter target,
            System.Type destinationType)
        {
            object result;

            if (TestSpecificStubsUtil.RunTestSpecificStub(System.Reflection.MethodBase.GetCurrentMethod(), new object[] { target, destinationType }, out result))
            {
                return((System.Boolean)result);
            }
            else
            {
                return(target.CanConvertTo(destinationType));
            }
        }
예제 #9
0
        internal static TT GenericConvert <FT, TT>(FT value)
        {
            System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(TT));
            if (converter.CanConvertFrom(typeof(FT)))
            {
                return((TT)converter.ConvertFrom(value));
            }
            converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(FT));
            if (converter.CanConvertTo(typeof(TT)))
            {
                return((TT)converter.ConvertTo(value, typeof(TT)));
            }

            throw new FormatException(string.Format("Cannot convert from type: \"{0}\" to type: \"{1}\"", typeof(FT).Name, typeof(TT).Name));
        }
        /// <summary>
        /// Converts a type to string if possible. This method supports an optional culture generically on any value.
        /// It calls the ToString() method on common types and uses a type converter on all other objects
        /// if available
        /// </summary>
        /// <param name="RawValue">The Value or Object to convert to a string</param>
        /// <param name="Culture">Culture for numeric and DateTime values</param>
        /// <returns>string</returns>
        public static string TypedValueToString(object RawValue, CultureInfo Culture)
        {
            Type   ValueType = RawValue.GetType();
            string Return    = null;

            if (ValueType == typeof(string))
            {
                Return = RawValue.ToString();
            }
            else if (ValueType == typeof(int) || ValueType == typeof(decimal) ||
                     ValueType == typeof(double) || ValueType == typeof(float))
            {
                Return = string.Format(Culture.NumberFormat, "{0}", RawValue);
            }
            else if (ValueType == typeof(DateTime))
            {
                Return = string.Format(Culture.DateTimeFormat, "{0}", RawValue);
            }
            else if (ValueType == typeof(bool))
            {
                Return = RawValue.ToString();
            }
            else if (ValueType == typeof(byte))
            {
                Return = RawValue.ToString();
            }
            else if (ValueType.IsEnum)
            {
                Return = RawValue.ToString();
            }
            else
            {
                // Any type that supports a type converter
                System.ComponentModel.TypeConverter converter =
                    System.ComponentModel.TypeDescriptor.GetConverter(ValueType);
                if (converter != null && converter.CanConvertTo(typeof(string)))
                {
                    Return = converter.ConvertToString(null, Culture, RawValue);
                }
                else
                {
                    // Last resort - just call ToString() on unknown type
                    Return = RawValue.ToString();
                }
            }

            return(Return);
        }
예제 #11
0
        internal static TT GenericConvert <FT, TT>(FT value, TT defaultValue)
        {
            if (value == null)
            {
                return(defaultValue);
            }
            System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(TT));
            if (converter.CanConvertFrom(typeof(FT)))
            {
                return((TT)converter.ConvertFrom(value));
            }
            converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(FT));
            if (converter.CanConvertTo(typeof(TT)))
            {
                return((TT)converter.ConvertTo(value, typeof(TT)));
            }

            return(defaultValue);
        }
예제 #12
0
        //---------------------------------Implementation-----------------------------//

        //var texto = "123123";
        //var res = texto.ConvertTo<int>();
        //res++;

        //---------------------------------Implementation-----------------------------//

        /// <summary>
        /// Converts to a specific data type.
        /// </summary>
        /// <typeparam name="TValue">The type of the t value.</typeparam>
        /// <param name="text">The text.</param>
        /// <returns>TValue.</returns>
        /// <exception cref="System.NotSupportedException"></exception>
        public static TValue ConvertTo <TValue>(this string text)
        {
            TValue res = default(TValue);

            System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(typeof(TValue));
            if (tc.CanConvertFrom(text.GetType()))
            {
                res = (TValue)tc.ConvertFrom(text);
            }
            else
            {
                tc = System.ComponentModel.TypeDescriptor.GetConverter(text.GetType());
                if (tc.CanConvertTo(typeof(TValue)))
                {
                    res = (TValue)tc.ConvertTo(text, typeof(TValue));
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            return(res);
        }
 private object cc(object tipo)
 {
     if (tipo == null)
     {
         return(null);
     }
     if (esConocido(tipo))
     {
         return(tipo);
     }
     else if (tipo is System.Web.UI.Triplet)
     {
         System.Web.UI.Triplet triple = (System.Web.UI.Triplet)tipo;
         return(new seriable3(cc(triple.First), cc(triple.Second), cc(triple.Third)));
     }
     else if (tipo is System.Web.UI.Pair)
     {
         System.Web.UI.Pair par = (System.Web.UI.Pair)tipo;
         return(new seriable2(cc(par.First), cc(par.Second)));
     }
     else if (tipo is ArrayList)
     {
         ArrayList trans  = (ArrayList)tipo;
         ArrayList salida = new ArrayList(trans.Count);
         foreach (object x in trans)
         {
             salida.Add(cc(x));
         }
         return(salida);
     }
     else if (tipo is Array)
     {
         Array trans  = (Array)tipo;
         Array salida = Array.CreateInstance(tipo.GetType().GetElementType(), trans.Length);
         for (int x = 0; x < trans.Length; x++)
         {
             salida.SetValue(cc(trans.GetValue(x)), x);
         }
         return(salida);
     }
     else if (tipo is Hashtable)
     {
         IDictionaryEnumerator enumerator = ((Hashtable)tipo).GetEnumerator();
         Hashtable             salida     = new Hashtable();
         while (enumerator.MoveNext())
         {
             salida.Add(cc(enumerator.Key), cc(enumerator.Value));
         }
         return(salida);
     }
     else
     {
         Type valueType       = tipo.GetType();
         Type destinationType = typeof(string);
         bool flag;
         bool flag2;
         System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(valueType);
         if (((converter == null) || converter is System.ComponentModel.ReferenceConverter))
         {
             flag  = false;
             flag2 = false;
         }
         else
         {
             flag  = converter.CanConvertTo(destinationType);
             flag2 = converter.CanConvertFrom(destinationType);
         }
         if ((flag && flag2))
         {
             return(new generalCnv(valueType, converter.ConvertToInvariantString(tipo)));
         }
         else
         {
             return(tipo);
             //Salida General
         }
     }
 }
예제 #14
0
        /// <summary>
        /// 指定したオブジェクトを指定した型として文字列に変換します。
        /// </summary>
        /// <param name="t">変換元のオブジェクトの型を指定します。</param>
        /// <param name="value">変換元のオブジェクトを指定します。</param>
        /// <returns>変換後の文字列を返します。</returns>
        public static string From(System.Type t, object value)
        {
            switch (Types.GetTypeCode(t))
            {
            case TypeCodes.SByte: return(FromSByte((sbyte)value));

            case TypeCodes.Byte: return(FromByte((byte)value));

            case TypeCodes.Short: return(FromInt16((short)value));

            case TypeCodes.UShort: return(FromUInt16((ushort)value));

            case TypeCodes.Int: return(FromInt32((int)value));

            case TypeCodes.UInt: return(FromUInt32((uint)value));

            case TypeCodes.Long: return(FromInt64((long)value));

            case TypeCodes.ULong: return(FromUInt64((ulong)value));

            case TypeCodes.Decimal: return(FromDecimal((decimal)value));

            case TypeCodes.Float: return(FromSingle((float)value));

            case TypeCodes.Double: return(FromDouble((double)value));

            case TypeCodes.Bool: return(FromBoolean((bool)value));

            case TypeCodes.Char: return(FromChar((char)value));

            case TypeCodes.String: return((string)value);

            case TypeCodes.Guid: return(FromGuid((System.Guid)value));

            case TypeCodes.TimeSpan: return(FromTimeSpan((System.TimeSpan)value));

            //.NET Framework 2.0 : System.Xml.XmlDateTimeSerializationMode を指定
            case TypeCodes.DateTime: return(FromDateTime((System.DateTime)value));

            case TypeCodes.IntPtr: return(FromInt64((long)(System.IntPtr)value));

            case TypeCodes.UIntPtr: return(FromUInt64((ulong)(System.UIntPtr)value));

            case TypeCodes.BoolArray: return(FromBooleanArray((bool[])value));

            case TypeCodes.ByteArray: return(FromByteArray((byte[])value));

            case TypeCodes.Type:
                return(((System.Type)value).FullName);

            default:
                //	typeconv:
                if (t.IsEnum)
                {
                    return(value.ToString());                               //System.Enum
                }
                if (t.GetCustomAttributes(typeof(System.ComponentModel.TypeConverterAttribute), false).Length == 0)
                {
                    goto serial;
                }
                System.ComponentModel.TypeConverter conv = System.ComponentModel.TypeDescriptor.GetConverter(t);
                if (conv.CanConvertTo(typeof(string)) && conv.CanConvertFrom(typeof(string)))
                {
                    try{ return(conv.ConvertToString(value)); }catch {}
                }
serial:
                if (t.GetCustomAttributes(typeof(System.SerializableAttribute), false).Length == 0)
                {
                    goto op_implicit;
                }
                using (System.IO.MemoryStream memstr = new System.IO.MemoryStream()){
                    binF.Serialize(memstr, value);
                    //--長さ
                    int len;
                    try{
                        len = (int)memstr.Length;
                    }catch (System.Exception e) {
                        throw new System.Exception("データの量が大きすぎるので文字列に変換できません", e);
                    }
                    //--文字列に変換
                    byte[] buff = new byte[len];
                    memstr.Position = 0;
                    memstr.Read(buff, 0, len);
                    return(System.Convert.ToBase64String(buff));
                }
op_implicit:
                System.Reflection.MethodInfo[] ms = t.GetMethods(BF_PublicStatic);
                for (int i = 0; i < ms.Length; i++)
                {
                    if (ms[i].Name != "op_Implicit" || ms[i].ReturnType != typeof(string))
                    {
                        continue;
                    }
                    System.Reflection.ParameterInfo[] ps = ms[i].GetParameters();
                    if (ps.Length != 1 || ps[0].ParameterType != t)
                    {
                        continue;
                    }
                    return((string)ms[i].Invoke(null, new object[] { value }));
                }
                throw new System.ArgumentException(string.Format(TOSTR_NOTSUPPORTEDTYPE, t), "t");
            }
        }
예제 #15
0
        /// <summary>
        /// 指定したオブジェクトを指定した型として文字列に変換します。
        /// </summary>
        /// <param name="t">変換元のオブジェクトの型を指定します。</param>
        /// <param name="value">変換元のオブジェクトを指定します。</param>
        /// <returns>変換後の文字列を返します。</returns>
        public static string ToString(System.Type t, object value)
        {
            switch (t.FullName.GetHashCode() & 0x7fffffff)
            {
            case 0x038D0F82:
                if (t != typeof(System.Int16))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int16)value));

            case 0x6D318EFD:
                if (t != typeof(System.UInt16))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt16)value));

            case 0x1B47F8B8:
                if (t != typeof(System.Int32))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int32)value));

            case 0x03FB8EF9:
                if (t != typeof(System.UInt32))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt32)value));

            case 0x4A1B9AE7:
                if (t != typeof(System.Int64))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int64)value));

            case 0x61CC8EFB:
                if (t != typeof(System.UInt64))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt64)value));

            case 0x4EE7D89D:
                if (t != typeof(System.SByte))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.SByte)value));

            case 0x2F001A17:
                if (t != typeof(System.Byte))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Byte)value));

            case 0x1B1EFB13:
                if (t != typeof(System.Decimal))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Decimal)value));

            case 0x44059415:
                if (t != typeof(System.Char))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Char)value));

            case 0x3EACB635:
                if (t != typeof(System.Single))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Single)value));

            case 0x0ED5FC72:
                if (t != typeof(System.Double))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Double)value));

            case 0x71309BFC:
                if (t != typeof(System.Boolean))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Boolean)value));

            case 0x5981F920:
                if (t != typeof(System.String))
                {
                    goto default;
                }
                return((string)value);

            case 0x1D77C984:
                if (t != typeof(System.IntPtr))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int64)value));

            case 0x65648F3B:
                if (t != typeof(System.UIntPtr))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt64)value));

            case 0x29BD8EB6:
                if (t != typeof(System.Guid))
                {
                    goto default;
                }
                return(System.Xml.XmlConvert.ToString((System.Guid)value));

            case 0x1FE98930:
                if (t != typeof(System.TimeSpan))
                {
                    goto default;
                }
                return(System.Xml.XmlConvert.ToString((System.TimeSpan)value));

            case 0x4A398CD8:
                if (t != typeof(System.DateTime))
                {
                    goto default;
                }
                //.NET Framework 2.0 : System.Xml.XmlDateTimeSerializationMode を指定
                return(System.Convert.ToString((System.DateTime)value));

            case 0x7F721A17:
                if (t != typeof(System.Type))
                {
                    goto default;
                }
                return(((System.Type)value).FullName);

            case 0x0458EA59:
                if (t != typeof(System.Boolean[]))
                {
                    goto default;
                }
                return(ToString((bool[])value));

            default:
                //	typeconv:
                if (t.IsEnum)
                {
                    return(value.ToString());                               //System.Enum
                }
                if (t.GetCustomAttributes(typeof(System.ComponentModel.TypeConverterAttribute), false).Length == 0)
                {
                    goto serial;
                }
                System.ComponentModel.TypeConverter conv = System.ComponentModel.TypeDescriptor.GetConverter(t);
                if (conv.CanConvertTo(typeof(string)) && conv.CanConvertFrom(typeof(string)))
                {
                    try{ return(conv.ConvertToString(value)); }catch {}
                }
serial:
                if (t.GetCustomAttributes(typeof(System.SerializableAttribute), false).Length == 0)
                {
                    goto op_implicit;
                }
                using (System.IO.MemoryStream memstr = new System.IO.MemoryStream()){
                    Convert.binF.Serialize(memstr, value);
                    //--長さ
                    int len;
                    try{
                        len = (int)memstr.Length;
                    }catch (System.Exception e) {
                        throw new System.Exception("データの量が大きすぎるので文字列に変換できません", e);
                    }
                    //--文字列に変換
                    byte[] buff = new byte[len];
                    memstr.Position = 0;
                    memstr.Read(buff, 0, len);
                    return(System.Convert.ToBase64String(buff));
                }
op_implicit:
                System.Reflection.MethodInfo[] ms = t.GetMethods(BF_PublicStatic);
                for (int i = 0; i < ms.Length; i++)
                {
                    if (ms[i].Name != "op_Implicit" || ms[i].ReturnType != typeof(string))
                    {
                        continue;
                    }
                    System.Reflection.ParameterInfo[] ps = ms[i].GetParameters();
                    if (ps.Length != 1 || ps[0].ParameterType != t)
                    {
                        continue;
                    }
                    return((string)ms[i].Invoke(null, new object[] { value }));
                }
                throw new System.ArgumentException(string.Format(TOSTR_NOTSUPPORTEDTYPE, t), "t");
            }
#if NET1_1
            switch (t.FullName.GetHashCode() & 0x7fffffff)
            {
            case 0x2DBDA61A:                    //case 0xE31638:
                if (t != typeof(System.Int16))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int16)value));

            case 0x1107D7EF:                    //case 0xE3166C:
                if (t != typeof(System.UInt16))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt16)value));

            case 0x2DBDA65C:                    //case 0xE312F4:
                if (t != typeof(System.Int32))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int32)value));

            case 0x1107D829:                    //case 0xE316A0:
                if (t != typeof(System.UInt32))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt32)value));

            case 0x2DBDA63F:                    //case 0xE316D4:
                if (t != typeof(System.Int64))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int64)value));

            case 0x1107D84A:                    //case 0xE31708:
                if (t != typeof(System.UInt64))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt64)value));

            case 0x2EF00F97:                    //case 0xE315D0:
                if (t != typeof(System.SByte))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.SByte)value));

            case 0x244D3E44:                    //case 0xE31604:
                if (t != typeof(System.Byte))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Byte)value));

            case 0x32C73145:                    //case 0xE317A4:
                if (t != typeof(System.Decimal))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Decimal)value));

            case 0x244C7CD6:                    //case 0xE3159C:
                if (t != typeof(System.Char))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Char)value));

            case 0x0EC74674:                    //case 0xE3173C:
                if (t != typeof(System.Single))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Single)value));

            case 0x5E38073B:                    //case 0xE31770:
                if (t != typeof(System.Double))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Double)value));

            case 0x604332EA:                    //case 0xE31568:
                if (t != typeof(System.Boolean))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Boolean)value));

            case 0x0DE37C3B:                    //case 0xE31328:
                if (t != typeof(System.String))
                {
                    goto default;
                }
                return((string)value);

            case 0x6572ED4B:                    //case 0xE37678:
                if (t != typeof(System.IntPtr))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.Int64)value));

            case 0x3203515E:                    //case 0xE376AC:
                if (t != typeof(System.UIntPtr))
                {
                    goto default;
                }
                return(System.Convert.ToString((System.UInt64)value));

            case 0x244AC511:                    //case 0xE376E0:
                if (t != typeof(System.Guid))
                {
                    goto default;
                }
                return(System.Xml.XmlConvert.ToString((System.Guid)value));

            case 0x4BD7DD17:                    //case 0xE37714:
                if (t != typeof(System.TimeSpan))
                {
                    goto default;
                }
                return(System.Xml.XmlConvert.ToString((System.TimeSpan)value));

            case 0x7F9DDECF:                    //case 0xE317D8:
                if (t != typeof(System.DateTime))
                {
                    goto default;
                }
                //.NET Framework 2.0 : System.Xml.XmlDateTimeSerializationMode を指定
                return(System.Convert.ToString((System.DateTime)value));

            case 0x24524716:                    //case 0xE37610:
                if (t != typeof(System.Type))
                {
                    goto default;
                }
                return(((System.Type)value).FullName);

            //	case 0x2453BC7A://case 0xE37748:
            //		if(t!=typeof(void))goto default;
            //		break;
            case 0x7DDB9ECC:                    //case 0xE37778:
                if (t != typeof(System.Boolean[]))
                {
                    goto default;
                }
                return(ToString((bool[])value));

            //	case 0x45EBBE0:
            //		if(t!=typeof(System.Windows.Forms.SelectionRange))goto default;
            //		return Convert.selectionRangeConv.ConvertToString(value);
            //	case 0x244D9E9D://case 0xE311BC:
            //		if(t!=typeof(System.Enum))goto default;
            //		return System.Xml.XmlConvert.ToString((System.Int64)value);
            default:
                //	typeconv:
                if (t.IsEnum)
                {
                    return(value.ToString());                               //System.Enum
                }
                if (t.GetCustomAttributes(typeof(System.ComponentModel.TypeConverterAttribute), false).Length == 0)
                {
                    goto serial;
                }
                System.ComponentModel.TypeConverter conv = System.ComponentModel.TypeDescriptor.GetConverter(t);
                if (conv.CanConvertTo(typeof(string)) && conv.CanConvertFrom(typeof(string)))
                {
                    try{ return(conv.ConvertToString(value)); }catch {}
                }
serial:
                if (t.GetCustomAttributes(typeof(System.SerializableAttribute), false).Length == 0)
                {
                    goto op_implicit;
                }
                using (System.IO.MemoryStream memstr = new System.IO.MemoryStream()){
                    Convert.binF.Serialize(memstr, value);
                    //--長さ
                    int len;
                    try{
                        len = (int)memstr.Length;
                    }catch (System.Exception e) {
                        throw new System.Exception("データの量が大きすぎるので文字列に変換できません", e);
                    }
                    //--文字列に変換
                    byte[] buff = new byte[len];
                    memstr.Position = 0;
                    memstr.Read(buff, 0, len);
                    return(System.Convert.ToBase64String(buff));
                }
op_implicit:
                System.Reflection.MethodInfo[] ms = t.GetMethods(BF_PublicStatic);
                for (int i = 0; i < ms.Length; i++)
                {
                    if (ms[i].Name != "op_Implicit" || ms[i].ReturnType != typeof(string))
                    {
                        continue;
                    }
                    System.Reflection.ParameterInfo[] ps = ms[i].GetParameters();
                    if (ps.Length != 1 || ps[0].ParameterType != t)
                    {
                        continue;
                    }
                    return((string)ms[i].Invoke(null, new object[] { value }));
                }
                throw new System.ArgumentException(string.Format(TOSTR_NOTSUPPORTEDTYPE, t), "t");
            }
#endif
        }