public PooledResourceReference allocate(string key) { PooledResourceEntry res; if (!resources.TryGetValue(key, out res)) { object r = loader.loadResource(key); res = new PooledResourceEntry(key, r, this); resources.Add(key, res); } return loader.wrapReference(res); }
public PooledResourceReference allocate(string key) { PooledResourceEntry res; if (!resources.TryGetValue(key, out res)) { object r = loader.loadResource(key); res = new PooledResourceEntry(key, r, this); resources.Add(key, res); } return(loader.wrapReference(res)); }
public void removeUnused() { LinkedList <string> keys = new LinkedList <string>(resources.Keys); foreach (string s in keys) { PooledResourceEntry r = resources[s]; if (r.references == 0) { IDisposable d = (IDisposable)r.resource; d.Dispose(); resources.Remove(s); } } }
public PooledResourceReference(PooledResourceEntry reference) { this.reference = reference; System.Threading.Interlocked.Increment(ref reference.references); }
public PooledResourceReference wrapReference(PooledResourceEntry res) { return new ImageRef(res); }
public ImageRef(PooledResourceEntry r) : base(r) { }
public PooledResourceReference wrapReference(PooledResourceEntry res) { return(new ImageRef(res)); }