Search Results for

    Show / Hide Table of Contents
    View Source

    Class ContentExtensions

    Inheritance
    System.Object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Core.dll
    Syntax
    public static class ContentExtensions

    Methods

    View Source

    GetAncestorIds(IContent)

    Gets a collection containing the ids of all ancestors.

    Declaration
    public static IEnumerable<int>? GetAncestorIds(this IContent content)
    Parameters
    Type Name Description
    IContent content

    IContent to retrieve ancestors for

    Returns
    Type Description
    System.Nullable<IEnumerable<System.Int32>>

    An Enumerable list of integer ids

    View Source

    GetCreatorProfile(IContentBase, IUserService)

    Gets the IProfile for the Creator of this content item.

    Declaration
    public static IProfile GetCreatorProfile(this IContentBase content, IUserService userService)
    Parameters
    Type Name Description
    IContentBase content
    IUserService userService
    Returns
    Type Description
    IProfile
    View Source

    GetCreatorProfile(IMedia, IUserService)

    Gets the IProfile for the Creator of this media item.

    Declaration
    public static IProfile GetCreatorProfile(this IMedia media, IUserService userService)
    Parameters
    Type Name Description
    IMedia media
    IUserService userService
    Returns
    Type Description
    IProfile
    View Source

    GetDirtyUserProperties(IContentBase)

    Declaration
    public static IEnumerable<string> GetDirtyUserProperties(this IContentBase entity)
    Parameters
    Type Name Description
    IContentBase entity
    Returns
    Type Description
    IEnumerable<System.String>
    View Source

    GetNonGroupedProperties(IContentBase)

    Returns properties that do not belong to a group

    Declaration
    public static IEnumerable<IProperty> GetNonGroupedProperties(this IContentBase content)
    Parameters
    Type Name Description
    IContentBase content
    Returns
    Type Description
    IEnumerable<IProperty>
    View Source

    GetPropertiesByEditor(IContentBase, String)

    Returns all properties based on the editorAlias

    Declaration
    public static IEnumerable<IProperty> GetPropertiesByEditor(this IContentBase content, string editorAlias)
    Parameters
    Type Name Description
    IContentBase content
    System.String editorAlias
    Returns
    Type Description
    IEnumerable<IProperty>
    View Source

    GetPropertiesForGroup(IContentBase, PropertyGroup)

    Returns the Property object for the given property group

    Declaration
    public static IEnumerable<IProperty> GetPropertiesForGroup(this IContentBase content, PropertyGroup propertyGroup)
    Parameters
    Type Name Description
    IContentBase content
    PropertyGroup propertyGroup
    Returns
    Type Description
    IEnumerable<IProperty>
    View Source

    GetStatus(IContent, ContentScheduleCollection, String)

    Gets the current status of the Content

    Declaration
    public static ContentStatus GetStatus(this IContent content, ContentScheduleCollection contentSchedule, string culture = null)
    Parameters
    Type Name Description
    IContent content
    ContentScheduleCollection contentSchedule
    System.String culture
    Returns
    Type Description
    ContentStatus
    View Source

    GetWriterProfile(IContent, IUserService)

    Gets the IProfile for the Writer of this content.

    Declaration
    public static IProfile GetWriterProfile(this IContent content, IUserService userService)
    Parameters
    Type Name Description
    IContent content
    IUserService userService
    Returns
    Type Description
    IProfile
    View Source

    GetWriterProfile(IMedia, IUserService)

    Gets the IProfile for the Writer of this content.

    Declaration
    public static IProfile GetWriterProfile(this IMedia content, IUserService userService)
    Parameters
    Type Name Description
    IMedia content
    IUserService userService
    Returns
    Type Description
    IProfile
    View Source

    IsAnyUserPropertyDirty(IContentBase)

    Declaration
    public static bool IsAnyUserPropertyDirty(this IContentBase entity)
    Parameters
    Type Name Description
    IContentBase entity
    Returns
    Type Description
    System.Boolean
    View Source

    IsMoving(IContentBase)

    Declaration
    public static bool IsMoving(this IContentBase entity)
    Parameters
    Type Name Description
    IContentBase entity
    Returns
    Type Description
    System.Boolean
    View Source

    SanitizeEntityPropertiesForXmlStorage(IContentBase)

    Removes characters that are not valid XML characters from all entity properties of type string. See: http://stackoverflow.com/a/961504/5018

    Declaration
    public static void SanitizeEntityPropertiesForXmlStorage(this IContentBase entity)
    Parameters
    Type Name Description
    IContentBase entity
    Remarks

    If this is not done then the xml cache can get corrupt and it will throw YSODs upon reading it.

    View Source

    SetValue(IContentBase, MediaFileManager, MediaUrlGeneratorCollection, IShortStringHelper, IContentTypeBaseServiceProvider, String, String, Stream, String, String)

    Sets the posted file value of a property.

    Declaration
    public static void SetValue(this IContentBase content, MediaFileManager mediaFileManager, MediaUrlGeneratorCollection mediaUrlGenerators, IShortStringHelper shortStringHelper, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, string propertyTypeAlias, string filename, Stream filestream, string culture = null, string segment = null)
    Parameters
    Type Name Description
    IContentBase content
    MediaFileManager mediaFileManager
    MediaUrlGeneratorCollection mediaUrlGenerators
    IShortStringHelper shortStringHelper
    IContentTypeBaseServiceProvider contentTypeBaseServiceProvider
    System.String propertyTypeAlias
    System.String filename
    Stream filestream
    System.String culture
    System.String segment
    View Source

    StoreFile(IContentBase, MediaFileManager, IContentTypeBaseServiceProvider, String, String, Stream, String)

    Stores a file.

    Declaration
    public static string StoreFile(this IContentBase content, MediaFileManager mediaFileManager, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, string propertyTypeAlias, string filename, Stream filestream, string filepath)
    Parameters
    Type Name Description
    IContentBase content

    IContentBaseA content item.

    MediaFileManager mediaFileManager

    The media file manager.

    IContentTypeBaseServiceProvider contentTypeBaseServiceProvider

    The content type base service provider.

    System.String propertyTypeAlias

    The property alias.

    System.String filename

    The name of the file.

    Stream filestream

    A stream containing the file data.

    System.String filepath

    The original file path, if any.

    Returns
    Type Description
    System.String

    The path to the file, relative to the media filesystem.

    Remarks

    Does NOT set the property value, so one should probably store the file and then do something alike: property.Value = MediaHelper.FileSystem.GetUrl(filepath).

    The original file path is used, in the old media file path scheme, to try and reuse the "folder number" that was assigned to the previous file referenced by the property, if any.

    View Source

    ToDeepXml(IContent, IEntityXmlSerializer)

    Creates the full xml representation for the IContent object and all of it's descendants

    Declaration
    public static XElement ToDeepXml(this IContent content, IEntityXmlSerializer serializer)
    Parameters
    Type Name Description
    IContent content

    IContent to generate xml for

    IEntityXmlSerializer serializer
    Returns
    Type Description
    System.Xml.Linq.XElement

    Xml representation of the passed in IContent

    View Source

    ToXml(IContent, IEntityXmlSerializer)

    Creates the xml representation for the IContent object

    Declaration
    public static XElement ToXml(this IContent content, IEntityXmlSerializer serializer)
    Parameters
    Type Name Description
    IContent content

    IContent to generate xml for

    IEntityXmlSerializer serializer
    Returns
    Type Description
    System.Xml.Linq.XElement

    Xml representation of the passed in IContent

    View Source

    ToXml(IMedia, IEntityXmlSerializer)

    Creates the xml representation for the IMedia object

    Declaration
    public static XElement ToXml(this IMedia media, IEntityXmlSerializer serializer)
    Parameters
    Type Name Description
    IMedia media

    IContent to generate xml for

    IEntityXmlSerializer serializer
    Returns
    Type Description
    System.Xml.Linq.XElement

    Xml representation of the passed in IContent

    View Source

    ToXml(IMember, IEntityXmlSerializer)

    Creates the xml representation for the IMember object

    Declaration
    public static XElement ToXml(this IMember member, IEntityXmlSerializer serializer)
    Parameters
    Type Name Description
    IMember member

    IMember to generate xml for

    IEntityXmlSerializer serializer
    Returns
    Type Description
    System.Xml.Linq.XElement

    Xml representation of the passed in IContent

    View Source

    TryGetMediaPath(IContentBase, String, MediaUrlGeneratorCollection, out String, String, String)

    Returns the path to a media item stored in a property if the property editor is IMediaUrlGenerator

    Declaration
    public static bool TryGetMediaPath(this IContentBase content, string propertyTypeAlias, MediaUrlGeneratorCollection mediaUrlGenerators, out string mediaFilePath, string culture = null, string segment = null)
    Parameters
    Type Name Description
    IContentBase content
    System.String propertyTypeAlias
    MediaUrlGeneratorCollection mediaUrlGenerators
    System.String mediaFilePath
    System.String culture
    System.String segment
    Returns
    Type Description
    System.Boolean

    True if the file path can be resolved and the property is IMediaUrlGenerator

    View Source

    WasAnyUserPropertyDirty(IContentBase)

    Declaration
    public static bool WasAnyUserPropertyDirty(this IContentBase entity)
    Parameters
    Type Name Description
    IContentBase entity
    Returns
    Type Description
    System.Boolean
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX