Example #1
0
        /// <summary>
        /// Returns a value indicating whether the current <see cref="ModuleVersion"/> object is equal to a specified object.
        /// </summary>
        /// <param name="obj">An object to compare with the current <see cref="ModuleVersion"/> object, or null.</param>
        /// <returns><see cref="bool"/></returns>
        public override bool Equals(object obj)
        {
            if ((obj == null) || !(obj is ModuleVersion))
            {
                return(false);
            }
            ModuleVersion version = (ModuleVersion)obj;

            return((Major == version.Major) && (Minor == version.Minor) &&
                   (Build == version.Build) && (Revision == version.Revision));
        }
Example #2
0
        /// <summary>
        /// Converts the string representation of a version number to an equivalent <see cref="ModuleVersion"/> object.
        /// </summary>
        /// <param name="s">A string that contains a version number to convert.</param>
        /// <param name="version">When this method returns, contains the <see cref="ModuleVersion"/> equivalent of the number that is contained in input, if the conversion succeeded. If input is null, Empty, or if the conversion fails, result is null when the method returns.</param>
        /// <returns></returns>
        public static bool TryParse(string s, out ModuleVersion version)
        {
            version = new ModuleVersion();
            bool result = version.Initialize(s, true);

            if (!result)
            {
                version = null;
            }
            return(result);
        }
Example #3
0
 /// <summary>
 /// Validates the underlying <see cref="License{T}"/> based on its module version using a specified module version.
 /// </summary>
 /// <param name="version">The specified module version.</param>
 /// <returns><see cref="LicenseValidator{T}"/></returns>
 public LicenseValidator <T> ForVersion(ModuleVersion version)
 {
     Result = Result && License.MinimumVersion <= version && License.MaximumVersion >= version;
     if (License <T> .ThrowExcpetionsOnValidation && !Result)
     {
         throw new LicenseValidationException(
                   "License validation failed. The specified license was not issued for this release.",
                   ValidationFault.IncorrectVersion);
     }
     return(this);
 }
Example #4
0
        /// <summary>
        /// Compares the current <see cref="ModuleVersion"/> object to a specified object and returns an indication of their relative values.
        /// </summary>
        /// <param name="obj">An object to compare, or null.</param>
        /// <returns><see cref="int"/></returns>
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            ModuleVersion version = (ModuleVersion)(obj ?? throw new ArgumentException(nameof(obj)));

            int major = Major.CompareTo(version.Major);

            if (major != 0)
            {
                return(major);
            }

            int minor = Minor.CompareTo(version.Minor);

            if (minor != 0)
            {
                return(minor);
            }

            int build = Build.CompareTo(version.Build);

            if (build != 0)
            {
                return(build);
            }

            int revision = Revision.CompareTo(version.Revision);

            if (revision != 0)
            {
                return(revision);
            }

            return(0);
        }