当前位置: 首页>>代码示例>>C#>>正文


C# Core.ContentReference类代码示例

本文整理汇总了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;
 }
开发者ID:ojarsb,项目名称:EpiRatingAlloySite,代码行数:7,代码来源:UrlHelpers.cs

示例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;

        }
开发者ID:BVNetwork,项目名称:Attend,代码行数:26,代码来源:Folders.cs

示例3: GetLoginUrl

 private string GetLoginUrl(ContentReference returnToContentLink)
 {
     return string.Format(
         "{0}?ReturnUrl={1}",
         FormsAuthentication.LoginUrl,
         _urlResolver.GetUrl(returnToContentLink));
 }
开发者ID:nimeshjm,项目名称:EPiServer-sample,代码行数:7,代码来源:PageViewContextFactory.cs

示例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;
 }
开发者ID:BVNetwork,项目名称:Attend,代码行数:7,代码来源:InvoiceList.ascx.cs

示例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
            };
        }
开发者ID:rbrunge,项目名称:phony-club-denmark,代码行数:26,代码来源:PageViewContextFactory.cs

示例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;
 }
开发者ID:pontushagman,项目名称:Attend,代码行数:7,代码来源:AttendSessionEngine.cs

示例8: ConstructDateContainer

        public IDateContainer ConstructDateContainer(ContentReference parent, string name, DateTime startPublish)
        {
            var dateContainer = this.ConstructDateContainerPage<BlogListPage>(parent, name, startPublish);
            dateContainer.Heading = name;

            return dateContainer;
        }
开发者ID:jeroenslor,项目名称:epi-alloy-demo-kit,代码行数:7,代码来源:BlogItemPage.cs

示例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;
 }
开发者ID:Geta,项目名称:EPi.Extensions,代码行数:13,代码来源:IContentReferenceCache.cs

示例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);
        }
开发者ID:adrian18hd,项目名称:Quicksilver,代码行数:7,代码来源:MailService.cs

示例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());
        }
开发者ID:dnasir,项目名称:EPi.Extensions,代码行数:46,代码来源:HtmlHelperExtensions.cs

示例12: GetChildrenOrganizer

        private IOrganizeChildren GetChildrenOrganizer(ContentReference pageLink)
        {
            if (ContentReference.IsNullOrEmpty(pageLink))
                return null;

            return GetPage(pageLink) as IOrganizeChildren;
        }
开发者ID:javafun,项目名称:PageStructureBuilder,代码行数:7,代码来源:PageStructureBuilderModule.cs

示例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))
                };
        }
开发者ID:tomeo,项目名称:Episerver-Master-Class,代码行数:26,代码来源:PageViewContextFactory.cs

示例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 });
        }
开发者ID:adagetech,项目名称:EPiServer-Cordova-Demo,代码行数:25,代码来源:MobilePageDataController.cs


注:本文中的EPiServer.Core.ContentReference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。