Пример #1
0
 /// <summary>
 /// Creates an int attribute with given key and value<br/>
 /// Side note: If you need this attribute to be compatible with deserialized json - use SetLong()
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public virtual void SetInt(string key, int value)
 {
     lock (attributesLock)
     {
         attributes[key] = new IntAttribute(value);
     }
 }
Пример #2
0
        /// <summary>
        /// Retrieves an int or default value if key is not found
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public virtual int GetInt(string key, int defaultValue = 0)
        {
            IntAttribute attr = attributes.TryGetValue(key) as IntAttribute;

            return(attr == null ? defaultValue : attr.value);
        }