/// <summary> /// 修改插件信息的窗口 /// </summary> public PluginInfoCtrl() { InitializeComponent(); this.cmbShortcutKeys.Items.AddRange(Enum.GetNames(typeof(Shortcut))); this.cmbShortcutKeys.SelectedIndex = 0; this.cmbInvokeType.Items.AddRange(EnumDescriptionHelper.GetDescriptions <EPluginInvokeType>()); this.cmbInvokeType.SelectedIndex = 0; }
public async Task <ActionResult <IEnumerable <MemberLabelDescription> > > GetMemberLabels() { var enumList = EnumDescriptionHelper.GetEnumDescriptions <MemberLabel>(); return(Ok(await Task.FromResult(enumList.Select(e => new MemberLabelDescription { Code = e.value, Description = e.description }).ToArray()))); }
protected virtual void DescribeType(EnumItemBuilder builder, Type enumType) { var enumValue = Enum.ToObject(enumType, builder.Value); if (EnumDescriptionHelper.TryGetDisplayName(enumType, enumValue, out var displayName)) { builder.Hint("display-name", displayName); } }
/// <summary> /// Returns All The Users in an Enum Form /// </summary> /// <returns></returns> protected IEnumerable <Translation> GetTranslations() { var bibleVersions = from BibleConstants.BibleVersions s in Enum.GetValues(typeof(BibleConstants.BibleVersions)) select new Translation { Abbreviation = s.ToString(), Name = EnumDescriptionHelper.GetDescription(s) }; return(bibleVersions); }
/// <summary> /// 修改插件信息的窗口 /// </summary> /// <param name="plugin"></param> public PluginInfoForm(IPluginItem plugin = null) { InitializeComponent(); this.cmbShortcutKeys.Items.AddRange(Enum.GetNames(typeof(Shortcut))); this.cmbShortcutKeys.SelectedIndex = 0; this.cmbInvokeType.Items.AddRange(EnumDescriptionHelper.GetDescriptions <EPluginInvokeType>()); this.cmbInvokeType.SelectedIndex = 0; if (plugin != null) { Plugin = plugin; } }
public async Task <ActionResult <ReferralPrintRequestResponse> > ReprintSupport(string fileId, string supportId, SupportReprintReason reprintReason) { var result = await messagingClient.Send(new ReprintSupportCommand { FileId = fileId, SupportId = supportId, ReprintReason = EnumDescriptionHelper.GetEnumDescription(reprintReason), RequestingUserId = currentUserId }); return(Ok(new ReferralPrintRequestResponse { PrintRequestId = result })); }
public void ChangeFormLanguage(Localizations newLocalization) { LanguageSettings LS = new LanguageSettings(); LS.SetCulture(newLocalization); var resources = new ComponentResourceManager(typeof(Main)); CultureInfo newCultureInfo = new CultureInfo(EnumDescriptionHelper.GetEnumDescription(newLocalization)); foreach (Control c in this.Controls) { resources.ApplyResources(c, c.Name, newCultureInfo); } resources.ApplyResources(this, "$this", newCultureInfo); }
public ActionResult <IEnumerable <Code> > GetCodes(string forEnumType) { if (!string.IsNullOrEmpty(forEnumType)) { var type = Assembly.GetExecutingAssembly().ExportedTypes.Where(t => t.Name.Equals(forEnumType, StringComparison.OrdinalIgnoreCase) && t.IsEnum).FirstOrDefault(); if (type == null) { return(NotFound(forEnumType)); } var values = EnumDescriptionHelper.GetEnumDescriptions(type); return(Ok(values.Select(e => new Code { Type = type.Name, Value = e.Value, Description = e.Description }).ToArray())); } return(BadRequest(new ProblemDetails { Detail = "empty query parameter" })); }
public MarsRoversResource CalculateRoversPosition(MarsRoversModel model) { var result = new MarsRoversResource(); var rovers = new Dictionary <int, Rover>(); var directions = EnumDescriptionHelper.GetEnumDescriptions <Direction>().ToList(); var commands = EnumDescriptionHelper.GetEnumDescriptions <RoverCommand>().ToList(); var index = 0; try { // InitializeRovers foreach (var roverModel in model.Rovers) { index++; rovers.Add(index, InitializeRover(index, roverModel, directions, commands)); } ; // Validate starting positions foreach (var rover in rovers) { PositionValidator.ValidatePosition(rover.Value, rover.Value.CurrentPosition, rovers, model.PlateauX, model.PlateauY, true); } // ProcessRovers var deployedRovers = rovers.Where(x => x.Value.Deployed).ToDictionary(x => x.Key, x => x.Value);; foreach (var rover in deployedRovers) { ProcessRoverCommands(rover.Value, deployedRovers, model.PlateauX, model.PlateauY); } // Map results result = MapRoversToResource(rovers); } catch (Exception ex) { _logger.LogError(ex, ex.Message); throw; } return(result); }
public RoverProgramValidator() { RuleFor(p => p.InitialX) .FieldGreaterThanOrEqualTo(0); RuleFor(p => p.InitialY) .FieldGreaterThanOrEqualTo(0); RuleFor(p => p.InitialDirection) .NotNull() .NotEmpty() .FieldLength(1) .Must(p => EnumDescriptionHelper.GetEnumDescriptions <Direction>().Contains(p.ToUpper())) .WithMessage($"{nameof(RoverProgramModel.InitialDirection)} should be one of the following values: [N - North, E - East, S - South, W - West]"); RuleForEach(p => p.Commands) .Must(p => EnumDescriptionHelper.GetEnumDescriptions <RoverCommand>().Contains(p.ToString().ToUpper())) .When(p => !string.IsNullOrEmpty(p.Commands)) .WithMessage($"{nameof(RoverProgramModel.Commands)} should consist of the following values: [M - Move, L - Left, R - Right]"); }
public EnumDescriptions(object value) { Name = EnumDescriptionHelper.GetDisplayName((Enum)value); Value = value; }
/// <summary> /// 提供获取指定类型数据库的操作、获取数据提供程序名的方法 /// </summary> static ProviderFactory() { ProviderFactoryDict = new Dictionary <EDbProviderType, DbProviderFactory>(); ProviderNameDict = EnumDescriptionHelper.GetValueAndDescriptionDict <EDbProviderType>(); }