コード例 #1
0
 /// <summary>
 /// Retrieves an unpacked asset instance.
 /// </summary>
 /// <typeparam name="TValue">Asset type.</typeparam>
 /// <param name="consumer">Consumer reference for the access request.</param>
 /// <param name="key">Key used for retrieval.</param>
 /// <returns>An unpacked asset.</returns>
 public static TValue Get <TValue>(IAssetConsumer consumer, dynamic key)
 {
     if (LookupDictionary.ContainsKey(typeof(Asset <TValue>)))
     {
         return(LookupDictionary[typeof(Asset <TValue>)].Get(consumer, key));
     }
     throw new KeyNotFoundException("No asset for the specified key was found.");
 }
コード例 #2
0
 public static Dictionary <string, TValue> GetDictionary <TValue>(IAssetConsumer consumer)
 {
     if (LookupDictionary.ContainsKey(typeof(Asset <TValue>)))
     {
         return(LookupDictionary[(dynamic)typeof(Asset <TValue>)].GetData(consumer));
     }
     return(null);
 }
コード例 #3
0
 public bool TryGet(IAssetConsumer consumer, string key, out TValue value)
 {
     value = default;
     if (data.TryGetValue(key, out Asset <TValue> asset))
     {
         value = asset.Get(consumer);
         return(true);
     }
     return(false);
 }
コード例 #4
0
        public Dictionary <string, TValue> GetData(IAssetConsumer consumer)
        {
            Dictionary <string, TValue> dict = new Dictionary <string, TValue>();

            foreach ((string key, Asset <TValue> value) in data)
            {
                dict.Add(key, value.Get(consumer));
            }
            return(dict);
        }
コード例 #5
0
 /// <summary>
 /// Attempts to return an unpacked asset instance.
 /// </summary>
 /// <typeparam name="TKey">Key type.</typeparam>
 /// <typeparam name="TValue">Asset type.</typeparam>
 /// <param name="consumer">Consumer reference for the access request.</param>
 /// <param name="key">Key used for retrieval.</param>
 /// <param name="value">Array resource returned.</param>
 /// <returns>True if successful.</returns>
 public static bool TryGet <TValue>(IAssetConsumer consumer, string key, out dynamic value)
 => LookupDictionary[typeof(Asset <TValue>)].TryGet(consumer, key, out value);
コード例 #6
0
 public TValue Get(IAssetConsumer consumer, string key)
 => data.TryGetValue(key, out Asset <TValue> asset) ? asset.Get(consumer) : default;