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 Resource GetResource(string resourceName, ResourceType resourceType, string encoding) { var 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); }