/// <summary> /// フィルター条件追加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddFilter_Click(object sender, EventArgs e) { try { if (this.cmbFields.SelectedItem == null) { return; } if (this.cmbOperator.SelectedItem == null) { return; } EnumNameAttribute selectedItem = (EnumNameAttribute)this.cmbOperator.SelectedItem; OperatorType op = (OperatorType)selectedItem.EnumValue; ConditionItem condiItem = new ConditionItem(op); condiItem.FieldRef = (IFieldRef)this.cmbFields.SelectedItem; condiItem.Value = this.txtValue.Text; this._targetView.ViewCondition.Nodes.Add(condiItem); InitConditionTree(); } catch (Exception ex) { Log.Write(ex); RSM.ShowMessage(this, ex); } }
///GENMHASH:1D0E421DB766190CD95F143F42464EC7:6A4E7C0B70D703812B26F169D2CFCB2F public ComputeRoles ComputeRole() { if (Inner.ComputeRole == null) { return(ComputeRoles.Unknown); } // ComputeRole is a fluent level convinence enum return(EnumNameAttribute.FromName <ComputeRoles>(Inner.ComputeRole)); }
/// <summary> /// 获取某个枚举某个值的EnumName /// </summary> /// <typeparam name="TEnum"></typeparam> /// <param name="enumValue"></param> /// <returns></returns> public static string GetEnumDescription <TEnum>(TEnum enumValue) { object[] objs = enumValue.GetType().GetField(enumValue.ToString()).GetCustomAttributes(typeof(EnumNameAttribute), false); if (objs.Length > 0) { EnumNameAttribute attr = objs[0] as EnumNameAttribute; return(attr.EnumName); } return(""); }
/// <summary> /// 获取枚举集合 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static List <EnumItem> GetEnumList <T>(int maxValue = -1, int minValue = -1) { List <EnumItem> enumList = new List <EnumItem>(); Type enumType = typeof(T); string[] names = Enum.GetNames(enumType); int[] values = (int[])Enum.GetValues(enumType); if (maxValue == -1) { for (int i = 0; i < values.Length; i++) { object[] objs = enumType.GetField(names[i]).GetCustomAttributes(typeof(EnumNameAttribute), false); if (objs == null || objs.Length == 0) { } else { EnumNameAttribute attr = objs[0] as EnumNameAttribute; string strName = attr.EnumName; int value = values[i]; enumList.Add(new EnumItem() { Key = value, Name = strName }); } } } else { for (int i = 0; i < values.Length; i++) { if (values[i] <= maxValue && values[i] >= minValue) { object[] objs = enumType.GetField(names[i]).GetCustomAttributes(typeof(EnumNameAttribute), false); if (objs == null || objs.Length == 0) { } else { EnumNameAttribute attr = objs[0] as EnumNameAttribute; string strName = attr.EnumName; int value = values[i]; enumList.Add(new EnumItem() { Key = value, Name = strName }); } } } } return(enumList); }
public async Task <IResourceGroupExportResult> ExportTemplateAsync(ResourceGroupExportTemplateOptions options, CancellationToken cancellationToken = default(CancellationToken)) { ExportTemplateRequest exportTemplateRequest = new ExportTemplateRequest(); exportTemplateRequest.Resources = new List <string>() { "*" }; exportTemplateRequest.Options = EnumNameAttribute.GetName(options); var result = await client.ExportTemplateWithHttpMessagesAsync(Name, exportTemplateRequest, cancellationToken : cancellationToken); return(new ResourceGroupExportResultImpl(result.Body)); }
private string GetEnumName(Enum value) { MemberInfo[] mems = value.GetType().GetMember(value.ToString()); if (mems != null && mems.Length > 0) { object[] customAttributes = mems[0].GetCustomAttributes(typeof(EnumNameAttribute), true); if (customAttributes.Count() > 0) { EnumNameAttribute attribute = (EnumNameAttribute)customAttributes[0]; return(attribute.DisplayName); } } return(value.ToString()); }
private void InitOperatorList() { this.cmbOperator.Items.Clear(); this.cmbOperator.DisplayMember = "DisplayName"; this.cmbOperator.ValueMember = "EnumValue"; var mems = typeof(OperatorType).GetMembers(BindingFlags.Public | BindingFlags.Static); foreach (MemberInfo info in mems) { object[] customAttributes = info.GetCustomAttributes(typeof(EnumNameAttribute), true); if (customAttributes.Count() > 0) { EnumNameAttribute item = (EnumNameAttribute)customAttributes[0]; this.cmbOperator.Items.Add(item); } } }
static TreeNodeTypeExtentions() { int index = 0; Type type = typeof(TreeNodeType); TreeNodeType[] values = (TreeNodeType[])Enum.GetValues(type); IEnumerable <FieldInfo> fields = type.GetRuntimeFields(); foreach (FieldInfo field in fields) { EnumNameAttribute name = field.GetCustomAttribute <EnumNameAttribute>(); if (name != null) { TreeNodeType value = values[index - 1]; s_typeNames.Add(value, name.Name); } index++; } }
static AssetClassTypeExtentions() { Type type = typeof(SerializeClassType); SerializeClassType[] values = (SerializeClassType[])Enum.GetValues(type); FieldInfo[] fields = type.GetFields(); for (int i = 1; i < fields.Length; i++) { MemberInfo member = fields[i]; EnumNameAttribute name = member.GetCustomAttribute <EnumNameAttribute>(); if (name == null) { continue; } SerializeClassType value = values[i - 1]; m_typeNames.Add(value, name.Name); } }
/// <summary> /// 検索条件を取得する /// </summary> /// <returns></returns> private SearchArgs GetSearchArgs() { SearchArgs args = new SearchArgs(); //Type EnumNameAttribute selectedItem = (EnumNameAttribute)this.cmbLogType.SelectedItem; args.Type = (LogType)selectedItem.EnumValue; //開始日 if (dtpStartDate.Checked) { args.StartDate = dtpStartDate.Value.Date; } //終了日 if (dtpEndDate.Checked) { args.EndDate = DateTime.Parse(dtpEndDate.Value.ToString("yyyy/MM/dd") + " 23:59:59"); } return(args); }
static TreeNodeTypeExtentions() { int index = 0; Type type = typeof(TreeNodeType); TreeNodeType[] values = (TreeNodeType[])Enum.GetValues(type); IEnumerable <FieldInfo> fields = type.GetRuntimeFields(); Dictionary <TreeNodeType, string> typeNames = new Dictionary <TreeNodeType, string>(values.Length); foreach (FieldInfo field in fields) { if (index > 0) { EnumNameAttribute name = field.GetCustomAttribute <EnumNameAttribute>(); typeNames.Add(values[index - 1], name == null ? values[index - 1].ToString() : name.Name); } index++; } s_typeNames = typeNames; }
/// <summary> /// ログ種別コンボボックスを初期化 /// </summary> private void InitLogTypes() { this.cmbLogType.Items.Clear(); this.cmbLogType.DisplayMember = "DisplayName"; this.cmbLogType.ValueMember = "EnumValue"; var mems = typeof(LogType).GetMembers(BindingFlags.Public | BindingFlags.Static); foreach (MemberInfo info in mems) { object[] customAttributes = info.GetCustomAttributes(typeof(EnumNameAttribute), true); if (customAttributes.Count() > 0) { EnumNameAttribute item = (EnumNameAttribute)customAttributes[0]; this.cmbLogType.Items.Add(item); } } if (this.cmbLogType.Items.Count > 0) { this.cmbLogType.SelectedIndex = 0; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // 替换属性名称 EnumNameAttribute rename = (EnumNameAttribute)attribute; label.text = rename.name; // 重绘GUI bool isElement = Regex.IsMatch(property.displayName, "Element \\d+"); if (isElement) { label.text = property.displayName; } if (property.propertyType == SerializedPropertyType.Enum) { drawEnum(position, property, label); } else { EditorGUI.PropertyField(position, property, label, true); } }
public static ImageReference ImageReference(this KnownWindowsVirtualMachineImage image) { string referenceString = EnumNameAttribute.GetName(image); return(GetImageReference(referenceString, image.ToString())); }