Ejemplo n.º 1
0
 public bool Has(ConfigTag key)
 {
     for (var i = 0; i < rows.Length; i++)
     {
         if (rows[i].key == key)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
    public void AddConfig()
    {
        foreach (string child in Body_ConfigTag)
        {
            ConfigTag config = new ConfigTag();
            config.Addself(child, ConfigBody);
        }

        foreach (TaskMessage child in AllTaskData)
        {
            TaskMessageBody.Add(child.id, child);
        }
    }
Ejemplo n.º 3
0
    public void Save <T>(ConfigTag key, T value)
    {
        // see if key already exists
        int  index = 0;
        bool found = false;

        for (; index < rows.Length; index++)
        {
            if (rows[index].key == key)
            {
                found = true;
            }
        }

        // resize to add room if not found
        if (!found)
        {
            Array.Resize(ref rows, rows.Length + 1);
            index       = rows.Length - 1;
            rows[index] = new PartConfigRow(key);
        }

        // set value based on type
        if (typeof(T) == typeof(bool))
        {
            rows[index].valueType = 0;
            rows[index].boolValue = (bool)(object)value;
        }
        else if (typeof(T) == typeof(string))
        {
            rows[index].valueType   = 1;
            rows[index].stringValue = (string)(object)value;
        }
        else if (typeof(T) == typeof(float))
        {
            rows[index].valueType  = 2;
            rows[index].floatValue = (float)(object)value;
        }
    }
Ejemplo n.º 4
0
 public T Get <T>(ConfigTag key)
 {
     for (var i = 0; i < rows.Length; i++)
     {
         if (rows[i].key == key)
         {
             if (typeof(T) == typeof(bool))
             {
                 return((T)(object)(rows[i].boolValue));
             }
             else if (typeof(T) == typeof(string))
             {
                 return((T)(object)(rows[i].stringValue));
             }
             else if (typeof(T) == typeof(float))
             {
                 return((T)(object)(rows[i].floatValue));
             }
         }
     }
     return(default(T));
 }
Ejemplo n.º 5
0
 public PartConfigRow(ConfigTag key)
 {
     this.key = key;
 }