예제 #1
0
 internal static string StringConverter(StringOrPrimitive <T> val)
 {
     if (val.StringValue != null)
     {
         return(val.StringValue);
     }
     else
     {
         return("" + val.PrimitiveValue);
     }
 }
예제 #2
0
        internal StringOrPrimitive <T> ValueConverter(string stringVal)
        {
            StringOrPrimitive <T> stringOrPrimitive = null;

            if (IsLegalString(stringVal))
            {
                stringOrPrimitive = new StringOrPrimitive <T>(stringVal);
            }
            else
            {
                T value;

                if (_tryParse(stringVal, out value))
                {
                    stringOrPrimitive = new StringOrPrimitive <T>(value);
                }
                else
                {
                    var message = string.Format(CultureInfo.CurrentCulture, Resources.ConversionExceptionMessage, value);
                    throw new ConversionException(message);
                }
            }
            return(stringOrPrimitive);
        }