NVelocity.Runtime.Resource.ResourceManagerImpl.GetLoaderNameForResource C# (CSharp) Method

GetLoaderNameForResource() public method

Determines is a template exists, and returns name of the loader that provides it. This is a slightly less hokey way to support the Velocity.templateExists() utility method, which was broken when per-template encoding was introduced. We can revisit this.
public GetLoaderNameForResource ( String resourceName ) : String
resourceName String Name of template or content resource ///
return String
        public String GetLoaderNameForResource(String resourceName)
        {
            ResourceLoader resourceLoader;

            /*
            *  loop through our loaders...
            */
            for(int i = 0; i < resourceLoaders.Count; i++)
            {
                resourceLoader = (ResourceLoader) resourceLoaders[i];

                Stream input = null;

                // if we find one that can provide the resource,
                // return the name of the loaders's Class
                try
                {
                    input = resourceLoader.GetResourceStream(resourceName);

                    if (input != null)
                    {
                        return resourceLoader.GetType().ToString();
                    }
                }
                catch(ResourceNotFoundException)
                {
                    // this isn't a problem.  keep going
                }
                finally
                {
                    // if we did find one, clean up because we were
                    // returned an open stream
                    if (input != null)
                    {
                        try
                        {
                            input.Close();
                        }
                        catch(IOException)
                        {
                        }
                    }
                }
            }

            return null;
        }