This class represent a general text resource that may have been retrieved from any number of possible sources. Also of interest is Velocity's {@link org.apache.velocity.Template} Resource.
Inheritance: Resource
		public Resource GetResource(string resourceName, ResourceType resourceType, string encoding)
		{
			Resource resource = (Resource) cacheProvider.Get(resourceName);

			if (resource == null)
			{
				if (resourceType == ResourceType.Content)
				{
					resource = new ContentResource();
				}
				else
				{
					resource = new CustomTemplate();
				}

				InitializeResource(resource, resourceName, encoding);

				resource.ResourceLoader = resourceLoaderAdapter;

				ProcessResourceWithSensibleExceptionWrapping(resourceName, resource);

				if (resource.Data == null)
				{
					throw new ResourceNotFoundException("Unable to find resource '" + resourceName + "'");
				}

				resource.LastModified = DateTime.Now.Ticks;
				resource.ModificationCheckInterval = resourceLoaderAdapter.ModificationCheckInterval;
				resource.Touch();

				if (!resource.IsSourceModified())
				{
					cacheProvider.Store(resourceName, resource);
				}
			}
			else
			{
				if (resource.IsSourceModified())
				{
					ProcessResourceWithSensibleExceptionWrapping(resourceName, resource);
				}
			}

			return resource;
		}
	public static Resource getResource(System.String resourceName, int resourceType) {
	    Resource resource = null;

	    switch (resourceType) {
		case NVelocity.Runtime.Resource.ResourceManager_Fields.RESOURCE_TEMPLATE:
		    resource = new Template();
		    break;



		case NVelocity.Runtime.Resource.ResourceManager_Fields.RESOURCE_CONTENT:
		    resource = new ContentResource();
		    break;

	    }

	    return resource;
	}
示例#3
0
		public static Resource GetResource(String resourceName, ResourceType resourceType)
		{
			Resource resource = null;

			switch(resourceType)
			{
				case ResourceType.Template:
					resource = new Template();
					break;

				case ResourceType.Content:
					resource = new ContentResource();
					break;
			}

			return resource;
		}