Exemplo n.º 1
0
    public static TEnum ReadEnum <TEnum>(Dictionary <string, object> inDict, string inVariableName, out bool inSuccess, TEnum inDefaultValue)
    // With Unity 4.3.4 and VS Express 2012 WP8 having the contraint causes an exception
#if !UNITY_WP8
        where TEnum : struct, System.IComparable, System.IFormattable, System.IConvertible
#endif
    {
        TEnum returnVal = inDefaultValue;

        if (typeof(TEnum).IsEnum == false)
        {
            throw new System.ArgumentException("TEnum must be an enumerated type");
        }

        if (inDict.ContainsKey(inVariableName) == true)
        {
            returnVal = JSONTools.ReadEnum(inDict[inVariableName], inDefaultValue);
            inSuccess = true;
        }
        else
        {
            inSuccess = false;
        }

        return(returnVal);
    }