/// <summary> /// Returns a string representation of this object. /// </summary> /// <returns>A string representation of this object.</returns> public override bool Equals(object obj) { if (obj is OptDouble) { OptInt optValue = (OptInt)obj; return((_activated == optValue._activated) && (_val == optValue._val)); } return(false); }
/// <summary> /// Converts the specified string to its <see cref="OptInt"/> equivalent. /// </summary> /// <param name="value">A string representation of a <see cref="OptInt"/>.</param> /// <param name="result">When this method returns, if the conversion succeeded, /// contains a <see cref="OptInt"/> reprensention the OptValue specified by <paramref name="value"/>. /// </param> /// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns> public static bool TryParse(string value, out OptInt result) { Regex r = new Regex(@"\((?<o>),(?<v>)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { result = new OptInt( bool.Parse(m.Result("${o}")), int.Parse(m.Result("${v}")) ); return(true); } result = OptInt.Zero; return(false); }
public OptInt(OptInt optValue) { _activated = optValue._activated; _val = optValue._val; }
public void SetMaxNumber(OptInt maxNumber) { OptMaxNumber = maxNumber; }
public void SetMaxNumber(int maxNumber) => OptMaxNumber = new OptInt(true, maxNumber);
public virtual OptInt OptGlobMaxNumber(Packable packable) { OptInt optMaxNumberWeight = new OptInt(OptMaxWeight.Activated, (int)Math.Floor((OptMaxWeight.Value - Container.Weight) / packable.Weight)); return(OptInt.Min(optMaxNumberWeight, OptMaxNumber)); }
/// <summary> /// Converts the specified string to its <see cref="OptInt"/> equivalent. /// </summary> /// <param name="value">A string representation of a <see cref="OptInt"/>.</param> /// <param name="result">When this method returns, if the conversion succeeded, /// contains a <see cref="OptInt"/> reprensention the OptValue specified by <paramref name="value"/>. /// </param> /// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns> public static bool TryParse(string value, out OptInt result) { Regex r = new Regex(@"\((?<o>),(?<v>)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { result = new OptInt( bool.Parse(m.Result("${o}")), int.Parse(m.Result("${v}")) ); return true; } result = OptInt.Zero; return false; }
public void SetMaxNumber(int maxNumber) { _maxNumber = new OptInt(true, maxNumber); }