コード例 #1
0
 /// <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);
 }
コード例 #2
0
ファイル: OptInt.cs プロジェクト: zanxueyan/StackBuilder
 /// <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) && (Value == optValue.Value));
     }
     return(false);
 }
コード例 #3
0
        /// <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(
                    int.Parse(m.Result("${o}")) == 1,
                    int.Parse(m.Result("${v}"))
                    );
                return(true);
            }
            result = OptInt.Zero;
            return(false);
        }
コード例 #4
0
ファイル: OptInt.cs プロジェクト: zanxueyan/StackBuilder
 public static OptInt Max(OptInt opt1, OptInt opt2)
 {
     if (opt1.Activated && !opt2.Activated)
     {
         return(opt1);
     }
     else if (!opt1.Activated && opt2.Activated)
     {
         return(opt2);
     }
     else if (opt1.Activated && opt2.Activated)
     {
         return(new OptInt(true, Math.Max(opt1.Value, opt2.Value)));
     }
     else
     {
         return(Zero);
     }
 }
コード例 #5
0
 public OptInt(OptInt optValue)
 {
     _activated = optValue._activated;
     _val       = optValue._val;
 }
コード例 #6
0
ファイル: OptInt.cs プロジェクト: zanxueyan/StackBuilder
 public OptInt(OptInt optValue)
 {
     Activated = optValue.Activated;
     Value     = optValue.Value;
 }