/// <summary>
 /// Fills the meta.
 /// </summary>
 /// <param name="meta">The meta.</param>
 /// <param name="blobMeta">The BLOB meta.</param>
 public static void FillMeta(this BinaryStorageMetaData meta, Dictionary<string, string> blobMeta)
 {
     if (meta != null && blobMeta != null)
     {
         meta.Duration = blobMeta.SafeGetValue("duration").ObjectToNullableInt32();
         meta.Height = blobMeta.SafeGetValue("height").ObjectToNullableInt32();
         meta.Width = blobMeta.SafeGetValue("width").ObjectToNullableInt32();
         meta.OwnerKey = blobMeta.SafeGetValue("owner").ObjectToGuid();
     }
 }
Exemple #2
0
        public bool Contains(KeyValuePair <TKey, TValue> item)
        {
            TValue value = _forwardDictionary.SafeGetValue(item.Key);

            if (value == null)
            {
                return(false);
            }
            if (item.Value.Equals(value))
            {
                return(true);
            }
            return(false);
        }
Exemple #3
0
        protected T SafeGetMetaField<T>(string field)
        {
            var res = _properties?.SafeGetValue(field);
            if (!(res is T)) return default;

            return (T)res;
        }
 WordSet GetWord(WordId id)
 {
     if (!isInitialized)
     {
         Init();
     }
     return(wordLibrary.SafeGetValue(id));
 }
 /// <summary>
 /// Adds the specified to.
 /// </summary>
 /// <param name="to">To.</param>
 /// <param name="replacements">The replacements.</param>
 public void Add(string to, Dictionary<string, string> replacements)
 {
     this.To.Add(to);
     foreach (var one in this.Substitution)
     {
         one.Value.Add(replacements.SafeGetValue(one.Key));
     }
 }
            public static string SafeGetStringValue(
                this Dictionary <string, object> dict,
                string key)
            {
                object val = dict.SafeGetValue(key);

                return(val != null?val.ToString() : null);
            }
Exemple #7
0
 private PersonData GetData(int peerId)
 {
     if (peerId == Id)
     {
         throw new ArgumentException("Cannot have self as peer");
     }
     return(_peers.SafeGetValue(peerId) ?? (_peers[peerId] = new PersonData(peerId, _network.GetName(peerId))));
 }
Exemple #8
0
        public void Add(TKey key, TValue value)
        {
            _forwardDictionary.Add(key, value);
            HashSet <TKey> keySet = _reverseDictionary.SafeGetValue(value);

            if (keySet == null)
            {
                keySet = new HashSet <TKey>
                {
                    key
                };
                _reverseDictionary.Add(value, keySet);
            }
            else
            {
                _ = keySet.Add(key);
            }
        }
    public IPool <T> GetPool <T>(T poolableObject)
    {
        var gameObject = Convert(poolableObject);

        return(_poolsDictionary.SafeGetValue(gameObject) as IPool <T>);
    }
 public AnimationCurve GetAnimationCurve(MyAnimationCurveType type)
 {
     return(curveDic.SafeGetValue(type));
 }
Exemple #11
0
 public static T SafeGetValue <T>(this Dictionary <string, object> dictionary, string key)
 {
     return(dictionary.SafeGetValue <string, object, T>(key));
 }
Exemple #12
0
 internal ArtefactData GetArtefact(int id)
 => _artefacts.SafeGetValue(id);