Search Results for

    Show / Hide Table of Contents
    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
    RepositoryService
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class FileService : RepositoryService, IFileService, IService

    Constructors

    View Source

    FileService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IStylesheetRepository, IScriptRepository, ITemplateRepository, IPartialViewRepository, IPartialViewMacroRepository, IAuditRepository, IShortStringHelper, IOptions<GlobalSettings>, IHostingEnvironment)

    Declaration
    public FileService(ICoreScopeProvider uowProvider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IStylesheetRepository stylesheetRepository, IScriptRepository scriptRepository, ITemplateRepository templateRepository, IPartialViewRepository partialViewRepository, IPartialViewMacroRepository partialViewMacroRepository, IAuditRepository auditRepository, IShortStringHelper shortStringHelper, IOptions<GlobalSettings> globalSettings, IHostingEnvironment hostingEnvironment)
    Parameters
    Type Name Description
    ICoreScopeProvider uowProvider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IStylesheetRepository stylesheetRepository
    IScriptRepository scriptRepository
    ITemplateRepository templateRepository
    IPartialViewRepository partialViewRepository
    IPartialViewMacroRepository partialViewMacroRepository
    IAuditRepository auditRepository
    IShortStringHelper shortStringHelper
    IOptions<GlobalSettings> globalSettings
    IHostingEnvironment hostingEnvironment

    Methods

    View Source

    CreatePartialView(IPartialView, String, Nullable<Int32>)

    Declaration
    public Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int? userId = -1)
    Parameters
    Type Name Description
    IPartialView partialView
    System.String snippetName
    System.Nullable<System.Int32> userId
    Returns
    Type Description
    Attempt<IPartialView>
    View Source

    CreatePartialViewFolder(String)

    Declaration
    public void CreatePartialViewFolder(string folderPath)
    Parameters
    Type Name Description
    System.String folderPath
    View Source

    CreatePartialViewMacro(IPartialView, String, Nullable<Int32>)

    Declaration
    public Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int? userId = -1)
    Parameters
    Type Name Description
    IPartialView partialView
    System.String snippetName
    System.Nullable<System.Int32> userId
    Returns
    Type Description
    Attempt<IPartialView>
    View Source

    CreatePartialViewMacroFolder(String)

    Declaration
    public void CreatePartialViewMacroFolder(string folderPath)
    Parameters
    Type Name Description
    System.String folderPath
    View Source

    CreateScriptFolder(String)

    Creates a folder for scripts

    Declaration
    public void CreateScriptFolder(string folderPath)
    Parameters
    Type Name Description
    System.String folderPath
    View Source

    CreateStyleSheetFolder(String)

    Creates a folder for style sheets

    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
    Type Description
    Attempt<OperationResult<OperationResultType, ITemplate>>

    The template created

    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
    Type Description
    ITemplate
    View Source

    DeletePartialView(String, Nullable<Int32>)

    Declaration
    public bool DeletePartialView(string path, int? userId = null)
    Parameters
    Type Name Description
    System.String path
    System.Nullable<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, Nullable<Int32>)

    Declaration
    public bool DeletePartialViewMacro(string path, int? userId = null)
    Parameters
    Type Name Description
    System.String path
    System.Nullable<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, Nullable<Int32>)

    Deletes a script by its name

    Declaration
    public void DeleteScript(string path, int? userId = null)
    Parameters
    Type Name Description
    System.String path

    Name incl. extension of the Script to delete

    System.Nullable<System.Int32> userId

    Optional id of the user deleting the script

    View Source

    DeleteScriptFolder(String)

    Deletes a folder for scripts

    Declaration
    public void DeleteScriptFolder(string folderPath)
    Parameters
    Type Name Description
    System.String folderPath
    View Source

    DeleteStylesheet(String, Nullable<Int32>)

    Deletes a stylesheet by its name

    Declaration
    public void DeleteStylesheet(string path, int? userId)
    Parameters
    Type Name Description
    System.String path

    Name incl. extension of the Stylesheet to delete

    System.Nullable<System.Int32> userId

    Optional id of the user deleting the stylesheet

    View Source

    DeleteStyleSheetFolder(String)

    Deletes a folder for style sheets

    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
    Type Description
    IPartialView
    View Source

    GetPartialViewFileContentStream(String)

    Gets the content of a partial view as a stream.

    Declaration
    public Stream GetPartialViewFileContentStream(string filepath)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the partial view.

    Returns
    Type Description
    Stream

    The content of the partial view.

    View Source

    GetPartialViewFileSize(String)

    Gets the size of a partial view.

    Declaration
    public 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.

    View Source

    GetPartialViewMacro(String)

    Declaration
    public IPartialView GetPartialViewMacro(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    IPartialView
    View Source

    GetPartialViewMacroFileContentStream(String)

    Gets the content of a macro partial view as a stream.

    Declaration
    public Stream GetPartialViewMacroFileContentStream(string filepath)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the macro partial view.

    Returns
    Type Description
    Stream

    The content of the macro partial view.

    View Source

    GetPartialViewMacroFileSize(String)

    Gets the size of a macro partial view.

    Declaration
    public 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.

    View Source

    GetPartialViewMacroSnippetContent(String)

    Declaration
    public string GetPartialViewMacroSnippetContent(string snippetName)
    Parameters
    Type Name Description
    System.String snippetName
    Returns
    Type Description
    System.String
    View Source

    GetPartialViews(String[])

    Declaration
    public IEnumerable<IPartialView> GetPartialViews(params string[] names)
    Parameters
    Type Name Description
    System.String[] names
    Returns
    Type Description
    IEnumerable<IPartialView>
    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
    IEnumerable<System.String>
    View Source

    GetScript(String)

    Gets a IScript object by its name

    Declaration
    public IScript GetScript(string name)
    Parameters
    Type Name Description
    System.String name

    Name of the script incl. extension

    Returns
    Type Description
    IScript

    A IScript object

    View Source

    GetScriptFileContentStream(String)

    Gets the content of a script file as a stream.

    Declaration
    public Stream GetScriptFileContentStream(string filepath)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the script.

    Returns
    Type Description
    Stream

    The content of the script file.

    View Source

    GetScriptFileSize(String)

    Gets the size of a script file.

    Declaration
    public 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.

    View Source

    GetScripts(String[])

    Gets a list of all IScript objects

    Declaration
    public IEnumerable<IScript> GetScripts(params string[] names)
    Parameters
    Type Name Description
    System.String[] names
    Returns
    Type Description
    IEnumerable<IScript>

    An enumerable list of IScript objects

    View Source

    GetStylesheet(String)

    Gets a IStylesheet object by its name

    Declaration
    public IStylesheet GetStylesheet(string path)
    Parameters
    Type Name Description
    System.String path

    Path of the stylesheet incl. extension

    Returns
    Type Description
    IStylesheet

    A IStylesheet object

    View Source

    GetStylesheetFileContentStream(String)

    Gets the content of a stylesheet as a stream.

    Declaration
    public Stream GetStylesheetFileContentStream(string filepath)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the stylesheet.

    Returns
    Type Description
    Stream

    The content of the stylesheet.

    View Source

    GetStylesheetFileSize(String)

    Gets the size of a stylesheet.

    Declaration
    public 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.

    View Source

    GetStylesheets(String[])

    Gets a list of all IStylesheet objects

    Declaration
    public IEnumerable<IStylesheet> GetStylesheets(params string[] paths)
    Parameters
    Type Name Description
    System.String[] paths
    Returns
    Type Description
    IEnumerable<IStylesheet>

    An enumerable list of IStylesheet objects

    View Source

    GetTemplate(Guid)

    Gets a ITemplate object by its guid identifier.

    Declaration
    public ITemplate GetTemplate(Guid id)
    Parameters
    Type Name Description
    Guid id

    The guid identifier of the template.

    Returns
    Type Description
    ITemplate

    The ITemplate object matching the identifier, or null.

    View Source

    GetTemplate(Int32)

    Gets a ITemplate object by its identifier.

    Declaration
    public ITemplate GetTemplate(int id)
    Parameters
    Type Name Description
    System.Int32 id

    The identifier of the template.

    Returns
    Type Description
    ITemplate

    The ITemplate object matching the identifier, or null.

    View Source

    GetTemplate(String)

    Gets a ITemplate object by its alias.

    Declaration
    public 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.

    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
    IEnumerable<ITemplate>
    View Source

    GetTemplateFileContentStream(String)

    Gets the content of a template as a stream.

    Declaration
    public Stream GetTemplateFileContentStream(string filepath)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the template.

    Returns
    Type Description
    Stream

    The content of the template.

    View Source

    GetTemplateFileSize(String)

    Gets the size of a template.

    Declaration
    public 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.

    View Source

    GetTemplates(Int32)

    Gets a list of all ITemplate objects

    Declaration
    public IEnumerable<ITemplate> GetTemplates(int masterTemplateId)
    Parameters
    Type Name Description
    System.Int32 masterTemplateId
    Returns
    Type Description
    IEnumerable<ITemplate>

    An enumerable list of ITemplate objects

    View Source

    GetTemplates(String[])

    Gets a list of all ITemplate objects

    Declaration
    public IEnumerable<ITemplate> GetTemplates(params string[] aliases)
    Parameters
    Type Name Description
    System.String[] aliases
    Returns
    Type Description
    IEnumerable<ITemplate>

    An enumerable list of ITemplate objects

    View Source

    SavePartialView(IPartialView, Nullable<Int32>)

    Declaration
    public Attempt<IPartialView> SavePartialView(IPartialView partialView, int? userId = null)
    Parameters
    Type Name Description
    IPartialView partialView
    System.Nullable<System.Int32> userId
    Returns
    Type Description
    Attempt<IPartialView>
    View Source

    SavePartialViewMacro(IPartialView, Nullable<Int32>)

    Declaration
    public Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int? userId = null)
    Parameters
    Type Name Description
    IPartialView partialView
    System.Nullable<System.Int32> userId
    Returns
    Type Description
    Attempt<IPartialView>
    View Source

    SaveScript(IScript, Nullable<Int32>)

    Saves a Script

    Declaration
    public void SaveScript(IScript script, int? userId)
    Parameters
    Type Name Description
    IScript script

    IScript to save

    System.Nullable<System.Int32> userId

    Optional id of the user saving the script

    View Source

    SaveStylesheet(IStylesheet, Nullable<Int32>)

    Saves a IStylesheet

    Declaration
    public void SaveStylesheet(IStylesheet stylesheet, int? userId = null)
    Parameters
    Type Name Description
    IStylesheet stylesheet

    IStylesheet to save

    System.Nullable<System.Int32> userId

    Optional id of the user saving the stylesheet

    View Source

    SaveTemplate(IEnumerable<ITemplate>, Int32)

    Saves a collection of Template objects

    Declaration
    public void SaveTemplate(IEnumerable<ITemplate> templates, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<ITemplate> templates

    List of Template to save

    System.Int32 userId

    Optional id of the user

    View Source

    SaveTemplate(ITemplate, Int32)

    Saves a Template

    Declaration
    public void SaveTemplate(ITemplate template, int userId = -1)
    Parameters
    Type Name Description
    ITemplate template

    Template to save

    System.Int32 userId
    View Source

    SetPartialViewFileContent(String, Stream)

    Sets the content of a partial view.

    Declaration
    public void SetPartialViewFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the partial view.

    Stream content

    The content of the partial view.

    View Source

    SetPartialViewMacroFileContent(String, Stream)

    Sets the content of a macro partial view.

    Declaration
    public void SetPartialViewMacroFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the macro partial view.

    Stream content

    The content of the macro partial view.

    View Source

    SetScriptFileContent(String, Stream)

    Sets the content of a script file.

    Declaration
    public void SetScriptFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the script.

    Stream content

    The content of the script file.

    View Source

    SetStylesheetFileContent(String, Stream)

    Sets the content of a stylesheet.

    Declaration
    public void SetStylesheetFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the stylesheet.

    Stream content

    The content of the stylesheet.

    View Source

    SetTemplateFileContent(String, Stream)

    Sets the content of a template.

    Declaration
    public void SetTemplateFileContent(string filepath, Stream content)
    Parameters
    Type Name Description
    System.String filepath

    The filesystem path to the template.

    Stream content

    The content of the template.

    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • FileService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IStylesheetRepository, IScriptRepository, ITemplateRepository, IPartialViewRepository, IPartialViewMacroRepository, IAuditRepository, IShortStringHelper, IOptions<GlobalSettings>, IHostingEnvironment)
    • Methods
      • CreatePartialView(IPartialView, String, Nullable<Int32>)
      • CreatePartialViewFolder(String)
      • CreatePartialViewMacro(IPartialView, String, Nullable<Int32>)
      • CreatePartialViewMacroFolder(String)
      • CreateScriptFolder(String)
      • CreateStyleSheetFolder(String)
      • CreateTemplateForContentType(String, String, Int32)
      • CreateTemplateWithIdentity(String, String, String, ITemplate, Int32)
      • DeletePartialView(String, Nullable<Int32>)
      • DeletePartialViewFolder(String)
      • DeletePartialViewMacro(String, Nullable<Int32>)
      • DeletePartialViewMacroFolder(String)
      • DeleteScript(String, Nullable<Int32>)
      • DeleteScriptFolder(String)
      • DeleteStylesheet(String, Nullable<Int32>)
      • DeleteStyleSheetFolder(String)
      • DeleteTemplate(String, Int32)
      • GetPartialView(String)
      • GetPartialViewFileContentStream(String)
      • GetPartialViewFileSize(String)
      • GetPartialViewMacro(String)
      • GetPartialViewMacroFileContentStream(String)
      • GetPartialViewMacroFileSize(String)
      • GetPartialViewMacroSnippetContent(String)
      • GetPartialViews(String[])
      • GetPartialViewSnippetContent(String)
      • GetPartialViewSnippetNames(String[])
      • GetScript(String)
      • GetScriptFileContentStream(String)
      • GetScriptFileSize(String)
      • GetScripts(String[])
      • GetStylesheet(String)
      • GetStylesheetFileContentStream(String)
      • GetStylesheetFileSize(String)
      • GetStylesheets(String[])
      • GetTemplate(Guid)
      • GetTemplate(Int32)
      • GetTemplate(String)
      • GetTemplateDescendants(Int32)
      • GetTemplateFileContentStream(String)
      • GetTemplateFileSize(String)
      • GetTemplates(Int32)
      • GetTemplates(String[])
      • SavePartialView(IPartialView, Nullable<Int32>)
      • SavePartialViewMacro(IPartialView, Nullable<Int32>)
      • SaveScript(IScript, Nullable<Int32>)
      • SaveStylesheet(IStylesheet, Nullable<Int32>)
      • SaveTemplate(IEnumerable<ITemplate>, Int32)
      • SaveTemplate(ITemplate, Int32)
      • SetPartialViewFileContent(String, Stream)
      • SetPartialViewMacroFileContent(String, Stream)
      • SetScriptFileContent(String, Stream)
      • SetStylesheetFileContent(String, Stream)
      • SetTemplateFileContent(String, Stream)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX