Example #1
0
        /// <summary>
        /// Gets a resource from the cache based on a specified native
        /// pointer.
        /// </summary>
        ///
        /// <param name="nativePtr">
        /// The native pointer corresponding to the resource to retrieve.
        /// </param>
        ///
        /// <returns>
        /// A reference to a resource based on its corresponding native
        /// pointer.
        /// </returns>
        protected T GetCachedResource(IntPtr nativePtr)
        {
            if (nativePtr == IntPtr.Zero)
            {
                return(null);
            }

            ZNativeResource resource = null;

            if (!this._cache.TryGetValue(nativePtr, out resource))
            {
                return(null);
            }

            return(resource as T);
        }
Example #2
0
 /// <summary>
 /// Remove a resource from the cache.
 /// </summary>
 ///
 /// <param name="resource">
 /// A reference to the resource to be removed.
 /// </param>
 protected void RemoveFromCache(ZNativeResource resource)
 {
     this._cache.Remove(resource.NativePtr);
 }
Example #3
0
        ////////////////////////////////////////////////////////////////////////
        // Protected Methods
        ////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Adds a resource to the cache.
        /// </summary>
        ///
        /// <param name="resource">
        /// The resource to be added to the cache.
        /// </param>
        protected void AddToCache(ZNativeResource resource)
        {
            this._cache.Add(resource.NativePtr, resource);
        }