Esempio n. 1
0
        /// <summary>
        /// Parses  the route grade from the given YDS representation.
        /// </summary>
        /// <param name="grade">Route grade in YDS representation.</param>
        /// <returns>Route grade.</returns>
        public static RouteGrade FromYDS(string grade)
        {
            Match m = null;
            double value = 0;
            RouteGrade ret = null;

            if (!string.IsNullOrEmpty(grade))
            {
                grade = grade.Trim().ToLowerInvariant();

                if (grade.Length > 5)
                {
                    m = Regex.Match(grade, "5\\.[0-9]{1,2}(a|b|c|d)?", RegexOptions.IgnoreCase);

                    if (m != null && m.Success)
                        grade = m.Value;
                }

                foreach (double key in RawToYDS.Keys.OrderBy(k => k))
                {
                    if (string.Compare(RawToYDS[key], grade, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        value = key;
                        break;
                    }
                }
            }

            if (value > 0)
                ret = new RouteGrade() { Value = value, _parsedClimbing = ClimbingTypes.Sport };

            return ret;
        }
Esempio n. 2
0
 /// <summary>
 /// Copies the state of the current object into the given one.
 /// </summary>
 /// <param name="target">Target object.</param>
 /// <exception cref="System.ArgumentNullException"><paramref name="target">target</paramref> is null.</exception>
 public void CopyTo(RouteGrade target)
 {
     if (target == null)
         throw new System.ArgumentNullException("target");
     else
     {
         target.Value = this.Value;
         target._parsedClimbing = this._parsedClimbing;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of an object.
 /// </summary>
 /// <param name="copyFrom">Object to copy state from.</param>
 /// <exception cref="System.ArgumentNullException"><paramref name="copyFrom">copyFrom</paramref> is null.</exception>
 public RouteGrade(RouteGrade copyFrom)
 {
     if (copyFrom == null)
         throw new System.ArgumentNullException("copyFrom");
     else
         copyFrom.CopyTo(this);
 }