public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(Enum.GetValues(value.GetType()).Cast <Enum>().Select(e => new EnumValueDescription() { Value = e, Description = EnumHelper.Description(e) })); }
private void CheckWinner() { var result = m_userFigure.CompareTo(m_bot.SelectedFigure); var msg = $"Computer move: {m_bot.SelectedFigure.Name}\n" + $"{EnumHelper.Description(result)}\nHMAC key: {m_bot.Key}"; PrintMsg(msg); }
/// <summary> /// 文件服务器接收上传文件[要求使用multipart/form-data请求编码类型][上传图片也不保存大/中/小图,需要的时候,自己加上webp后缀即可][不考虑自定义文件名的情况] /// </summary> public List <string> Upload(UploadFileCmd cmd) { if (cmd.Files == null || cmd.Files.Files.Count == 0) { throw new Exception("请选择文件!"); } //文件类型是图片时,进行图片内容类型验证 if (cmd.FileType == FileType.Image) { foreach (var formFile in cmd.Files.Files) { if (!formFile.ContentType.Contains("image")) { throw new Exception("图片格式不正确!"); } } } //验证文件路径长度和文件长度是否一致 if (string.IsNullOrEmpty(cmd.FilePath)) { throw new Exception("文件保存路径不能为空!"); } var list = new List <string>(); var fileServer = _fileServerSettings.FileServer; foreach (var formFile in cmd.Files.Files) { var fileExt = Path.GetExtension(formFile.FileName); //保存到指定路径下 var directory = $"/upload/{EnumHelper.Description(cmd.ComeFrom)}/{cmd.FilePath}/{DateTime.Now:yyyyMM}/"; var relativePath = directory + StringGenerator.FileName(fileExt); if (!Directory.Exists(_env.WebRootPath + directory)) { Directory.CreateDirectory(_env.WebRootPath + directory); } using (var fileStream = new FileStream(_env.WebRootPath + relativePath, FileMode.OpenOrCreate)) { formFile.CopyTo(fileStream); list.Add(fileServer + relativePath); } } return(list); }
private async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { LoadInfo(); var api = !_isForTeacher ? $"api/Schedule?groupId={App.GroupId}" : $"api/TSchedule?teacherId={App.TeacherId}"; var id = !_isForTeacher ? App.GroupId : App.TeacherId; GroupItems.Clear(); var items = await DataStore.GetLessonsAsync(api, id, _isForTeacher, true); foreach (var item in items.GroupBy(x => x.WeekDay).OrderBy(x => x.Key)) { var groupItem = new GroupItem { IsCurrent = (int)item.Key == (int)DateTime.Now.DayOfWeek, Title = EnumHelper.Description(item.Key), Items = new ObservableCollection <Lesson>(item.OrderBy(x => x.Order).ToList()) }; GroupItems.Add(groupItem); } } catch (Exception ex) { Debug.WriteLine(ex); Info = "Серверге қосылу мүмкін емес..."; } finally { IsBusy = false; } }
public void Description() { string description = EnumHelper.Description(TestEnum.B); Assert.AreEqual("B", description); }
public void Consulta_Descricao_Enum() { var result = EnumHelper.Description(ETipoOrcamento.Despesa); Assert.AreEqual("Despesa", result); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(EnumHelper.Description((Enum)value)); }