Exemplo n.º 1
0
        public string GetString(string name)
        {
#if NOT_PFX
            object value = GetValue(name, typeof(System.String));
            if (value == null)
            {
                return(null);
            }
            return(converter.ToString(value));
#else
            throw new NotSupportedException();
#endif
        }
 internal static object Convert(IFormatterConverter formatterConverter, object value, TypeCode typeCode)
 {
     return(typeCode switch
     {
         TypeCode.Boolean => formatterConverter.ToBoolean(value),
         TypeCode.Byte => formatterConverter.ToBoolean(value),
         TypeCode.Char => formatterConverter.ToChar(value),
         TypeCode.DateTime => formatterConverter.ToDateTime(value),
         TypeCode.Decimal => formatterConverter.ToDecimal(value),
         TypeCode.Double => formatterConverter.ToDouble(value),
         TypeCode.Int16 => formatterConverter.ToInt16(value),
         TypeCode.Int32 => formatterConverter.ToInt32(value),
         TypeCode.Int64 => formatterConverter.ToInt64(value),
         TypeCode.SByte => formatterConverter.ToSByte(value),
         TypeCode.Single => formatterConverter.ToSingle(value),
         TypeCode.String => formatterConverter.ToString(value),
         TypeCode.UInt16 => formatterConverter.ToUInt16(value),
         TypeCode.UInt32 => formatterConverter.ToUInt32(value),
         TypeCode.UInt64 => formatterConverter.ToUInt64(value),
         _ => throw new NotSupportedException("Unsupported type code: " + typeCode),
     });
Exemplo n.º 3
0
        public string?GetString(string name)
        {
            Type   foundType;
            object?value = GetElement(name, out foundType);

            return(ReferenceEquals(foundType, typeof(string)) || value == null ? (string?)value : _converter.ToString(value));
        }
        public string GetString(string name)
        {
            var value = GetValue(name, typeof(string));

            return(converter.ToString(value));
        }