public void RedumpSystemHasValidCategory(RedumpSystemComboBoxItem system) { RedumpSystem[] markers = { RedumpSystem.MarkerArcadeEnd, RedumpSystem.MarkerDiscBasedConsoleEnd, /* RedumpSystem.MarkerOtherConsoleEnd, */ RedumpSystem.MarkerComputerEnd, RedumpSystem.MarkerOtherEnd }; // Non-system items won't map if (system.IsHeader) { return; } // Null will never map if (system?.Value == null) { return; } // we check that the category is the first category value higher than the system SystemCategory category = ((RedumpSystem?)system).GetCategory(); RedumpSystem? marker = null; switch (category) { case SystemCategory.Arcade: marker = RedumpSystem.MarkerArcadeEnd; break; case SystemCategory.DiscBasedConsole: marker = RedumpSystem.MarkerDiscBasedConsoleEnd; break; /* case SystemCategory.OtherConsole: marker = RedumpSystem.MarkerOtherConsoleEnd; break; */ case SystemCategory.Computer: marker = RedumpSystem.MarkerComputerEnd; break; case SystemCategory.Other: marker = RedumpSystem.MarkerOtherEnd; break; } Assert.NotNull(marker); Assert.True(marker > system); Array.ForEach(markers, mmarker => { // a marker can be the same of the found one, or one of a category before or a category after but never in the middle between // the system and the mapped category Assert.True(mmarker == marker || mmarker <system || mmarker> marker); }); }
/// <summary> /// 作用:系统配置界面 /// 作者:汪建龙 /// 时间:2016年12月5日10:18:18 /// </summary> /// <returns></returns> public ActionResult Index(SystemCategory category = SystemCategory.City) { ViewBag.Category = category; return(View()); }