Пример #1
0
        public string AsString(string defaultValue = null)
        {
            if (mType == TypeCode.String)
            {
                return((string)mObject);
            }
            switch (mType)
            {
            case TypeCode.Undefined:
                return(defaultValue);

            case TypeCode.Null:
                return(null);

            case TypeCode.Boolean:
                return(mBoolValue ? "true" : "false");

            case TypeCode.Int:
                return(mIntValue.ToString());

            case TypeCode.UInt:
                return(UIntValue.ToString());

            case TypeCode.Number:
                return(mNumberValue.ToString());

            case TypeCode.Object:
                return(mObject.ToString());

            default:
                throw new InvalidCastException("Cannot cast to String");
            }
        }
Пример #2
0
        public override string ToString()
        {
            switch (mType)
            {
            case TypeCode.Undefined:
                return("<undefined>");

            case TypeCode.Null:
                return("<null>");

            case TypeCode.Boolean:
                return(mBoolValue ? "true" : "false");

            case TypeCode.Int:
                return(mIntValue.ToString());

            case TypeCode.UInt:
                return(UIntValue.ToString());

            case TypeCode.Number:
                return(mNumberValue.ToString());

            case TypeCode.String:
                return((string)mObject);

            case TypeCode.Object:
                return(mObject.ToString());

            default:
                return("Type: " + this.mType.ToString());
            }
        }
 private void RefreshValue()
 {
     if (HexdecimalRadioButton.IsChecked == true)
     {
         var hexString = ValueSize == ValueSize.UInt32 ? UIntValue.ToString("X") : ULongValue.ToString("X");
         if (!string.Equals(hexString, ValueTextBox.Text, StringComparison.OrdinalIgnoreCase))
         {
             ValueTextBox.Text = hexString;
         }
     }
     else
     {
         ValueTextBox.Text = ValueSize == ValueSize.UInt32 ? UIntValue.ToString() : ULongValue.ToString();
     }
 }
Пример #4
0
        public override string ToString()
        {
            switch (_type)
            {
            case Type.Int:
                return(IntValue.ToString());

            case Type.Short:
                return(ShortValue.ToString());

            case Type.UInt:
                return(UIntValue.ToString());

            case Type.ULong:
                return(ULongValue.ToString());

            case Type.UShort:
                return(UShortValue.ToString());

            case Type.Long:
            default:
                return(LongValue.ToString());
            }
        }
 private void DecimalRadioButton_OnChecked(object sender, RoutedEventArgs e)
 {
     ValueTextBox.Text = ValueSize == ValueSize.UInt32 ? UIntValue.ToString() : ULongValue.ToString();
 }