HaloOnlineLib.Resources.ResourceReference.GetLocation C# (CSharp) Method

GetLocation() public method

Gets the location of the resource by checking its location flags.
The resource does not have a location flag set
public GetLocation ( ) : ResourceLocation
return ResourceLocation
        public ResourceLocation GetLocation()
        {
            if ((LocationFlags & ResourceLocationFlags.InResources) != 0)
                return ResourceLocation.Resources;
            if ((LocationFlags & ResourceLocationFlags.InTextures) != 0)
                return ResourceLocation.Textures;
            if ((LocationFlags & ResourceLocationFlags.InTexturesB) != 0)
                return ResourceLocation.TexturesB;
            if ((LocationFlags & ResourceLocationFlags.InAudio) != 0)
                return ResourceLocation.Audio;
            if ((LocationFlags & ResourceLocationFlags.InVideo) != 0)
                return ResourceLocation.Video;
            throw new InvalidOperationException("The resource does not have a location flag set");
        }

Usage Example

 private LoadedCache GetCache(ResourceReference resource)
 {
     LoadedCache cache;
     if (!_loadedCaches.TryGetValue(resource.GetLocation(), out cache))
         throw new InvalidOperationException("The requested resource is located in " + resource.GetLocation() + ", but the corresponding cache file has not been loaded.");
     return cache;
 }
ResourceReference