예제 #1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var valueAsString = value as string;

            if (valueAsString != null)
            {
                return(MaskableInt32.GetUnmaskedValue(valueAsString));
            }

            return(base.ConvertFrom(context, culture, value));
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            JToken token       = JToken.Load(reader);
            string maskedValue = token.ToObject <string>();

            if (maskedValue != null)
            {
                try
                {
                    return(MaskableInt32.GetUnmaskedValue(maskedValue));
                }
                catch (ArgumentException exception)
                {
                    throw new JsonSerializationException(exception.Message);
                }
            }

            return(null);
        }
 public bool Equals(MaskableInt32 other)
 {
     return(Val == other.Val);
 }
예제 #4
0
 public int CompareTo(MaskableInt32 other)
 {
     return(Val.CompareTo(other.Val));
 }