private static RealmInfo BuildRealmInfoFromModel(Realmlist realm) { //TODO: Handle realm version/build info better RealmBuildInformation buildInfo = new RealmBuildInformation(ExpansionType.WrathOfTheLichKing, 3, 5, (short)(realm.Gamebuild & 0xFF)); DefaultRealmInformation information = new DefaultRealmInformation((RealmFlags)realm.Flag, realm.Name, new RealmEndpoint($"{realm.Address}:{realm.Port}"), 0, 0, realm.Timezone, (byte)realm.Id); //TODO: Implement character count query //TODO: Implement float??? population return(information.Flags.HasFlag(RealmFlags.SpecifyBuild) ? new RealmInfo((RealmType)realm.Icon, false, information, buildInfo) : new RealmInfo((RealmType)realm.Icon, false, information)); }
#pragma warning restore AsyncFixer01 // Unnecessary async/await usage private static RealmInfo RebuildRealmInfo(RealmInfo info, string newAddress) { DefaultRealmInformation information = info.Information as DefaultRealmInformation; DefaultRealmInformation newRealmDefaultInfo = new DefaultRealmInformation(information.Flags & ~RealmFlags.Offline, information.RealmString, new RealmEndpoint(newAddress), information.PopulationLevel, info.Information.CharacterCount, information.RealmTimeZone, information.RealmId); if (!info.HasBuildInformation) { return(new RealmInfo(info.RealmType, info.isLocked, newRealmDefaultInfo)); } else { //new RealmBuildInformation(ExpansionType.Vanilla, 12, 1, 5875) RealmBuildInformation buildInfo = info.BuildInfo; return(new RealmInfo(info.RealmType, false, newRealmDefaultInfo, new RealmBuildInformation(ExpansionType.WrathOfTheLichKing, 3, 5, 12340))); } }
/// <inheritdoc /> public RealmInfo(RealmType realmType, bool isLocked, DefaultRealmInformation defaultInformation, [CanBeNull] RealmBuildInformation buildInfo) { if (!Enum.IsDefined(typeof(RealmType), realmType)) { throw new ArgumentOutOfRangeException(nameof(realmType), "Value should be defined in the RealmType enum."); } //Don't check build info. It can be null. Only if the specify build was not included RealmType = realmType; this.isLocked = isLocked; DefaultInformation = defaultInformation; BuildInfo = buildInfo; //Check after initialization if we have everything needed if (HasBuildInformation && BuildInfo == null) { throw new ArgumentNullException(nameof(buildInfo), $"{defaultInformation} has the {RealmFlags.SpecifyBuild} flags but no build information is provided."); } }