ReadOnlyFileSystemProvider.GetContent Method
Namespace: Rebex.IO.FileSystem
Assembly: Rebex.FileSystem.dll (version 7.0.9147)
GetContent(NodeBase, NodeContentParameters)
Override this method to implement retrieval of the content for the node
.
By default, this method is only called for files (instances of the class File
When the virtual file system is used in the FileServer component, the server session, which contains information about the user and the active connection, can be accessed using Current property.
Declaration
protected abstract NodeContent GetContent(NodeBase node, NodeContentParameters contentParameters)
Parameters
Type | Name | Description |
---|---|---|
Node |
node | Processed node. |
Node |
contentParameters | Required properties of the returned Node |
Returns
Type | Description |
---|---|
Node |
Content for the |
Examples
protected override NodeContent GetContent(NodeBase node, NodeContentParams contentRequest)
{
var fullPath = getFullPath(node.Path);
if (contentRequest.AccesType == NodeContentAccess.Read)
{
var readOnlyStream = File.OpenRead(fullPath);
return NodeContent.CreateReadOnlyContent(readOnlyStream);
}
var realFsAccessMode = contentRequest.AccesType == NodeContentAccess.Write
? FileAccess.Write
: FileAccess.ReadWrite;
var readWriteStream = File.Open(fullPath, FileMode.Open, realFsAccessMode);
return NodeContent.CreateImmediateWriteContent(readWriteStream);
}