本文整理汇总了C#中EPiServer.Core.ContentReference类的典型用法代码示例。如果您正苦于以下问题:C# ContentReference类的具体用法?C# ContentReference怎么用?C# ContentReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentReference类属于EPiServer.Core命名空间,在下文中一共展示了ContentReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPageRoute
public static RouteValueDictionary GetPageRoute(this RequestContext requestContext, ContentReference contentLink)
{
var values = new RouteValueDictionary();
values[RoutingConstants.NodeKey] = contentLink;
values[RoutingConstants.LanguageKey] = ContentLanguage.PreferredCulture.Name;
return values;
}
示例2: GetOrCreateEventFolder
public static ContentFolder GetOrCreateEventFolder(ContentReference EventPageBase, string folderName)
{
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var contentAssetHelper = ServiceLocator.Current.GetInstance<ContentAssetHelper>();
ContentFolder folder = null;
var assetsFolder = contentAssetHelper.GetOrCreateAssetFolder(EventPageBase);
var folders = contentRepository.GetChildren<ContentFolder>(assetsFolder.ContentLink);
foreach (ContentFolder cf in folders)
{
if (cf.Name == folderName)
folder = cf;
}
if (folder == null)
{
folder = contentRepository.GetDefault<ContentFolder>(assetsFolder.ContentLink);
folder.Name = folderName;
contentRepository.Save(folder, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
}
return folder;
}
示例3: GetLoginUrl
private string GetLoginUrl(ContentReference returnToContentLink)
{
return string.Format(
"{0}?ReturnUrl={1}",
FormsAuthentication.LoginUrl,
_urlResolver.GetUrl(returnToContentLink));
}
示例4: ContentReference
public void CompareTo_IfTheIdsAreEqualAndTheInstanceWorkIdIsGreaterThanTheObjectParameterWorkId_ShouldReturnMinusOne()
{
ContentReference contentReferenceToCompareWith = new ContentReference(_random.Next(0, int.MaxValue), _random.Next(0, int.MaxValue - 1));
ContentReference contentReference = contentReferenceToCompareWith.Copy();
contentReference.WorkID = contentReference.WorkID + 1;
Assert.AreEqual(-1, contentReference.CompareTo(contentReferenceToCompareWith));
}
开发者ID:HansKindberg-Net,项目名称:HansKindberg-EPiServer-CMS7-Abstractions,代码行数:7,代码来源:ContentReferenceTest.cs
示例5: GetCourseName
protected string GetCourseName(ContentReference EventPageBase)
{
var currentEvent = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>().Get<BVNetwork.Attend.Models.Pages.EventPageBase>(EventPageBase);
if (currentEvent == null)
return string.Empty;
return currentEvent.Name;
}
示例6: CreateLayoutModel
public virtual LayoutModel CreateLayoutModel(ContentReference currentContentLink, RequestContext requestContext)
{
if (ContentReference.StartPage.ID == 0)
return null;
var startPage = _contentLoader.Get<StartPage>(ContentReference.StartPage);
return new LayoutModel
{
// MenuTopPages = startPage.MenuTopPageLinks,
SearchPageRouteValues = requestContext.GetPageRoute(startPage.SearchPageLink),
SearchPageLink = startPage.SearchPageLink,
// header
SearchLabel = startPage.SearchLabel,
SearchPlaceholderLabel = startPage.SearchPlaceholderLabel,
LogoAlternativeText = startPage.LogoAlternativeText,
// footer
PhoneNumber = startPage.PhoneNumber,
PhoneNumberLabel = startPage.PhoneNumberLabel,
MailAddress = startPage.MailAddress,
Address = startPage.Address,
CvrNumber = startPage.CvrNumber
};
}
示例7: GetSessions
public static List<SessionBlock> GetSessions(ContentReference EventPageBase)
{
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
List<SessionBlock> sessions = contentRepository.GetChildren<SessionBlock>(GetOrCreateSessionFolder(EventPageBase).ContentLink, new NullLanguageSelector()).ToList<SessionBlock>();
sessions.Sort(delegate(SessionBlock s1, SessionBlock s2) { return s1.Start.CompareTo(s2.Start); });
return sessions;
}
示例8: ConstructDateContainer
public IDateContainer ConstructDateContainer(ContentReference parent, string name, DateTime startPublish)
{
var dateContainer = this.ConstructDateContainerPage<BlogListPage>(parent, name, startPublish);
dateContainer.Heading = name;
return dateContainer;
}
示例9: CacheKey
/// <summary>
/// Instantiates new CacheKey.
/// </summary>
/// <param name="type">Singleton page's type.</param>
/// <param name="parentLink">A root page's content reference under which singleton page gets searched.</param>
/// <exception cref="ArgumentNullException"></exception>
public CacheKey(Type type, ContentReference parentLink)
{
if (type == null) throw new ArgumentNullException(nameof(type));
if (parentLink == null) throw new ArgumentNullException(nameof(parentLink));
Type = type;
ParentLink = parentLink;
}
示例10: Send
public void Send(ContentReference mailReference, NameValueCollection nameValueCollection, string toEmail, string language)
{
var body = GetHtmlBodyForMail(mailReference, nameValueCollection, language);
var mailPage = _contentLoader.Get<MailBasePage>(mailReference);
Send(mailPage.MailTitle, body, toEmail);
}
示例11: MenuList
/// <summary>
/// Returns an element for each child page of the rootLink using the itemTemplate.
/// </summary>
/// <param name="helper">The html helper in whose context the list should be created</param>
/// <param name="rootLink">A reference to the root whose children should be listed</param>
/// <param name="itemTemplate">
/// A template for each page which will be used to produce the return value. Can be either a
/// delegate or a Razor helper.
/// </param>
/// <param name="includeRoot">Whether an element for the root page should be returned</param>
/// <param name="requireVisibleInMenu">
/// Wether pages that do not have the "Display in navigation" checkbox checked should be
/// excluded
/// </param>
/// <param name="requirePageTemplate">Whether page that do not have a template (i.e. container pages) should be excluded</param>
/// <remarks>
/// Filter by access rights and publication status.
/// </remarks>
public static IHtmlString MenuList(this HtmlHelper helper, ContentReference rootLink, Func<MenuItem, HelperResult> itemTemplate = null,
bool includeRoot = false, bool requireVisibleInMenu = true, bool requirePageTemplate = true)
{
itemTemplate = itemTemplate ?? GetDefaultItemTemplate(helper);
var currentContentLink = helper.ViewContext.RequestContext.GetContentLink();
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
Func<IEnumerable<PageData>, IEnumerable<PageData>> filter = pages => pages.FilterForDisplay(requirePageTemplate, requireVisibleInMenu);
var menuItems = contentLoader.GetChildren<PageData>(rootLink)
.FilterForDisplay(requirePageTemplate, requireVisibleInMenu)
.Select(x => CreateMenuItem(x, currentContentLink, rootLink, contentLoader, filter))
.ToList();
if (includeRoot)
{
menuItems.Insert(0, CreateMenuItem(contentLoader.Get<PageData>(rootLink), currentContentLink, rootLink, contentLoader, filter));
}
var buffer = new StringBuilder();
var writer = new StringWriter(buffer);
foreach (var menuItem in menuItems)
{
itemTemplate(menuItem).WriteTo(writer);
}
return new MvcHtmlString(buffer.ToString());
}
示例12: GetChildrenOrganizer
private IOrganizeChildren GetChildrenOrganizer(ContentReference pageLink)
{
if (ContentReference.IsNullOrEmpty(pageLink))
return null;
return GetPage(pageLink) as IOrganizeChildren;
}
示例13: CompareTo_IfTheInstanceIdIsLessThanTheObjectParameterId_ShouldReturnMinusOne
public void CompareTo_IfTheInstanceIdIsLessThanTheObjectParameterId_ShouldReturnMinusOne()
{
ContentReference contentReferenceToCompareWith = new ContentReference(_random.Next(1, int.MaxValue));
ContentReference contentReference = contentReferenceToCompareWith.Copy();
contentReference.ID = contentReference.ID - 1;
Assert.AreEqual(-1, contentReference.CompareTo(contentReferenceToCompareWith));
}
开发者ID:HansKindberg-Net,项目名称:HansKindberg-EPiServer-CMS7-Abstractions,代码行数:7,代码来源:ContentReferenceTest.cs
示例14: CreateLayoutModel
public virtual LayoutModel CreateLayoutModel(ContentReference currentContentLink, RequestContext requestContext)
{
var startPageContentLink = SiteDefinition.Current.StartPage;
// Use the content link with version information when editing the startpage,
// otherwise the published version will be used when rendering the props below.
if (currentContentLink.CompareToIgnoreWorkID(startPageContentLink))
{
startPageContentLink = currentContentLink;
}
var startPage = _contentLoader.Get<StartPage>(startPageContentLink);
return new LayoutModel
{
Logotype = startPage.SiteLogotype,
LogotypeLinkUrl = new MvcHtmlString(_urlResolver.GetUrl(SiteDefinition.Current.StartPage)),
ProductPages = startPage.ProductPageLinks,
CompanyInformationPages = startPage.CompanyInformationPageLinks,
NewsPages = startPage.NewsPageLinks,
CustomerZonePages = startPage.CustomerZonePageLinks,
LoggedIn = requestContext.HttpContext.User.Identity.IsAuthenticated,
LoginUrl = new MvcHtmlString(GetLoginUrl(currentContentLink)),
SearchActionUrl = new MvcHtmlString(EPiServer.Web.Routing.UrlResolver.Current.GetUrl(startPage.SearchPageLink))
};
}
示例15: Get
public IHttpActionResult Get(int id)
{
var reference = new ContentReference(id);
if (ContentReference.IsNullOrEmpty(reference))
{
var message = new HttpResponseMessage();
message.StatusCode = HttpStatusCode.NotFound;
message.ReasonPhrase = String.Format("Did not find page content with id {0}", id);
throw new HttpResponseException(message);
}
var pageData = this._contentLoader.Get<PageData>(reference) as MobilePageData;
if (pageData == null)
{
var message = new HttpResponseMessage();
message.StatusCode = HttpStatusCode.Forbidden;
message.ReasonPhrase = String.Format("Page with id {0} was not of type {1}", id, typeof(MobilePageData).Name);
throw new HttpResponseException(message);
}
var epiTitle = pageData.Title;
var epiContent = PreProcess(pageData.Content);
return Ok(new { title = epiTitle, content = epiContent });
}