Пример #1
0
        private bool IsInRange(SupportedFirmwareVersion supportedFirmwareVersion)
        {
            VersionBetweenAttribute versionRange = GetVersionRange(supportedFirmwareVersion);

            if (versionRange == null)
            {
                return(false);
            }

            if (versionRange.MinVersionState == VersionState.Exclusive && this <= versionRange.MinVersion)
            {
                return(false);
            }
            if (versionRange.MinVersionState == VersionState.Inclusive && this < versionRange.MinVersion)
            {
                return(false);
            }

            if (versionRange.MaxVersionState == VersionState.Exclusive && this >= versionRange.MaxVersion)
            {
                return(false);
            }
            if (versionRange.MaxVersionState == VersionState.Inclusive && this > versionRange.MaxVersion)
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        private VersionBetweenAttribute GetVersionRange(SupportedFirmwareVersion supportedFirmwareVersion)
        {
            MemberInfo memberInfo = typeof(SupportedFirmwareVersion).GetMember(supportedFirmwareVersion.ToString()).FirstOrDefault();

            if (memberInfo != null)
            {
                VersionBetweenAttribute attribute = (VersionBetweenAttribute)memberInfo.GetCustomAttributes(typeof(VersionBetweenAttribute), false).FirstOrDefault();
                return(attribute);
            }

            return(null);
        }