GetEnumVersion static method

ExchangeVersion? GetEnumVersion(
  1. Type enumType,
  2. dynamic enumValue
)
Gets version for enum member. Type of the enum. The enum name.

Implementation

static ExchangeVersion? GetEnumVersion(Type enumType, dynamic enumValue) {
  Map<dynamic, ExchangeVersion> exchangeVersions =
      _requiredServerVersion.Member![enumType]!;

  EwsUtilities.Assert(
      exchangeVersions != null && exchangeVersions.isNotEmpty,
      "EwsUtilities.GetEnumVersion",
      "Enum member $enumValue not found in $enumType");

  if (exchangeVersions.containsKey(enumValue)) {
    return exchangeVersions[enumValue];
  } else {
    return ExchangeVersion.Exchange2007_SP1;
  }

//            MemberInfo[] memberInfo = enumType.GetMember(enumName);
//            EwsUtilities.Assert(
//                                (memberInfo != null) && (memberInfo.Length > 0),
//                                "EwsUtilities.GetEnumVersion",
//                                "Enum member " + enumName + " not found in " + enumType);
//
//            object[] attrs = memberInfo[0].GetCustomAttributes(typeof(RequiredServerVersionAttribute), false);
//            if (attrs != null && attrs.Length > 0)
//            {
//                return ((RequiredServerVersionAttribute)attrs[0]).Version;
//            }
//            else
//            {
//                return ExchangeVersion.Exchange2007_SP1;
//            }
}