public static VariableType GetVariableType(this SocketUserVars v)
 {
     if (!typeMap.ContainsKey(v))
     {
         Log.LogError(v, string.Concat("Socket user var `", v, "` has no type"));
         throw new Exception(string.Concat("Socket user var `", v, "` has no type"));
     }
     return(typeMap[v]);
 }
 public static string GetKey(this SocketUserVars v)
 {
     if (!keyMap.ContainsKey(v))
     {
         Log.LogError(v, string.Concat("Socket user var `", v, "` has no key"));
         throw new Exception(string.Concat("Socket user var `", v, "` has no key"));
     }
     return(keyMap[v]);
 }
Example #3
0
    private void addIfChanged(List <UserVariable> userVariables, SocketUserVars key, object newValue)
    {
        Type   typeFromSFSVariableType = SmartFoxUtil.GetTypeFromSFSVariableType(key.GetVariableType());
        object obj = (newValue == null) ? null : Convert.ChangeType(newValue, typeFromSFSVariableType);

        if (mt.isLoggedIn)
        {
            UserVariable var  = null;
            bool         flag = mt.TryGetUserVariable(key.GetKey(), out var);
            if ((!flag && obj != null) || (flag && obj != SmartFoxUtil.GetValueFromSFSUserValue(var, typeFromSFSVariableType)))
            {
                userVariables.Add(new SFSUserVariable(key.GetKey(), obj));
            }
        }
    }
 private static MemberInfo ForValue(SocketUserVars v)
 {
     return(typeof(SocketUserVars).GetField(Enum.GetName(typeof(SocketUserVars), v)));
 }
 private static SocketUserVarAttribute GetAttr(SocketUserVars v)
 {
     return((SocketUserVarAttribute)Attribute.GetCustomAttribute(ForValue(v), typeof(SocketUserVarAttribute)));
 }