あなたはこれをやって、あなたの出力キャッシュプロファイルのリストを取得することができます。
private Dictionary<string, OutputCacheProfile> _outputCacheProfiles;
/// <summary>
/// Initializes <see cref="OutputCacheProfiles"/> using the settings found in
/// "system.web\caching\outputCacheSettings"
/// </summary>
void InitializeOutputCacheProfiles(
System.Configuration.Configuration appConfig,
NameValueCollection providerConfig)
{
_outputCacheProfiles = new Dictionary<string, OutputCacheProfile>();
OutputCacheSettingsSection outputCacheSettings =
(OutputCacheSettingsSection)appConfig.GetSection("system.web/caching/outputCacheSettings");
if(outputCacheSettings != null)
{
foreach(OutputCacheProfile profile in outputCacheSettings.OutputCacheProfiles)
{
_outputCacheProfiles[profile.Name] = profile;
}
}
}
そして、あなたの挿入時にそれを使用する:
/// <summary>
/// Gets the output cache profile with the specified name
/// </summary>
public OutputCacheProfile GetOutputCacheProfile(string name)
{
if(!_outputCacheProfiles.ContainsKey(name))
{
throw new ArgumentException(String.Format("The output cache profile '{0}' is not registered", name));
}
return _outputCacheProfiles[name];
}
/// <summary>
/// Inserts the key/value pair using the specifications of the output cache profile
/// </summary>
public void InsertItemUsing(string outputCacheProfileName, string key, object value)
{
OutputCacheProfile profile = GetOutputCacheProfile(outputCacheProfileName);
//Get settings from profile to use on your insert instead of hard coding them
}