public Enum displayEnum(string displayName, Enum value, out bool modified) { Enum retValue = EditorGUILayout.EnumPopup(displayName, value); modified = retValue.CompareTo(value) != 0; return(retValue); }
public static bool DrawEnum(ref Enum value, GUIContent content) { var nextValue = EditorGUILayout.EnumPopup(content, value); var changed = value.CompareTo(nextValue) != 0; value = nextValue; return(changed); }
/// <summary> /// Compares two <typeparamref name="TEnum"/> instances. /// </summary> /// <param name="other">The instance to compare against.</param> /// <returns>The result of the comparison.</returns> public int CompareTo(TEnum other) { if (!IsEnum) { return(-1); } return(Enum.CompareTo(other)); }
static int CompareTo(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); Enum obj = LuaScriptMgr.GetNetObject <Enum>(L, 1); object arg0 = LuaScriptMgr.GetVarObject(L, 2); int o = obj.CompareTo(arg0); LuaScriptMgr.Push(L, o); return(1); }
private static int CompareTo(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); Enum @enum = (Enum)LuaScriptMgr.GetNetObjectSelf(L, 1, "Enum"); object varObject = LuaScriptMgr.GetVarObject(L, 2); int d = @enum.CompareTo(varObject); LuaScriptMgr.Push(L, d); return(1); }
/// <summary>Count number of lex.</summary> /// <returns>Count lex.</returns> public static int CountLex() { Count = 0; Text.NextCh(); NextLex(Text.Ch()); while (_lex.CompareTo(Lex.EOT) != 0) { Count++; NextLex(Text.Ch()); } return(Count); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Enum gender = (Enum)value; if (gender.CompareTo(GenderEnum.Kobieta) == 0) { return(HighlightBrush); } else { return(DefaultBrush); } }
public void CompareTo_StringAndLanguageAttributeFileAccessEnum_RelationOfUnderlyingEnumValues( [Values(StringAndLanguageAttributeFileAccess.Delete, StringAndLanguageAttributeFileAccess.Read, StringAndLanguageAttributeFileAccess.ReadWrite, StringAndLanguageAttributeFileAccess.Write)] Enum value, [Values(StringAndLanguageAttributeFileAccess.Delete, StringAndLanguageAttributeFileAccess.Read, StringAndLanguageAttributeFileAccess.ReadWrite, StringAndLanguageAttributeFileAccess.Write)] Enum valueToCompare, [Values(EnumStringRepresentationUsage.ToStringMethod, EnumStringRepresentationUsage.StringAttribute, EnumStringRepresentationUsage.LanguageStringAttribute)] EnumStringRepresentationUsage enumStringRepresentationUsage, [Values(EnumStringRepresentationUsage.ToStringMethod, EnumStringRepresentationUsage.StringAttribute, EnumStringRepresentationUsage.LanguageStringAttribute)] EnumStringRepresentationUsage enumStringRepresentationUsageOfValueToCompare) { var enumString = EnumString.Create <StringAndLanguageAttributeFileAccess>((StringAndLanguageAttributeFileAccess)value, enumStringRepresentationUsage); var other = EnumString.Create <StringAndLanguageAttributeFileAccess>((StringAndLanguageAttributeFileAccess)valueToCompare, enumStringRepresentationUsageOfValueToCompare); Assert.AreEqual(value.CompareTo(valueToCompare), enumString.CompareTo(other)); }
private static int CompareTo(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 2); Enum @enum = (Enum)ToLua.CheckObject(L, 1, typeof(Enum)); object obj = ToLua.ToVarObject(L, 2); int n = @enum.CompareTo(obj); LuaDLL.lua_pushinteger(L, n); result = 1; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
/// <summary> /// 返回枚举项的描述信息。 /// </summary> /// <param name="value">要获取描述信息的枚举项。</param> /// <returns>枚举想的描述信息。</returns> public static string GetDescription(this Enum value) { Type enumType = value.GetType(); DescriptionAttribute attr = null; string[] strName = Enum.GetNames(enumType); Array strValue = Enum.GetValues(enumType); FieldInfo[] fil = enumType.GetFields(); foreach (EnumUnit item in Enum.GetValues(typeof(EnumUnit))) { bool f = Enum.Equals(value, item); if (value.CompareTo(item) == 0) { // 获取枚举常数名称。 string name = Enum.GetName(enumType, item); if (name != null) { // 获取枚举字段。 FieldInfo fieldInfo = enumType.GetField(name); if (fieldInfo != null) { // 获取描述的属性。 attr = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute), false) as DescriptionAttribute; } } break; } else { continue; } } if (attr != null && !string.IsNullOrEmpty(attr.Description)) { return(attr.Description); } else { return(string.Empty); } }
public static void CompareTo(Enum e, object target, int expected) { Assert.Equal(expected, Math.Sign(e.CompareTo(target))); }
public int getAction(int roomID, Enum target) { int result = -1; var id = (Function.MEMBER)roomID; // 25가지 조건 switch (id) { case Function.MEMBER.N: if (target.CompareTo(TARGET.VERY_COLD) == 0) { result = (int)ACTION.NOCHANGE; } if (target.CompareTo(TARGET.COLD) == 0) { result = (int)ACTION.HEAT; } if (target.CompareTo(TARGET.WARM) == 0) { result = (int)ACTION.HEAT; } if (target.CompareTo(TARGET.HOT) == 0) { result = (int)ACTION.HEAT; } if (target.CompareTo(TARGET.VERY_HOT) == 0) { result = (int)ACTION.HEAT; } break; case Function.MEMBER.MN: if (target.CompareTo(TARGET.VERY_COLD) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.COLD) == 0) { result = (int)ACTION.NOCHANGE; } if (target.CompareTo(TARGET.WARM) == 0) { result = (int)ACTION.HEAT; } if (target.CompareTo(TARGET.HOT) == 0) { result = (int)ACTION.HEAT; } if (target.CompareTo(TARGET.VERY_HOT) == 0) { result = (int)ACTION.HEAT; } break; case Function.MEMBER.S: if (target.CompareTo(TARGET.VERY_COLD) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.COLD) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.WARM) == 0) { result = (int)ACTION.NOCHANGE; } if (target.CompareTo(TARGET.HOT) == 0) { result = (int)ACTION.HEAT; } if (target.CompareTo(TARGET.VERY_HOT) == 0) { result = (int)ACTION.HEAT; } break; case Function.MEMBER.MP: if (target.CompareTo(TARGET.VERY_COLD) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.COLD) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.WARM) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.HOT) == 0) { result = (int)ACTION.NOCHANGE; } if (target.CompareTo(TARGET.VERY_HOT) == 0) { result = (int)ACTION.HEAT; } break; case Function.MEMBER.LP: if (target.CompareTo(TARGET.VERY_COLD) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.COLD) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.WARM) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.HOT) == 0) { result = (int)ACTION.COOL; } if (target.CompareTo(TARGET.VERY_HOT) == 0) { result = (int)ACTION.NOCHANGE; } break; } return(result); }