You've already forked linux-packaging-mono
acceptance-tests
data
docs
external
Newtonsoft.Json
api-doc-tools
external
mdoc
monodoc
Assembly
Mono.Documentation
Mono.Utilities
Monodoc
caches
generators
providers
storage
HelpSource.cs
HelpSource_Legacy.cs
Node.cs
Node_Legacy.cs
Provider.cs
RootTree.cs
RootTree_Legacy.cs
SearchableDocument.cs
SearchableIndex.cs
Tree.cs
TypeUtils.cs
cache.cs
generator.cs
index.cs
settings.cs
settings_Legacy.cs
storage.cs
Monodoc.Ecma
Properties
Resources
Test
Makefile
jay.sh
monodoc.csproj
monodoc.dll.config
.gitignore
.gitmodules
Makefile
README.md
apidoctools.sln
api-snapshot
aspnetwebstack
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
ikdasm
ikvm
linker
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
ikvm-native
libgc
llvm
m4
man
mcs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using System.Configuration;
|
|
using System.Collections.Specialized;
|
|
using Monodoc.Caches;
|
|
|
|
namespace Monodoc
|
|
{
|
|
public enum DocEntity
|
|
{
|
|
Text,
|
|
Blob
|
|
}
|
|
|
|
public interface IDocCache : IDisposable
|
|
{
|
|
bool IsCached (string id);
|
|
bool CanCache (DocEntity entity);
|
|
|
|
Stream GetCachedStream (string id);
|
|
string GetCachedString (string id);
|
|
|
|
void CacheText (string id, string content);
|
|
void CacheText (string id, Stream stream);
|
|
|
|
void CacheBlob (string id, byte[] data);
|
|
void CacheBlob (string id, Stream stream);
|
|
}
|
|
|
|
public static class DocCacheHelper
|
|
{
|
|
static string cacheBaseDirectory;
|
|
|
|
static DocCacheHelper ()
|
|
{
|
|
try {
|
|
var cacheConfig = Config.Get ("cache");
|
|
if (cacheConfig == null) return;
|
|
var cacheValues = cacheConfig.Split (',');
|
|
if (cacheValues.Length == 2 && cacheValues[0].Equals ("file", StringComparison.Ordinal))
|
|
cacheBaseDirectory = cacheValues[1].Replace ("~", Environment.GetFolderPath (Environment.SpecialFolder.Personal));
|
|
} catch {}
|
|
}
|
|
|
|
// Use configuration option to query for cache directory, if it doesn't exist we instantiate a nullcache
|
|
public static IDocCache GetDefaultCache (string name)
|
|
{
|
|
if (cacheBaseDirectory == null)
|
|
return new NullCache ();
|
|
|
|
return new FileCache (Path.Combine (cacheBaseDirectory, name));
|
|
}
|
|
}
|
|
}
|