private static EnumInfo InitializeValuesAndNames(StructMultiKey <Type, NamingStrategy> key) { Type enumType = key.Value1; string[] names = Enum.GetNames(enumType); string[] resolvedNames = new string[names.Length]; ulong[] values = new ulong[names.Length]; for (int i = 0; i < names.Length; i++) { string name = names[i]; FieldInfo f = enumType.GetField(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); values[i] = ToUInt64(f.GetValue(null)); string resolvedName = f.GetCustomAttributes(typeof(EnumMemberAttribute), true) .Cast <EnumMemberAttribute>() .Select(a => a.Value) .SingleOrDefault() ?? f.Name; if (Array.IndexOf(resolvedNames, resolvedName, 0, i) != -1) { throw new InvalidOperationException("Enum name '{0}' already exists on enum '{1}'.".FormatWith(CultureInfo.InvariantCulture, resolvedName, enumType.Name)); } resolvedNames[i] = key.Value2 != null ? key.Value2.GetPropertyName(resolvedName, false) : resolvedName; } bool isFlags = enumType.IsDefined(typeof(FlagsAttribute), false); return(new EnumInfo(isFlags, values, names, resolvedNames)); }
public bool Equals(StructMultiKey <T1, T2> other) { return(Equals(Value1, other.Value1) && Equals(Value2, other.Value2)); }