This commit is contained in:
Jelle Luteijn 2022-05-15 11:19:49 +02:00
parent 16e76d6b31
commit 484dbfc9d9
529 changed files with 113694 additions and 0 deletions

View file

@ -0,0 +1,49 @@
using System;
using System.IO;
using System.Security.Permissions;
namespace AspClassic.Scripting;
[Serializable]
internal sealed class FileStreamContentProvider : StreamContentProvider
{
[Serializable]
private class PALHolder : MarshalByRefObject
{
[NonSerialized]
private readonly PlatformAdaptationLayer _pal;
internal PALHolder(PlatformAdaptationLayer pal)
{
_pal = pal;
}
internal Stream GetStream(string path)
{
return _pal.OpenInputFileStream(path);
}
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
public override object InitializeLifetimeService()
{
return null;
}
}
private readonly string _path;
private readonly PALHolder _pal;
internal string Path => _path;
internal FileStreamContentProvider(PlatformAdaptationLayer pal, string path)
{
_path = path;
_pal = new PALHolder(pal);
}
public override Stream GetStream()
{
return _pal.GetStream(Path);
}
}