View Source
Class FileService
Represents the File Service, which is an easy access to operations involving IFile objects like Scripts, Stylesheets and Templates
Inheritance
System.Object
Assembly: Umbraco.Core.dll
Syntax
public class FileService : ScopeRepositoryService, IFileService, IService
Constructors
View Source
FileService(IScopeProvider, ILogger, IEventMessagesFactory, IStylesheetRepository, IScriptRepository, ITemplateRepository, IPartialViewRepository, IPartialViewMacroRepository, IAuditRepository)
Declaration
public FileService(IScopeProvider uowProvider, ILogger logger, IEventMessagesFactory eventMessagesFactory, IStylesheetRepository stylesheetRepository, IScriptRepository scriptRepository, ITemplateRepository templateRepository, IPartialViewRepository partialViewRepository, IPartialViewMacroRepository partialViewMacroRepository, IAuditRepository auditRepository)
Parameters
Methods
View Source
CreatePartialView(IPartialView, String, Int32)
Declaration
public Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = -1)
Parameters
Type |
Name |
Description |
IPartialView |
partialView |
|
System.String |
snippetName |
|
System.Int32 |
userId |
|
Returns
View Source
CreatePartialViewFolder(String)
Declaration
public void CreatePartialViewFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
CreatePartialViewMacro(IPartialView, String, Int32)
Declaration
public Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = -1)
Parameters
Type |
Name |
Description |
IPartialView |
partialView |
|
System.String |
snippetName |
|
System.Int32 |
userId |
|
Returns
View Source
CreatePartialViewMacroFolder(String)
Declaration
public void CreatePartialViewMacroFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
CreateScriptFolder(String)
Declaration
public void CreateScriptFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
CreateStyleSheetFolder(String)
Declaration
public void CreateStyleSheetFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
CreateTemplateForContentType(String, String, Int32)
Creates a template for a content type
Declaration
public Attempt<OperationResult<OperationResultType, ITemplate>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = -1)
Parameters
Type |
Name |
Description |
System.String |
contentTypeAlias |
|
System.String |
contentTypeName |
|
System.Int32 |
userId |
|
Returns
View Source
CreateTemplateWithIdentity(String, String, String, ITemplate, Int32)
Create a new template, setting the content if a view exists in the filesystem
Declaration
public ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = -1)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.String |
alias |
|
System.String |
content |
|
ITemplate |
masterTemplate |
|
System.Int32 |
userId |
|
Returns
View Source
DeletePartialView(String, Int32)
Declaration
public bool DeletePartialView(string path, int userId = -1)
Parameters
Type |
Name |
Description |
System.String |
path |
|
System.Int32 |
userId |
|
Returns
Type |
Description |
System.Boolean |
|
View Source
DeletePartialViewFolder(String)
Declaration
public void DeletePartialViewFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
DeletePartialViewMacro(String, Int32)
Declaration
public bool DeletePartialViewMacro(string path, int userId = -1)
Parameters
Type |
Name |
Description |
System.String |
path |
|
System.Int32 |
userId |
|
Returns
Type |
Description |
System.Boolean |
|
View Source
DeletePartialViewMacroFolder(String)
Declaration
public void DeletePartialViewMacroFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
DeleteScript(String, Int32)
Deletes a script by its name
Declaration
public void DeleteScript(string path, int userId = -1)
Parameters
Type |
Name |
Description |
System.String |
path |
Name incl. extension of the Script to delete
|
System.Int32 |
userId |
|
View Source
DeleteScriptFolder(String)
Declaration
public void DeleteScriptFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
DeleteStylesheet(String, Int32)
Deletes a stylesheet by its name
Declaration
public void DeleteStylesheet(string path, int userId = -1)
Parameters
Type |
Name |
Description |
System.String |
path |
Name incl. extension of the Stylesheet to delete
|
System.Int32 |
userId |
|
View Source
DeleteStyleSheetFolder(String)
Declaration
public void DeleteStyleSheetFolder(string folderPath)
Parameters
Type |
Name |
Description |
System.String |
folderPath |
|
View Source
DeleteTemplate(String, Int32)
Deletes a template by its alias
Declaration
public void DeleteTemplate(string alias, int userId = -1)
Parameters
Type |
Name |
Description |
System.String |
alias |
Alias of the ITemplate to delete
|
System.Int32 |
userId |
|
View Source
GetPartialView(String)
Declaration
public IPartialView GetPartialView(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
|
Returns
View Source
GetPartialViewFileContentStream(String)
Declaration
public Stream GetPartialViewFileContentStream(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.IO.Stream |
|
View Source
GetPartialViewFileSize(String)
Declaration
public long GetPartialViewFileSize(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.Int64 |
|
View Source
GetPartialViewMacro(String)
Declaration
public IPartialView GetPartialViewMacro(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
|
Returns
View Source
GetPartialViewMacroFileContentStream(String)
Declaration
public Stream GetPartialViewMacroFileContentStream(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.IO.Stream |
|
View Source
GetPartialViewMacroFileSize(String)
Declaration
public long GetPartialViewMacroFileSize(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.Int64 |
|
View Source
GetPartialViewMacros(String[])
Declaration
public IEnumerable<IPartialView> GetPartialViewMacros(params string[] names)
Parameters
Type |
Name |
Description |
System.String[] |
names |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<IPartialView> |
|
View Source
GetPartialViewMacroSnippetContent(String)
Declaration
public string GetPartialViewMacroSnippetContent(string snippetName)
Parameters
Type |
Name |
Description |
System.String |
snippetName |
|
Returns
Type |
Description |
System.String |
|
View Source
GetPartialViewSnippetContent(String)
Declaration
public string GetPartialViewSnippetContent(string snippetName)
Parameters
Type |
Name |
Description |
System.String |
snippetName |
|
Returns
Type |
Description |
System.String |
|
View Source
GetPartialViewSnippetNames(String[])
Declaration
public IEnumerable<string> GetPartialViewSnippetNames(params string[] filterNames)
Parameters
Type |
Name |
Description |
System.String[] |
filterNames |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.String> |
|
View Source
GetScriptByName(String)
Gets a Script object by its name
Declaration
public Script GetScriptByName(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
Name of the script incl. extension
|
Returns
View Source
GetScriptFileContentStream(String)
Declaration
public Stream GetScriptFileContentStream(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.IO.Stream |
|
View Source
GetScriptFileSize(String)
Declaration
public long GetScriptFileSize(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.Int64 |
|
View Source
GetScripts(String[])
Gets a list of all Script objects
Declaration
public 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
|
View Source
GetStylesheetByName(String)
Declaration
public Stylesheet GetStylesheetByName(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
Name of the stylesheet incl. extension
|
Returns
View Source
GetStylesheetFileContentStream(String)
Declaration
public Stream GetStylesheetFileContentStream(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.IO.Stream |
|
View Source
GetStylesheetFileSize(String)
Declaration
public long GetStylesheetFileSize(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.Int64 |
|
View Source
GetStylesheets(String[])
Declaration
public 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
|
View Source
GetTemplate(Guid)
Gets a ITemplate object by its guid identifier.
Declaration
public ITemplate GetTemplate(Guid id)
Parameters
Type |
Name |
Description |
System.Guid |
id |
The guid identifier of the template.
|
Returns
View Source
GetTemplate(Int32)
Declaration
public ITemplate GetTemplate(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
The identifier of the template.
|
Returns
View Source
GetTemplate(String)
Declaration
public ITemplate GetTemplate(string alias)
Parameters
Type |
Name |
Description |
System.String |
alias |
The alias of the template.
|
Returns
View Source
GetTemplateChildren(Int32)
Gets the template children
Declaration
public IEnumerable<ITemplate> GetTemplateChildren(int masterTemplateId)
Parameters
Type |
Name |
Description |
System.Int32 |
masterTemplateId |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<ITemplate> |
|
View Source
GetTemplateChildren(String)
Gets the template children
Declaration
public IEnumerable<ITemplate> GetTemplateChildren(string alias)
Parameters
Type |
Name |
Description |
System.String |
alias |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<ITemplate> |
|
View Source
GetTemplateDescendants(Int32)
Gets the template descendants
Declaration
public IEnumerable<ITemplate> GetTemplateDescendants(int masterTemplateId)
Parameters
Type |
Name |
Description |
System.Int32 |
masterTemplateId |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<ITemplate> |
|
View Source
GetTemplateDescendants(String)
Declaration
public IEnumerable<ITemplate> GetTemplateDescendants(string alias)
Parameters
Type |
Name |
Description |
System.String |
alias |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<ITemplate> |
|
View Source
GetTemplateFileContentStream(String)
Declaration
public Stream GetTemplateFileContentStream(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.IO.Stream |
|
View Source
GetTemplateFileSize(String)
Declaration
public long GetTemplateFileSize(string filepath)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
Returns
Type |
Description |
System.Int64 |
|
View Source
GetTemplates(Int32)
Declaration
public 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
|
View Source
GetTemplates(String[])
Declaration
public 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
|
View Source
SavePartialView(IPartialView, Int32)
Declaration
public Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = -1)
Parameters
Type |
Name |
Description |
IPartialView |
partialView |
|
System.Int32 |
userId |
|
Returns
View Source
SavePartialViewMacro(IPartialView, Int32)
Declaration
public Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int userId = -1)
Parameters
Type |
Name |
Description |
IPartialView |
partialView |
|
System.Int32 |
userId |
|
Returns
View Source
SaveScript(Script, Int32)
Declaration
public void SaveScript(Script script, int userId = -1)
Parameters
Type |
Name |
Description |
Script |
script |
Script to save
|
System.Int32 |
userId |
|
View Source
SaveStylesheet(Stylesheet, Int32)
Declaration
public void SaveStylesheet(Stylesheet stylesheet, int userId = -1)
Parameters
View Source
SaveTemplate(IEnumerable<ITemplate>, Int32)
Declaration
public void SaveTemplate(IEnumerable<ITemplate> templates, int userId = -1)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<ITemplate> |
templates |
List of Template to save
|
System.Int32 |
userId |
Optional id of the user
|
View Source
SaveTemplate(ITemplate, Int32)
Declaration
public void SaveTemplate(ITemplate template, int userId = -1)
Parameters
View Source
SetPartialViewFileContent(String, Stream)
Declaration
public void SetPartialViewFileContent(string filepath, Stream content)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
System.IO.Stream |
content |
|
View Source
SetPartialViewMacroFileContent(String, Stream)
Declaration
public void SetPartialViewMacroFileContent(string filepath, Stream content)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
System.IO.Stream |
content |
|
View Source
SetScriptFileContent(String, Stream)
Declaration
public void SetScriptFileContent(string filepath, Stream content)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
System.IO.Stream |
content |
|
View Source
SetStylesheetFileContent(String, Stream)
Declaration
public void SetStylesheetFileContent(string filepath, Stream content)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
System.IO.Stream |
content |
|
View Source
SetTemplateFileContent(String, Stream)
Declaration
public void SetTemplateFileContent(string filepath, Stream content)
Parameters
Type |
Name |
Description |
System.String |
filepath |
|
System.IO.Stream |
content |
|
View Source
ValidatePartialView(PartialView)
Declaration
public bool ValidatePartialView(PartialView partialView)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
ValidatePartialViewMacro(PartialView)
Declaration
public bool ValidatePartialViewMacro(PartialView partialView)
Parameters
Returns
Type |
Description |
System.Boolean |
|
View Source
ValidateScript(Script)
Declaration
public bool ValidateScript(Script script)
Parameters
Returns
Type |
Description |
System.Boolean |
True if Script is valid, otherwise false
|
View Source
ValidateStylesheet(Stylesheet)
Declaration
public bool ValidateStylesheet(Stylesheet stylesheet)
Parameters
Returns
Type |
Description |
System.Boolean |
True if Stylesheet is valid, otherwise false
|
View Source
ValidateTemplate(ITemplate)
Declaration
public bool ValidateTemplate(ITemplate template)
Parameters
Returns
Type |
Description |
System.Boolean |
True if Script is valid, otherwise false
|
Events
View Source
CreatedPartialView
Declaration
public static event TypedEventHandler<IFileService, NewEventArgs<IPartialView>> CreatedPartialView
Event Type
View Source
CreatingPartialView
Declaration
public static event TypedEventHandler<IFileService, NewEventArgs<IPartialView>> CreatingPartialView
Event Type
View Source
DeletedPartialView
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<IPartialView>> DeletedPartialView
Event Type
View Source
DeletedScript
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<Script>> DeletedScript
Event Type
View Source
DeletedStylesheet
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<Stylesheet>> DeletedStylesheet
Event Type
View Source
DeletedTemplate
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<ITemplate>> DeletedTemplate
Event Type
View Source
DeletingPartialView
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<IPartialView>> DeletingPartialView
Event Type
View Source
DeletingScript
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<Script>> DeletingScript
Event Type
View Source
DeletingStylesheet
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<Stylesheet>> DeletingStylesheet
Event Type
View Source
DeletingTemplate
Declaration
public static event TypedEventHandler<IFileService, DeleteEventArgs<ITemplate>> DeletingTemplate
Event Type
View Source
SavedPartialView
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<IPartialView>> SavedPartialView
Event Type
View Source
SavedScript
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<Script>> SavedScript
Event Type
View Source
SavedStylesheet
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<Stylesheet>> SavedStylesheet
Event Type
View Source
SavedTemplate
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<ITemplate>> SavedTemplate
Event Type
View Source
SavingPartialView
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<IPartialView>> SavingPartialView
Event Type
View Source
SavingScript
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<Script>> SavingScript
Event Type
View Source
SavingStylesheet
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<Stylesheet>> SavingStylesheet
Event Type
View Source
SavingTemplate
Declaration
public static event TypedEventHandler<IFileService, SaveEventArgs<ITemplate>> SavingTemplate
Event Type