using FishNet.Documenting;
using System.Collections.Generic;
namespace FishNet.Utility.Extension
{
    [APIExclude]
    public static class DictionaryFN
    {
        /// 
        /// Uses a hacky way to TryGetValue on a dictionary when using IL2CPP and on mobile.
        /// This is to support older devices that don't properly handle IL2CPP builds.
        /// 
        public static bool TryGetValueIL2CPP(this IDictionary dict, TKey key, out TValue value)
        {
#if ENABLE_IL2CPP && UNITY_IOS || UNITY_ANDROID
            if (dict.ContainsKey(key))
            {
                value = dict[key];
                return true;
            }
            else
            {
                value = default;
                return false;
            }
#else
            return dict.TryGetValue(key, out value);
#endif
        }
    }
}