public static IEnumerable <SelectListItem> ToSelectList <T>(this System.Enum enumValue)
 {
     return
         (System.Enum.GetValues(enumValue.GetType()).Cast <T>()
          .Select(
              x =>
              new SelectListItem
     {
         Text = ((System.Enum)(object) x).ToDescription(),
         Value = x.ToString(),
         Selected = (enumValue.Equals(x))
     }));
 }
Exemple #2
0
            public bool IsVisibleForEnumCondition(OCEnumPropertyToggleAttribute enumCondition)
            {
                // If there is no enumCondition, it is allowed to be visible, there is nothing to hide it.
                if (enumCondition == null)
                {
                    //Debug.Log("The '[EnumPropertyToggle]' is not attributed to this " + PublicName + " property field.");
                    return(true);
                }

                //Gets the Property or Field for the enum
                OCPropertyField enumPropertyField = null;

                GetPropertyOrField
                    (out enumPropertyField
                    , enumCondition.EnumField
                    , Instance
                    , null
                    );

                if (enumPropertyField == null)
                {
                    //If the field in boolCondition.BooleanField doesn't exist.
                    Debug.LogError("The '[EnumPropertyToggle(" + enumCondition.EnumField + ", " + enumCondition.EnumValue + ")]' failed. The field '" + enumCondition.EnumField + "' does not exisit in '" + Instance + "'.");
                    return(true);
                }

                if (enumPropertyField.UnityType != SerializedPropertyType.Enum)
                {
                    //If the wanted field is not a enum
                    Debug.LogError("The '[EnumPropertyToggle(" + enumCondition.EnumField + ", " + enumCondition.EnumValue + ")]' failed. The field '" + enumCondition.EnumField + "' is not a enum in '" + Instance + "'.");
                    return(true);
                }

                //Tests if the fields current value is equal to the value it should be to be shown
                if (Enum.Equals(enumPropertyField.GetValue(), enumCondition.EnumValue))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Exemple #3
0
        static int _m_Equals(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            System.Enum __cl_gen_to_be_invoked = (System.Enum)translator.FastGetCSObj(L, 1);


            try {
                {
                    object obj = translator.GetObject(L, 2, typeof(object));

                    bool __cl_gen_ret = __cl_gen_to_be_invoked.Equals(obj);
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }