Class UnifiedFile
Base class for all implementations of custom file systems. This is an extension of the VPP API VirtualFile class to provide extended functionallity around EPiServer files.
Namespace: EPiServer.Web.Hosting
Assembly: EPiServer.dll
Version: 7.19.2Syntax
public abstract class UnifiedFile : VirtualFileEx
Constructors
UnifiedFile(UnifiedDirectory, VirtualPathUnifiedProvider, String, Boolean)
Default constructor.
Declaration
public UnifiedFile(UnifiedDirectory directory, VirtualPathUnifiedProvider provider, string virtualPath, bool bypassAccessCheck)
Parameters
Type | Name | Description |
---|---|---|
UnifiedDirectory | directory | The directory the file belongs to. Is only of importance for access checks for page folders for unsaved pages |
VirtualPathUnifiedProvider | provider | The provider. |
System.String | virtualPath | The virtual path. |
System.Boolean | bypassAccessCheck | True if no access check should be done. |
Remarks
UnifiedDirectory needs to be passed only when files is created in a directory which is a pagefolder for an unsaved page. Else null can be passed
Fields
ContentForAclCheck
When a new page is created but not yet saved we need to hold parent for that page here so we can perform access check against it. When Parent property is overriden the SetPageForAccessControl on parent should be called before parent is returned.
Declaration
protected ContentReference ContentForAclCheck
Field Value
Type | Description |
---|---|
ContentReference |
Properties
BypassAccessCheck
Gets or sets a value indicating whether to bypass access check for file.
Declaration
public virtual bool BypassAccessCheck { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Created
Base class implementation of interface. Throws NotImplementedException.
Declaration
public virtual DateTime Created { get; }
Property Value
Type | Description |
---|---|
System.DateTime | The created. |
Length
Base class implementation of interface. Throws NotImplementedException.
Declaration
public virtual long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 | The length. |
Parent
Parent UnifiedDirectory of the current UnifiedFile.
Declaration
public virtual UnifiedDirectory Parent { get; }
Property Value
Type | Description |
---|---|
UnifiedDirectory |
Remarks
When Parent property is overriden: if PageForAclCheck is set, SetPageForAccessControl on parent should be called with PageForAclCheck as parameter before parent is returned.
PermanentLinkVirtualPath
Gets the permanent link virtual path.
Declaration
public abstract string PermanentLinkVirtualPath { get; }
Property Value
Type | Description |
---|---|
System.String | The permanent link virtual path. |
Provider
Gets the virtual path provider that handles this directory.
Declaration
public VirtualPathUnifiedProvider Provider { get; }
Property Value
Type | Description |
---|---|
VirtualPathUnifiedProvider |
Summary
Gets the summary for the file.
Declaration
public virtual IUnifiedSummary Summary { get; }
Property Value
Type | Description |
---|---|
IUnifiedSummary | The summary. |
Methods
CopyFile(VirtualFile, UnifiedFile)
Copies the content of one file to the other. If a file is versioned a checkout of the file instance is called before atempt to write new data from source file using the Stream from OpenWrite() in destination. Also Summary data is copied from source to destination using the Dictionary property of the files. At the end of copy a versioned file is checked in with empty comment.
Declaration
protected static void CopyFile(VirtualFile source, UnifiedFile destination)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Hosting.VirtualFile | source | Source file holding data to copy from. |
UnifiedFile | destination | Destination file to copy data to. |
CopySummary(UnifiedFile, UnifiedFile)
Copies the summary.
Declaration
public static void CopySummary(UnifiedFile src, UnifiedFile dst)
Parameters
Type | Name | Description |
---|---|---|
UnifiedFile | src | The SRC. |
UnifiedFile | dst | The DST. |
CopyTo(String)
Creates a copy of this file instance at the specified virtual path.
Declaration
public virtual void CopyTo(string newVirtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | newVirtualPath | The full virtual path to copy the file to, including the file name. |
Remarks
Fires a FileEvent with type flag set to FileCopy. This method relies on the VirtualPath property not set to new path and internally builds the new path from this data. This means implementing classes shall call this before doing any other implementation logic.
CopyTo(String, Guid)
Creates a copy of this file instance at the specified virtual path.
Declaration
public virtual void CopyTo(string newVirtualPath, Guid fileId)
Parameters
Type | Name | Description |
---|---|---|
System.String | newVirtualPath | The full virtual path to copy the file to, including the file name. |
System.Guid | fileId | The guid for the file. |
Remarks
Fires a FileEvent with type flag set to FileCopy. This method relies on the VirtualPath property not set to new path and internally builds the new path from this data. This means implementing classes shall call this before doing any other implementation logic.
CopyTo(VirtualFile, String)
Copies the file to a new path
Declaration
public static void CopyTo(VirtualFile source, string newVirtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Hosting.VirtualFile | source | The source. |
System.String | newVirtualPath | The new virtual path. |
Delete()
Base class implementation of interface. Throws NotImplementedException.
Declaration
public virtual void Delete()
MoveTo(UnifiedFile, String)
Moves to the file to a new path
Declaration
public static void MoveTo(UnifiedFile source, string newVirtualPath)
Parameters
Type | Name | Description |
---|---|---|
UnifiedFile | source | The source. |
System.String | newVirtualPath | The new virtual path. |
Remarks
The newVirtualPath
parameter is expected to contain the full path to the new file, including the file name.
Avoid to call this method from MoveTo(String) in the case the source and destination is from the same type of provider
MoveTo(String)
Moves this file instance to a new virtual path.
Declaration
public virtual void MoveTo(string newVirtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | newVirtualPath | The full virtual path to move the file to, including the file name. |
Remarks
Fires a FileEvent with type flag set to FileMove. This method relies on the VirtualPath property not set to new path and internally builds the new path from this data. This means implementing classes shall call this before doing any other implementation logic.
OnCheckedIn(UnifiedVirtualPathEventArgs)
Base implementation on raised event for checked in files.
Declaration
protected virtual void OnCheckedIn(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnCheckedOut(UnifiedVirtualPathEventArgs)
Base implementation on raised event for checked out files.
Declaration
protected virtual void OnCheckedOut(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnCheckingIn(UnifiedVirtualPathEventArgs)
Base implementation on raised event for checking in files.
Declaration
protected virtual void OnCheckingIn(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnCheckingOut(UnifiedVirtualPathEventArgs)
Base implementation on raised event for checking out files.
Declaration
protected virtual void OnCheckingOut(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnCopied(UnifiedVirtualPathEventArgs)
Base implementation on raised event for copied files.
Declaration
protected virtual void OnCopied(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnCopying(UnifiedVirtualPathEventArgs)
Base implementation on raised event for copying files.
Declaration
protected virtual void OnCopying(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnDeleted(UnifiedVirtualPathEventArgs)
Base implementation on raised event for deleted files.
Declaration
protected virtual void OnDeleted(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnDeleting(UnifiedVirtualPathEventArgs)
Base implementation on raised event for deleting files.
Declaration
protected virtual void OnDeleting(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnMoved(UnifiedVirtualPathEventArgs)
Base implementation on raised event for renamed files.
Declaration
protected virtual void OnMoved(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnMoving(UnifiedVirtualPathEventArgs)
Base implementation on raised event for renaming files.
Declaration
protected virtual void OnMoving(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnSummarySaved(UnifiedVirtualPathEventArgs)
Raises the UnifiedFileSummarySaved event.
Declaration
protected virtual void OnSummarySaved(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e | The UnifiedVirtualPathEventArgs instance containing the event data. |
OnTransmitting(VirtualFile)
Called when transmitting/downloading a UnifiedFile.
Declaration
public static bool OnTransmitting(VirtualFile file)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Hosting.VirtualFile | file | The file to be transmitted. |
Returns
Type | Description |
---|---|
System.Boolean | True if the file should be transmitted, False if the transmission should be cancelled. |
Remarks
Note that this method is not called from within a UnifiedFile-derived class and must therefore be public and not protected as the rest of the event raiser methods. The reason for this is that it is not possible to identify the scenario where a file is downloaded by just looking at the use of the API:s in UnifiedFile.
OnUndidCheckOut(UnifiedVirtualPathEventArgs)
Base implementation on raised event for undoed checked out files.
Declaration
protected virtual void OnUndidCheckOut(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
OnUndoingCheckOut(UnifiedVirtualPathEventArgs)
Base implementation on raised event for undoing checking out files.
Declaration
protected virtual void OnUndoingCheckOut(UnifiedVirtualPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UnifiedVirtualPathEventArgs | e |
Open()
When overridden in a derived class, returns a read-only stream to the virtual resource.
Declaration
public override Stream Open()
Returns
Type | Description |
---|---|
System.IO.Stream | A read-only stream to the virtual file. |
Open(FileMode)
Opens the file for writing given an mode to open the file in.
Declaration
public virtual Stream Open(FileMode mode)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileMode | mode | The mode. |
Returns
Type | Description |
---|---|
System.IO.Stream | A open stream to the file. |
Open(FileMode, FileAccess)
Opens the file for writing given an mode with an specific share option to open the file in .
Declaration
public virtual Stream Open(FileMode mode, FileAccess access)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileMode | mode | The file mode to use when open the file. |
System.IO.FileAccess | access | A FileAccess constant specifying whether to open the file with Read, Write, or ReadWrite file access. |
Returns
Type | Description |
---|---|
System.IO.Stream | A open stream to the file. |
Open(FileMode, FileAccess, FileShare)
Opens the file for writing given an mode with an specific share option to open the file in .
Declaration
public virtual Stream Open(FileMode mode, FileAccess access, FileShare share)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileMode | mode | The file mode to use when open the file. |
System.IO.FileAccess | access | A FileAccess constant specifying whether to open the file with Read, Write, or ReadWrite file access. |
System.IO.FileShare | share | A FileShare value specifying the type of access other threads have to the file. |
Returns
Type | Description |
---|---|
System.IO.Stream | A open stream to the file. |
QueryAccess()
Gets the access level for the current user on this file.
Declaration
public virtual AccessLevel QueryAccess()
Returns
Type | Description |
---|---|
AccessLevel | The access level. |
QueryDistinctAccess(AccessLevel)
Query if a user has access level on the current folder.
Declaration
public virtual bool QueryDistinctAccess(AccessLevel access)
Parameters
Type | Name | Description |
---|---|---|
AccessLevel | access | The required access level. |
Returns
Type | Description |
---|---|
System.Boolean |
SetContentForAccessControl(ContentReference)
Method that admits control of which page to perform access control against.
Declaration
public virtual void SetContentForAccessControl(ContentReference contentLink)
Parameters
Type | Name | Description |
---|---|---|
ContentReference | contentLink | The page to check access against |
SetPageForAccessControl(PageReference)
Declaration
[Obsolete("Use SetContentForAccessControl")]
public virtual void SetPageForAccessControl(PageReference pageReference)
Parameters
Type | Name | Description |
---|---|---|
PageReference | pageReference |
TryAsVersioningFile(out IVersioningFile)
Tries to cast this instance to a versioning file.
Declaration
public bool TryAsVersioningFile(out IVersioningFile vFile)
Parameters
Type | Name | Description |
---|---|---|
IVersioningFile | vFile | The file as IVersioningFile is succeded, else null |
Returns
Type | Description |
---|---|
System.Boolean | true if file is versioning file |
Events
UnifiedFileChanged
Raised when a file is changed.
Declaration
public static event UnifiedFileStreamEventHandler UnifiedFileChanged
Event Type
Type | Description |
---|---|
UnifiedFileStreamEventHandler |
UnifiedFileCheckedIn
Raised when a file is checked in.
Declaration
public static event UnifiedFileEventHandler UnifiedFileCheckedIn
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileCheckedOut
Raised when a file is checked out.
Declaration
public static event UnifiedFileEventHandler UnifiedFileCheckedOut
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileCheckingIn
Raised when a file is about to be checked in.
Declaration
public static event UnifiedFileEventHandler UnifiedFileCheckingIn
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileCheckingOut
Raised when a file is about to be checked out.
Declaration
public static event UnifiedFileEventHandler UnifiedFileCheckingOut
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileCheckOutUndone
Raised when a file checked out is undone.
Declaration
public static event UnifiedFileEventHandler UnifiedFileCheckOutUndone
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileCopied
Raised when a file is copied.
Declaration
public static event UnifiedFileEventHandler UnifiedFileCopied
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileCopying
Raised when a file is about to be copied.
Declaration
public static event UnifiedFileEventHandler UnifiedFileCopying
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileDeleted
Raised when a file is deleted.
Declaration
public static event UnifiedFileEventHandler UnifiedFileDeleted
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileDeleting
Raised when a file is about to be deleted.
Declaration
public static event UnifiedFileEventHandler UnifiedFileDeleting
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileMoved
Raised when a file is moved.
Declaration
public static event UnifiedFileEventHandler UnifiedFileMoved
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileMoving
Raised when a file is about to be moved.
Declaration
public static event UnifiedFileEventHandler UnifiedFileMoving
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileSummarySaved
Raised when a file summary is saved.
Declaration
public static event UnifiedFileEventHandler UnifiedFileSummarySaved
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileTransmitting
Raised when a file is about to be transmitted / downloaded.
Declaration
public static event UnifiedFileEventHandler UnifiedFileTransmitting
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileUndoedCheckOut
Raised when a file is undo checked out.
Declaration
[Obsolete("Use UnifiedFileCheckOutUndone event instead", true)]
public static event UnifiedFileEventHandler UnifiedFileUndoedCheckOut
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |
UnifiedFileUndoingCheckOut
Raised when a file is about to be undo checked out.
Declaration
public static event UnifiedFileEventHandler UnifiedFileUndoingCheckOut
Event Type
Type | Description |
---|---|
UnifiedFileEventHandler |