private IAsset GetCreateAsset(AssetType type, string key, CreateAssetDlgt createAsset, CreateAssetCoreDlgt createAssetCore) { AssetInstance assetInstance; IAsset result = null; IDictionary <string, AssetInstance> assetTypeDict = _assets[(int)type]; lock (assetTypeDict) { if (assetTypeDict.TryGetValue(key, out assetInstance)) { result = assetInstance.asset.Target as IAsset; } else { assetInstance = NewAssetInstance(key, type, createAssetCore()); } // If the asset instance was just created, create asset wrapper. If the asset wrapper has been garbage collected, re-allocate it. if (result == null) { result = createAsset(assetInstance.core); assetInstance.asset = new WeakReference(result); } } return(result); }
private IAsset GetCreateAsset(AssetType type, string key, CreateAssetDlgt createAsset, CreateAssetCoreDlgt createAssetCore) { AssetInstance assetInstance; IAsset result = null; IDictionary<string, AssetInstance> assetTypeDict = _assets[(int) type]; lock (assetTypeDict) { if (assetTypeDict.TryGetValue(key, out assetInstance)) result = assetInstance.asset.Target as IAsset; else assetInstance = NewAssetInstance(key, type, createAssetCore()); // If the asset instance was just created, create asset wrapper. If the asset wrapper has been garbage collected, re-allocate it. if (result == null) { result = createAsset(assetInstance.core); assetInstance.asset = new WeakReference(result); } } return result; }