コード例 #1
0
 public BotVar(string id, IGenericBotVar var)
 {
     Identifier = id;
     Type       = BotVarType.Generic;
     Generic    = var.ToJSON();
     UInt64     = default;
     Int64      = default;
     Float64    = default;
     String     = default;
     Bool       = default;
 }
コード例 #2
0
 public BotVar(string id, JSONContainer var)
 {
     Identifier = id;
     Type       = BotVarType.Generic;
     Generic    = var;
     UInt64     = default;
     Int64      = default;
     Float64    = default;
     String     = default;
     Bool       = default;
 }
コード例 #3
0
 public BotVar(string id, bool var)
 {
     Identifier = id;
     Type       = BotVarType.Bool;
     Bool       = var;
     UInt64     = default;
     Int64      = default;
     Float64    = default;
     String     = default;
     Generic    = default;
 }
コード例 #4
0
 public BotVar(string id, string var)
 {
     Identifier = id;
     Type       = BotVarType.String;
     String     = var;
     UInt64     = default;
     Int64      = default;
     Float64    = default;
     Bool       = default;
     Generic    = default;
 }
コード例 #5
0
 public BotVar(string id, double var)
 {
     Identifier = id;
     Type       = BotVarType.Float64;
     Float64    = var;
     UInt64     = default;
     Int64      = default;
     String     = default;
     Bool       = default;
     Generic    = default;
 }
コード例 #6
0
        internal bool FromJSON(JSONContainer json)
        {
            if (json.TryGetField(JSON_ID, out Identifier) && json.TryGetField(JSON_TYPE, out int type))
            {
                Type = (BotVarType)type;
                switch (Type)
                {
                case BotVarType.Undefined:
                    return(true);

                case BotVarType.UInt64:
                    return(json.TryGetField(JSON_VALUE, out UInt64));

                case BotVarType.Int64:
                    return(json.TryGetField(JSON_VALUE, out Int64));

                case BotVarType.Float64:
                    return(json.TryGetField(JSON_VALUE, out Float64));

                case BotVarType.String:
                    return(json.TryGetField(JSON_VALUE, out String));

                case BotVarType.Bool:
                    return(json.TryGetField(JSON_VALUE, out Bool));

                case BotVarType.Generic:
                    return(json.TryGetField(JSON_VALUE, out Generic));

                default:
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }