Interface IFileService
Defines the File Service, which is an easy access to operations involving IFile objects like Scripts, Stylesheets and Templates
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public interface IFileService : IService
Methods
CreatePartialView(IPartialView, String, Int32)
Declaration
Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IPartialView | partialView | |
System.String | snippetName | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
Attempt<IPartialView> |
CreatePartialViewFolder(String)
Declaration
void CreatePartialViewFolder(string folderPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderPath |
CreatePartialViewMacro(IPartialView, String, Int32)
Declaration
Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IPartialView | partialView | |
System.String | snippetName | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
Attempt<IPartialView> |
CreatePartialViewMacroFolder(String)
Declaration
void CreatePartialViewMacroFolder(string folderPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderPath |
CreateScriptFolder(String)
Creates a folder for scripts
Declaration
void CreateScriptFolder(string folderPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderPath |
CreateTemplateForContentType(String, String, Int32)
Creates a template for a content type
Declaration
Attempt<OperationStatus<ITemplate, OperationStatusType>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeAlias | |
System.String | contentTypeName | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
Attempt<OperationStatus<ITemplate, OperationStatusType>> | The template created |
CreateTemplateWithIdentity(String, String, ITemplate, Int32)
Declaration
ITemplate CreateTemplateWithIdentity(string name, string content, ITemplate masterTemplate = null, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | |
System.String | content | |
ITemplate | masterTemplate | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
ITemplate |
DeletePartialView(String, Int32)
Declaration
bool DeletePartialView(string path, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
System.Boolean |
DeletePartialViewFolder(String)
Declaration
void DeletePartialViewFolder(string folderPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderPath |
DeletePartialViewMacro(String, Int32)
Declaration
bool DeletePartialViewMacro(string path, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
System.Boolean |
DeletePartialViewMacroFolder(String)
Declaration
void DeletePartialViewMacroFolder(string folderPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderPath |
DeleteScript(String, Int32)
Deletes a script by its name
Declaration
void DeleteScript(string path, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Name incl. extension of the Script to delete |
System.Int32 | userId | Optional id of the user deleting the script |
DeleteScriptFolder(String)
Deletes a folder for scripts
Declaration
void DeleteScriptFolder(string folderPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | folderPath |
DeleteStylesheet(String, Int32)
Deletes a stylesheet by its name
Declaration
void DeleteStylesheet(string path, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Name incl. extension of the Stylesheet to delete |
System.Int32 | userId | Optional id of the user deleting the stylesheet |
DeleteTemplate(String, Int32)
Deletes a template by its alias
Declaration
void DeleteTemplate(string alias, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | Alias of the ITemplate to delete |
System.Int32 | userId | Optional id of the user deleting the template |
DetermineTemplateRenderingEngine(ITemplate)
This checks what the default rendering engine is set in config but then also ensures that there isn't already a template that exists in the opposite rendering engine's template folder, then returns the appropriate rendering engine to use.
Declaration
RenderingEngine DetermineTemplateRenderingEngine(ITemplate template)
Parameters
Type | Name | Description |
---|---|---|
ITemplate | template |
Returns
Type | Description |
---|---|
RenderingEngine |
Remarks
The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page. This is mostly related to installing packages since packages install file templates to the file system and then create the templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
FindTemplateInTree(TemplateNode, String)
Given a template node in a tree, this will find the template node with the given alias if it is found in the hierarchy, otherwise null
Declaration
TemplateNode FindTemplateInTree(TemplateNode anyNode, string alias)
Parameters
Type | Name | Description |
---|---|---|
TemplateNode | anyNode | |
System.String | alias |
Returns
Type | Description |
---|---|
TemplateNode |
GetMacroScript(String)
Declaration
[Obsolete("MacroScripts are obsolete - this is for backwards compatibility with upgraded sites.")]
IPartialView GetMacroScript(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
IPartialView |
GetMacroScriptFileContentStream(String)
Gets the content of a macroscript as a stream.
Declaration
Stream GetMacroScriptFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the macroscript. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the macroscript. |
GetMacroScriptFileSize(String)
Gets the size of a macroscript.
Declaration
long GetMacroScriptFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the macroscript. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the macroscript. |
GetPartialView(String)
Declaration
IPartialView GetPartialView(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
IPartialView |
GetPartialViewFileContentStream(String)
Gets the content of a partial view as a stream.
Declaration
Stream GetPartialViewFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the partial view. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the partial view. |
GetPartialViewFileSize(String)
Gets the size of a partial view.
Declaration
long GetPartialViewFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the partial view. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the partial view. |
GetPartialViewMacro(String)
Declaration
IPartialView GetPartialViewMacro(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
IPartialView |
GetPartialViewMacroFileContentStream(String)
Gets the content of a macro partial view as a stream.
Declaration
Stream GetPartialViewMacroFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the macro partial view. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the macro partial view. |
GetPartialViewMacroFileSize(String)
Gets the size of a macro partial view.
Declaration
long GetPartialViewMacroFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the macro partial view. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the macro partial view. |
GetPartialViewMacros(String[])
Declaration
IEnumerable<IPartialView> GetPartialViewMacros(params string[] names)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | names |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IPartialView> |
GetPartialViewMacroSnippetContent(String)
Gets the content of a macro partial view snippet as a string
Declaration
string GetPartialViewMacroSnippetContent(string snippetName)
Parameters
Type | Name | Description |
---|---|---|
System.String | snippetName | The name of the snippet |
Returns
Type | Description |
---|---|
System.String |
GetPartialViewSnippetContent(String)
Gets the content of a partial view snippet as a string.
Declaration
string GetPartialViewSnippetContent(string snippetName)
Parameters
Type | Name | Description |
---|---|---|
System.String | snippetName | The name of the snippet |
Returns
Type | Description |
---|---|
System.String | The content of the partial view. |
GetPartialViewSnippetNames(String[])
Declaration
IEnumerable<string> GetPartialViewSnippetNames(params string[] filterNames)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | filterNames |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> |
GetScriptByName(String)
Gets a Script object by its name
Declaration
Script GetScriptByName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the script incl. extension |
Returns
Type | Description |
---|---|
Script | A Script object |
GetScriptFileContentStream(String)
Gets the content of a script file as a stream.
Declaration
Stream GetScriptFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the script. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the script file. |
GetScriptFileSize(String)
Gets the size of a script file.
Declaration
long GetScriptFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the script file. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the script file. |
GetScripts(String[])
Gets a list of all Script objects
Declaration
IEnumerable<Script> GetScripts(params string[] names)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | names |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Script> | An enumerable list of Script objects |
GetStylesheetByName(String)
Gets a Stylesheet object by its name
Declaration
Stylesheet GetStylesheetByName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the stylesheet incl. extension |
Returns
Type | Description |
---|---|
Stylesheet | A Stylesheet object |
GetStylesheetFileContentStream(String)
Gets the content of a stylesheet as a stream.
Declaration
Stream GetStylesheetFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the stylesheet. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the stylesheet. |
GetStylesheetFileSize(String)
Gets the size of a stylesheet.
Declaration
long GetStylesheetFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the stylesheet. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the stylesheet. |
GetStylesheets(String[])
Gets a list of all Stylesheet objects
Declaration
IEnumerable<Stylesheet> GetStylesheets(params string[] names)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | names |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Stylesheet> | An enumerable list of Stylesheet objects |
GetTemplate(Guid)
Gets a ITemplate object by its guid identifier.
Declaration
ITemplate GetTemplate(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The guid identifier of the template. |
Returns
Type | Description |
---|---|
ITemplate | The ITemplate object matching the identifier, or null. |
GetTemplate(Int32)
Gets a ITemplate object by its identifier.
Declaration
ITemplate GetTemplate(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifer of the template. |
Returns
Type | Description |
---|---|
ITemplate | The ITemplate object matching the identifier, or null. |
GetTemplate(String)
Gets a ITemplate object by its alias.
Declaration
ITemplate GetTemplate(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | The alias of the template. |
Returns
Type | Description |
---|---|
ITemplate | The ITemplate object matching the alias, or null. |
GetTemplateChildren(Int32)
Gets the template children
Declaration
IEnumerable<ITemplate> GetTemplateChildren(int masterTemplateId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | masterTemplateId |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ITemplate> |
GetTemplateChildren(String)
Gets the template children
Declaration
IEnumerable<ITemplate> GetTemplateChildren(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ITemplate> |
GetTemplateDescendants(Int32)
Gets the template descendants
Declaration
IEnumerable<ITemplate> GetTemplateDescendants(int masterTemplateId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | masterTemplateId |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ITemplate> |
GetTemplateDescendants(String)
Gets the template descendants
Declaration
IEnumerable<ITemplate> GetTemplateDescendants(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ITemplate> |
GetTemplateFileContentStream(String)
Gets the content of a template as a stream.
Declaration
Stream GetTemplateFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the template. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the template. |
GetTemplateFileSize(String)
Gets the size of a template.
Declaration
long GetTemplateFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the template. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the template. |
GetTemplateNode(String)
Returns a template as a template node which can be traversed (parent, children)
Declaration
TemplateNode GetTemplateNode(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias |
Returns
Type | Description |
---|---|
TemplateNode |
GetTemplates(Int32)
Gets a list of all ITemplate objects
Declaration
IEnumerable<ITemplate> GetTemplates(int masterTemplateId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | masterTemplateId |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ITemplate> | An enumerable list of ITemplate objects |
GetTemplates(String[])
Gets a list of all ITemplate objects
Declaration
IEnumerable<ITemplate> GetTemplates(params string[] aliases)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | aliases |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ITemplate> | An enumerable list of ITemplate objects |
GetUserControl(String)
Declaration
[Obsolete("UserControls are obsolete - this is for backwards compatibility with upgraded sites.")]
IUserControl GetUserControl(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
IUserControl |
GetUserControlFileContentStream(String)
Gets the content of a usercontrol as a stream.
Declaration
Stream GetUserControlFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the usercontrol. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the usercontrol. |
GetUserControlFileSize(String)
Gets the size of a usercontrol.
Declaration
long GetUserControlFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the usercontrol. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the usercontrol. |
GetXsltFile(String)
Declaration
IXsltFile GetXsltFile(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
IXsltFile |
GetXsltFileContentStream(String)
Gets the content of a XSLT file as a stream.
Declaration
Stream GetXsltFileContentStream(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the XSLT file. |
Returns
Type | Description |
---|---|
System.IO.Stream | The content of the XSLT file. |
GetXsltFiles(String[])
Declaration
IEnumerable<IXsltFile> GetXsltFiles(params string[] names)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | names |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IXsltFile> |
GetXsltFileSize(String)
Gets the size of a XSLT file.
Declaration
long GetXsltFileSize(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the XSLT file. |
Returns
Type | Description |
---|---|
System.Int64 | The size of the XSLT file. |
SavePartialView(IPartialView, Int32)
Declaration
Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IPartialView | partialView | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
Attempt<IPartialView> |
SavePartialViewMacro(IPartialView, Int32)
Declaration
Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
IPartialView | partialView | |
System.Int32 | userId |
Returns
Type | Description |
---|---|
Attempt<IPartialView> |
SaveScript(Script, Int32)
Saves a Script
Declaration
void SaveScript(Script script, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
Script | script | Script to save |
System.Int32 | userId | Optional id of the user saving the script |
SaveStylesheet(Stylesheet, Int32)
Saves a Stylesheet
Declaration
void SaveStylesheet(Stylesheet stylesheet, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
Stylesheet | stylesheet | Stylesheet to save |
System.Int32 | userId | Optional id of the user saving the stylesheet |
SaveTemplate(IEnumerable<ITemplate>, Int32)
Saves a collection of Template objects
Declaration
void SaveTemplate(IEnumerable<ITemplate> templates, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ITemplate> | templates | List of Template to save |
System.Int32 | userId | Optional id of the user |
SaveTemplate(ITemplate, Int32)
Saves a ITemplate
Declaration
void SaveTemplate(ITemplate template, int userId = 0)
Parameters
Type | Name | Description |
---|---|---|
ITemplate | template | ITemplate to save |
System.Int32 | userId | Optional id of the user saving the template |
SetMacroScriptFileContent(String, Stream)
Sets the content of a macroscript.
Declaration
void SetMacroScriptFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the macroscript. |
System.IO.Stream | content | The content of the macroscript. |
SetPartialViewFileContent(String, Stream)
Sets the content of a partial view.
Declaration
void SetPartialViewFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the partial view. |
System.IO.Stream | content | The content of the partial view. |
SetPartialViewMacroFileContent(String, Stream)
Sets the content of a macro partial view.
Declaration
void SetPartialViewMacroFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the macro partial view. |
System.IO.Stream | content | The content of the macro partial view. |
SetScriptFileContent(String, Stream)
Sets the content of a script file.
Declaration
void SetScriptFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the script. |
System.IO.Stream | content | The content of the script file. |
SetStylesheetFileContent(String, Stream)
Sets the content of a stylesheet.
Declaration
void SetStylesheetFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the stylesheet. |
System.IO.Stream | content | The content of the stylesheet. |
SetTemplateFileContent(String, Stream)
Sets the content of a template.
Declaration
void SetTemplateFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the template. |
System.IO.Stream | content | The content of the template. |
SetUserControlFileContent(String, Stream)
Sets the content of a usercontrol.
Declaration
void SetUserControlFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the usercontrol. |
System.IO.Stream | content | The content of the usercontrol. |
SetXsltFileContent(String, Stream)
Sets the content of a XSLT file.
Declaration
void SetXsltFileContent(string filepath, Stream content)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The filesystem path to the XSLT file. |
System.IO.Stream | content | The content of the XSLT file. |
ValidatePartialView(PartialView)
Declaration
bool ValidatePartialView(PartialView partialView)
Parameters
Type | Name | Description |
---|---|---|
PartialView | partialView |
Returns
Type | Description |
---|---|
System.Boolean |
ValidatePartialViewMacro(PartialView)
Declaration
bool ValidatePartialViewMacro(PartialView partialView)
Parameters
Type | Name | Description |
---|---|---|
PartialView | partialView |
Returns
Type | Description |
---|---|
System.Boolean |
ValidateScript(Script)
Validates a Script
Declaration
bool ValidateScript(Script script)
Parameters
Type | Name | Description |
---|---|---|
Script | script | Script to validate |
Returns
Type | Description |
---|---|
System.Boolean | True if Script is valid, otherwise false |
ValidateStylesheet(Stylesheet)
Validates a Stylesheet
Declaration
bool ValidateStylesheet(Stylesheet stylesheet)
Parameters
Type | Name | Description |
---|---|---|
Stylesheet | stylesheet | Stylesheet to validate |
Returns
Type | Description |
---|---|
System.Boolean | True if Stylesheet is valid, otherwise false |
ValidateTemplate(ITemplate)
Validates a ITemplate
Declaration
bool ValidateTemplate(ITemplate template)
Parameters
Type | Name | Description |
---|---|---|
ITemplate | template | ITemplate to validate |
Returns
Type | Description |
---|---|
System.Boolean | True if Script is valid, otherwise false |