public bool TryGetFile(uint key, out File file) { WeakReference <File> fileRef; if (_Files.TryGetValue(key, out fileRef) && fileRef.TryGetTarget(out file)) { return(true); } IndexFile index; if (Index.Files.TryGetValue(key, out index)) { file = FileFactory.Get(this.Pack, index); if (_Files.ContainsKey(key)) { _Files[key].SetTarget(file); } else { _Files.Add(key, new WeakReference <File>(file)); } return(true); } file = null; return(false); }
public bool TryGetFile(uint hash, out File value) { WeakReference <File> fileRef; if (_Files.TryGetValue(hash, out fileRef) && fileRef.TryGetTarget(out value)) { return(true); } Index2File index; if (Index.Files.TryGetValue(hash, out index)) { value = FileFactory.Get(this.Pack, index); if (_Files.ContainsKey(hash)) { _Files[hash].SetTarget(value); } else { _Files.Add(hash, new WeakReference <File>(value)); } return(true); } value = null; return(false); }
public File GetFile(uint hash) { if (_Files.TryGetValue(hash, out var fileRef) && fileRef.TryGetTarget(out var file)) { return(file); } var index = Index.Files[hash]; file = FileFactory.Get(this.Pack, index); if (_Files.ContainsKey(hash)) { _Files[hash].SetTarget(file); } else { _Files.Add(hash, new WeakReference <File>(file)); } return(file); }
public File GetFile(uint key) { if (_Files.TryGetValue(key, out var fileRef) && fileRef.TryGetTarget(out var file)) { return(file); } if (!Index.Files.TryGetValue(key, out var index)) { return(null); } file = FileFactory.Get(this.Pack, index); _Files.AddOrUpdate(key, k => new WeakReference <File>(file), (k, r) => { r.SetTarget(file); return(r); }); return(file); }
public File GetFile(uint key) { if (_Files.TryGetValue(key, out var fileRef) && fileRef.TryGetTarget(out var file)) { return(file); } if (!Index.Files.TryGetValue(key, out var index)) { return(null); } file = FileFactory.Get(this.Pack, index); if (_Files.ContainsKey(key)) { _Files[key].SetTarget(file); } else { _Files.Add(key, new WeakReference <File>(file)); } return(file); }
public bool TryGetFile(uint key, out File file) { if (_Files.TryGetValue(key, out var fileRef) && fileRef.TryGetTarget(out file)) { return(true); } if (Index.Files.TryGetValue(key, out var index)) { var theFile = FileFactory.Get(this.Pack, index); _Files.AddOrUpdate(key, k => new WeakReference <File>(theFile), (k, r) => { r.SetTarget(theFile); return(r); }); file = theFile; return(true); } file = null; return(false); }