public static void Main(string[] args) { #region Snippet // Create asset var source = new Dictionary <string, string> { { "Culture:en:Key:hello", "Hello World!" } }; IAsset asset = new StringAsset(source, LineFormat.Parameters); // Create cache IAssetCache asset_cached = new AssetCache(asset); // Adds feature to cache IResourceAsset specific requests asset_cached.Add(new AssetCachePartResources(asset_cached.Source, asset_cached.Options)); // Adds feature to cache IStringAsset specific requests asset_cached.Add(new AssetCachePartStrings(asset_cached.Source, asset_cached.Options)); // Adds feature to cache IAssetCultureEnumerable specific requests asset_cached.Add(new AssetCachePartCultures(asset_cached.Source, asset_cached.Options)); // Assign the cached asset LineRoot.Global.Asset = asset_cached; #endregion Snippet }
public void TestAssetCache( ) { AssetCache cache = new AssetCache( ); int key = new Location( m_LocationManagers, "blarg" ).Key; // Add an asset to the cache object asset = new object( ); cache.Add( key, asset ); // Make sure that it can be retrived from its key Assert.AreEqual( asset, cache.Find( key ) ); // Collect garbage (will clean up asset) asset = null; GC.Collect( ); // Make sure that the asset is no longer in the cache Assert.AreEqual( cache.Find( key ), asset ); }