Exemplo n.º 1
0
        public void Setup()
        {
            var members = FastEnum.GetMembers <Fruits>();

            this.Standard          = members.ToDictionary(x => (int)x.Value);
            this.GenericsKeyFrozen = members.ToFrozenDictionary(x => (int)x.Value);
            this.IntKeyFrozen      = members.ToFrozenIntKeyDictionary(x => (int)x.Value);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates instance.
 /// </summary>
 /// <param name="name"></param>
 internal Member(string name)
 {
     this.Value
         = Enum.TryParse <T>(name, out var value)
         ? value
         : throw new ArgumentException(nameof(name));
     this.Name                = name;
     this.FieldInfo           = typeof(T).GetField(name);
     this.EnumMemberAttribute = this.FieldInfo.GetCustomAttribute <EnumMemberAttribute>();
     this.Labels
         = this.FieldInfo
           .GetCustomAttributes <LabelAttribute>()
           .ToFrozenIntKeyDictionary(x => x.Index, x => string.Intern(x.Value));
 }