/// <summary> /// Retrieves the resource with the specified resource ID /// </summary> /// <param name="resourceId">The resource ID to look for</param> /// <param name="addToCache">Boolean flag indicating if the returned resource structure should be cached for faster future lookups</param> /// <param name="profiler">OPTIONAL: Profiler to use to profile this call</param> /// <returns>The corresponding resource or null if no match is found</returns> public IResource GetResource(ulong resourceId, bool addToCache, BrightstarProfiler profiler = null) { using (profiler.Step("ResourceIndex.GetResource")) { IResource resource; if (_resourceCache.TryGetValue(resourceId, out resource)) { return(resource); } var buff = new byte[64]; if (Search(resourceId, buff, profiler)) { resource = _resourceStore.FromBTreeValue(buff); _resourceCache.Add(resourceId, resource); return(resource); } #if DEBUG if (resourceId > 0) { // Repeat the search for debug purposes Search(resourceId, buff, profiler); } #endif return(null); } }
/// <summary> /// Retrieves the resource with the specified resource ID /// </summary> /// <param name="resourceId">The resource ID to look for</param> /// <param name="addToCache">Boolean flag indicating if the returned resource structure should be cached for faster future lookups</param> /// <param name="profiler">OPTIONAL: Profiler to use to profile this call</param> /// <returns>The corresponding resource or null if no match is found</returns> public IResource GetResource(ulong resourceId, bool addToCache, BrightstarProfiler profiler = null) { using (profiler.Step("ResourceIndex.GetResource")) { IResource resource; if (_resourceCache.TryGetValue(resourceId, out resource)) { return(resource); } var buff = new byte[64]; if (Search(resourceId, buff, profiler)) { resource = _resourceStore.FromBTreeValue(buff); _resourceCache.Add(resourceId, resource); return(resource); } return(null); } }