DirectoryResource: Another fix for GetResource()
parent
97a39f4acc
commit
d07b28da48
|
@ -92,44 +92,43 @@ namespace ln.http.resources
|
|||
|
||||
public override Resource GetResource(string name)
|
||||
{
|
||||
if (!Contains(name))
|
||||
return null;
|
||||
|
||||
if (injectedResources.ContainsKey(name))
|
||||
return injectedResources[name];
|
||||
|
||||
lock (cache)
|
||||
{
|
||||
if (!Contains(name))
|
||||
return null;
|
||||
|
||||
if (injectedResources.ContainsKey(name))
|
||||
return injectedResources[name];
|
||||
|
||||
if (cache.ContainsKey(name))
|
||||
return cache[name];
|
||||
}
|
||||
|
||||
String cPath = PathHelper.FindPath(searchPaths.Select((p) => System.IO.Path.Combine(p,name)));
|
||||
if (cPath == null)
|
||||
return null;
|
||||
String cPath = PathHelper.FindPath(searchPaths.Select((p) => System.IO.Path.Combine(p, name)));
|
||||
if (cPath == null)
|
||||
return null;
|
||||
|
||||
if (Directory.Exists(cPath))
|
||||
{
|
||||
DirectoryResource child = new DirectoryResource(this, searchPaths.Select((p)=> System.IO.Path.Combine(p,name)));
|
||||
child.ResourceTypeHook = ResourceTypeHook;
|
||||
return child;
|
||||
}
|
||||
else if (File.Exists(cPath))
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(cPath);
|
||||
|
||||
Resource resource = null;
|
||||
if (ResourceTypeHook != null)
|
||||
if (Directory.Exists(cPath))
|
||||
{
|
||||
resource = ResourceTypeHook(this, fileInfo);
|
||||
DirectoryResource child = new DirectoryResource(this, searchPaths.Select((p) => System.IO.Path.Combine(p, name)));
|
||||
child.ResourceTypeHook = ResourceTypeHook;
|
||||
return child;
|
||||
}
|
||||
if (resource == null)
|
||||
else if (File.Exists(cPath))
|
||||
{
|
||||
resource = new FileResource(this, fileInfo);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
FileInfo fileInfo = new FileInfo(cPath);
|
||||
|
||||
Resource resource = null;
|
||||
if (ResourceTypeHook != null)
|
||||
{
|
||||
resource = ResourceTypeHook(this, fileInfo);
|
||||
}
|
||||
if (resource == null)
|
||||
{
|
||||
resource = new FileResource(this, fileInfo);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
return GetFallBackResource();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue