本文整理汇总了C#中System.Web.Mvc.UrlHelper.ItemDisplayUrl方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.ItemDisplayUrl方法的具体用法?C# UrlHelper.ItemDisplayUrl怎么用?C# UrlHelper.ItemDisplayUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.UrlHelper
的用法示例。
在下文中一共展示了UrlHelper.ItemDisplayUrl方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Applies
public bool Applies(ShoppingCartQuantityProduct quantityProduct, IEnumerable<ShoppingCartQuantityProduct> cartProducts) {
if (DiscountPart == null) return false;
var now = _clock.UtcNow;
if (DiscountPart.StartDate != null && DiscountPart.StartDate > now) return false;
if (DiscountPart.EndDate != null && DiscountPart.EndDate < now) return false;
if (DiscountPart.StartQuantity != null &&
DiscountPart.StartQuantity > quantityProduct.Quantity)
return false;
if (DiscountPart.EndQuantity != null &&
DiscountPart.EndQuantity < quantityProduct.Quantity)
return false;
if (!string.IsNullOrWhiteSpace(DiscountPart.Pattern)) {
string path;
if (DiscountPart.DisplayUrlResolver != null) {
path = DiscountPart.DisplayUrlResolver(quantityProduct.Product);
}
else {
var urlHelper = new UrlHelper(_wca.GetContext().HttpContext.Request.RequestContext);
path = urlHelper.ItemDisplayUrl(quantityProduct.Product);
}
if (!path.StartsWith(DiscountPart.Pattern, StringComparison.OrdinalIgnoreCase))
return false;
}
if (DiscountPart.Roles.Any()) {
var user = _wca.GetContext().CurrentUser;
if (user.Has<UserRolesPart>()) {
var roles = user.As<UserRolesPart>().Roles;
if (!roles.Any(r => DiscountPart.Roles.Contains(r))) return false;
}
}
return true;
}
示例2: Display
protected override void Display(ConnectorDisplayContext model, dynamic shape, ModelShapeContext context)
{
if (context.Paradigms.Has("Navigation")) {
model.SocketDisplayContext.Paradigms.Add("NavigationChild");
context.Paradigms.Add("NavigationChild");
bool isCurrent = false;
string rightUrl = "";
// HACK: Better than before but still a bit hackish
if (model.Right.Content != null) {
// TODO: Make absolute
var url = new UrlHelper(_requestContext);
rightUrl = url.ItemDisplayUrl(model.Right.Content);
// Check if it's a current page or parent
var work = _workContextAccessor.GetContext();
string modelUrl = rightUrl.Replace(work.HttpContext.Request.ApplicationPath, string.Empty).TrimEnd('/').ToUpperInvariant();
isCurrent = ((!string.IsNullOrEmpty(modelUrl) && RequestUrl.StartsWith(modelUrl)) || RequestUrl == modelUrl);
// Add Current paradigm so we can modify display
if (isCurrent) {
context.Paradigms.Add("Current");
}
else {
context.Paradigms.Remove("Current");
}
}
(shape.Metadata as ShapeMetadata).OnDisplaying(displaying => {
displaying.Shape.IsCurrent = isCurrent;
// Store display url
displaying.Shape.Url = rightUrl;
});
}
}
示例3: GetItemDisplayUrl
protected string GetItemDisplayUrl(IContent item)
{
// Was particularly complex working out how to do this :)
var helper = new UrlHelper(new RequestContext(
new HttpContextWrapper(HttpContext.Current),
new RouteData()), RouteTable.Routes);
var siteUrl = helper.RequestContext.HttpContext.Request.ToRootUrlString();
return siteUrl + helper.ItemDisplayUrl(item);
}
示例4: Evaluate
public void Evaluate(EvaluateContext context) {
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
context.For<IContent>("Content")
.Token("PostMessage", content => content.As<PostPart>().Text)
.Chain("PostMessage", "Text", content => content.As<PostPart>().Text)
//viagra-test-123 is used by https://akismet.com/ to flag a subsmission as spam for testing purposes
.Token("PostAuthor", content => content.As<CommonPart>().Owner.UserName) //content => { return "viagra-test-123"; })
.Chain("PostAuthor", "Text", content => content.As<CommonPart>().Owner.UserName) //content => { return "viagra-test-123"; })
.Token("PostAuthorEmail", content => content.As<CommonPart>().Owner.Email)
.Chain("PostAuthorEmail", "Text", content => content.As<CommonPart>().Owner.Email)
.Token("PostUserIp", content => content.As<PostPart>().IP)
.Token("PostPermalink", content => urlHelper.MakeAbsolute(urlHelper.ItemDisplayUrl(content.As<PostPart>().ContentItem)))
.Token("PostFrontPage", content => urlHelper.MakeAbsolute(urlHelper.ItemDisplayUrl(content.As<PostPart>().ThreadPart.ForumPart.ForumCategoryPart.ForumsHomePagePart)))
;
}
示例5: CacheSettingsPartHandler
public CacheSettingsPartHandler(
IRepository<CacheSettingsPartRecord> repository,
IWorkContextAccessor workContextAccessor,
ICacheService cacheService,
RequestContext requestContext)
{
_workContextAccessor = workContextAccessor;
_cacheService = cacheService;
_requestContext = requestContext;
Filters.Add(new ActivatingFilter<CacheSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository));
// initializing default cache settings values
OnInitializing<CacheSettingsPart>((context, part) => { part.DefaultCacheDuration = 300; });
// evict modified routable content when updated
OnPublished<IContent>(
(context, part) => {
// list of cache keys to evict
var evict = new List<CacheItem>();
var workContext = _workContextAccessor.GetContext();
Action<IContent> findAndEvict = p => {
foreach (var cacheItem in _cacheService.GetCacheItems()) {
var urlHelper = new UrlHelper(_requestContext);
if (String.Equals(cacheItem.Url, VirtualPathUtility.ToAbsolute("~/" + urlHelper.ItemDisplayUrl(p)), StringComparison.OrdinalIgnoreCase)) {
evict.Add(cacheItem);
}
}
};
findAndEvict(part);
// search the cache for containers too
var commonPart = part.As<CommonPart>();
if (commonPart != null) {
if (commonPart.Container != null) {
findAndEvict(commonPart.Container);
}
}
// remove all content to evict
foreach (var cacheItem in evict) {
_cacheService.Evict(cacheItem.CacheKey, workContext.HttpContext);
}
});
}
示例6: TaxonomyItem
public void TaxonomyItem(dynamic Display, dynamic Shape) {
using (Display.ViewDataContainer.Model.Node(Shape.ContentPart.Name)) {
Shape.Metadata.Alternates.Clear();
Shape.Metadata.Type = "TaxonomyItemLink";
UrlHelper urlHelper = new UrlHelper(Display.ViewContext.RequestContext);
Display.ViewDataContainer.Model.Id = Shape.ContentPart.Id;
Display.ViewDataContainer.Model.Title = Shape.ContentPart.Name;
Display.ViewDataContainer.Model.DisplayUrl = urlHelper.ItemDisplayUrl((IContent)Shape.ContentPart.ContentItem);
/* render child elements */
using (Display.ViewDataContainer.Model.List("Terms")) {
if (((IEnumerable<dynamic>)Shape.Items).Any()) {
DisplayChildren(Display, Shape);
}
}
}
}
示例7: Parts_Common_Metadata_Summary
public void Parts_Common_Metadata_Summary(dynamic Display, dynamic Shape) {
string DisplayUrl = null;
if (((IContent)Shape.ContentPart).Is<IAliasAspect>()) {
UrlHelper urlHelper = new UrlHelper(Display.ViewContext.RequestContext);
DisplayUrl = urlHelper.ItemDisplayUrl((IContent)Shape.ContentPart.ContentItem);
}
Display.ViewDataContainer.Model.Id = Shape.ContentPart.Id;
Display.ViewDataContainer.Model.DisplayUrl = DisplayUrl;
Display.ViewDataContainer.Model.CreatedUtc = Shape.ContentPart.CreatedUtc;
Display.ViewDataContainer.Model.PublishedUtc = Shape.ContentPart.PublishedUtc;
}
示例8: CreatePackage
private XElement CreatePackage(PackagePart package, UrlHelper urlHelper, string baseUrl, IShapeDisplay shapeDisplay, dynamic shapeFactory) {
var element = new XElement(atomns + "entry");
dynamic content = package.ContentItem;
string iconUrl = null;
if (content.Package.Icon != null && content.Package.Icon.FirstMediaUrl != null) {
iconUrl = (string)content.Package.Icon.FirstMediaUrl;
iconUrl = shapeDisplay.Display(shapeFactory.ResizeMediaUrl(Path: iconUrl, Width: 64, Heigth: 64));
}
var screenshots = new XElement(atomns + "link",
new XAttribute("rel", "http://schemas.microsoft.com/ado/2007/08/dataservices/related/Screenshots"),
new XAttribute("type", "application/atom+xml;type=feed"),
new XAttribute("title", "Screenshots"),
new XAttribute("href", "Packages(Id='" + package.PackageId + "')/Screenshots")
);
foreach (var media in (IEnumerable<dynamic>)content.Package.Screenshots.MediaParts) {
string screenshotUrl = media.MediaUrl;
screenshotUrl = shapeDisplay.Display(shapeFactory.ResizeMediaUrl(Path: screenshotUrl, Width: 164, Heigth: 128));
screenshots.Add(
new XElement(mns + "inline",
new XElement(atomns + "feed",
new XElement(atomns + "title", "Screenshots", new XAttribute("type", "text")),
new XElement(atomns + "id", urlHelper.MakeAbsolute("/FeedService/Packages(Id='" + package.PackageId + "')/Screenshots", baseUrl)),
new XElement(atomns + "link",
new XAttribute("rel", "self"),
new XAttribute("title", "Screenshots"),
new XAttribute("href", "Packages(Id='" + package.PackageId + "')/Screenshots")
),
new XElement(atomns + "entry",
new XElement(atomns + "id", urlHelper.MakeAbsolute("/FeedService.svc/Screenshots(" + (string)media.Id.ToString() + ")", baseUrl)),
new XElement(atomns + "title", media.ContentItem.TitlePart.Title, new XAttribute("type", "text")),
new XElement(atomns + "content", new XAttribute("type", "application/xml"),
new XElement(mns + "properties",
new XElement(dns + "Id", media.ContentItem.Id, new XAttribute(mns + "type", "Edm.Int32")),
new XElement(dns + "PublishedPackageId", package.PackageId),
new XElement(dns + "ScreenshotUri", urlHelper.MakeAbsolute(screenshotUrl, baseUrl)),
new XElement(dns + "Caption", new XAttribute(mns + "null", "true"))
)
)
)
)
)
);
}
element.Add(
new XElement(atomns + "id", urlHelper.MakeAbsolute(urlHelper.ItemDisplayUrl(package), baseUrl)),
new XElement(atomns + "title", package.TitlePart.Title, new XAttribute("type", "text")),
new XElement(atomns + "summary", package.Summary, new XAttribute("type", "text")),
new XElement(atomns + "updated", package.LatestVersionUtc.ToString("o")),
new XElement(atomns + "author",
new XElement(atomns + "name", package.CommonPart.Owner.UserName)
),
screenshots,
// edit-media
// edit
//new XElement(atomns + "category",
// new XAttribute("term", "Gallery.Infrastructure.FeedModels.PublishedPackage"),
// new XAttribute("scheme", "http://schemas.microsoft.com/ado/2007/08/dataservices/scheme")
// ),
new XElement(atomns + "content",
new XAttribute("type", "application/zip"),
new XAttribute("src", urlHelper.MakeAbsolute(urlHelper.Action("Download", "PackageVersion", new { id = package.PackageId, version = package.LatestVersion, area = "Orchard.Gallery" }), baseUrl))
),
new XElement(mns + "properties",
new XElement(dns + "Id", package.PackageId),
new XElement(dns + "Version", package.LatestVersion),
new XElement(dns + "Title", package.TitlePart.Title),
new XElement(dns + "Authors", package.CommonPart.Owner.UserName),
new XElement(dns + "PackageType", package.ExtensionType),
new XElement(dns + "Summary", package.Summary),
new XElement(dns + "Description", package.BodyPart.Text),
new XElement(dns + "Copyright", "", new XAttribute(mns + "null", "true")),
new XElement(dns + "PackageHashAlgorithm", ""),
new XElement(dns + "PackageHash", ""),
new XElement(dns + "PackageSize", new XAttribute(mns + "type", "Edm.Int64"), "0"),
new XElement(dns + "Price", "0", new XAttribute(mns + "type", "Edm.Decimal")),
new XElement(dns + "RequireLicenseAcceptance", "false", new XAttribute(mns + "type", "Edm.Boolean")),
new XElement(dns + "IsLatestVersion", "true", new XAttribute(mns + "type", "Edm.Boolean")),
new XElement(dns + "VersionRating", "5", new XAttribute(mns + "type", "Edm.Double")),
new XElement(dns + "VersionRatingsCount", "0", new XAttribute(mns + "type", "Edm.Int32")),
new XElement(dns + "VersionDownloadCount", package.DownloadCount, new XAttribute(mns + "type", "Edm.Int32")),
new XElement(dns + "Created", package.CommonPart.CreatedUtc.Value.ToString("o"), new XAttribute(mns + "type", "Edm.DateTime")),
new XElement(dns + "LastUpdated", package.LatestVersionUtc.ToString("o"), new XAttribute(mns + "type", "Edm.DateTime")),
new XElement(dns + "Published", package.CommonPart.PublishedUtc.Value.ToString("o"), new XAttribute(mns + "type", "Edm.DateTime")),
new XElement(dns + "ExternalPackageUrl", "", new XAttribute(mns + "null", "true")),
new XElement(dns + "ProjectUrl", package.ProjectUrl),
new XElement(dns + "LicenseUrl", package.LicenseUrl, new XAttribute(mns + "null", "true")),
new XElement(dns + "IconUrl", iconUrl),
new XElement(dns + "Rating", "5", new XAttribute(mns + "type", "Edm.Double")),
new XElement(dns + "RatingsCount", "0", new XAttribute(mns + "type", "Edm.Int32")),
new XElement(dns + "DownloadCount", package.DownloadCount, new XAttribute(mns + "type", "Edm.Int32")),
new XElement(dns + "Categories", ""),
new XElement(dns + "Tags", new XAttribute(XNamespace.Xml + "space", "preserve"), String.Join(" ", package.TagsPart.CurrentTags.ToArray())),
//.........这里部分代码省略.........
示例9: Execute
public void Execute(Orchard.Core.Feeds.Models.FeedContext context)
{
var idValue = context.ValueProvider.GetValue("id");
var connectorValue = context.ValueProvider.GetValue("connector");
var limitValue = context.ValueProvider.GetValue("limit");
var limit = 20;
if (limitValue != null)
{
limit = (int)limitValue.ConvertTo(typeof(int));
}
var id = (int)idValue.ConvertTo(typeof(int));
var connectorName = (string)connectorValue.ConvertTo(typeof(string));
var item = Services.ContentManager.Get(id);
var socket = item.As<SocketsPart>();
var connectors = socket.Sockets[connectorName].Connectors.List(
q => q.ForPart<CommonPart>().OrderBy<CommonPartRecord>(c => c.CreatedUtc),
q=>q.ForPart<ConnectorPart>().Slice(0,limit));
var site = Services.WorkContext.CurrentSite;
var url = new UrlHelper(_requestContext);
if (context.Format == "rss")
{
var link = new XElement("link");
context.Response.Element.SetElementValue("title", GetTitle(item.GetTitle(), site));
context.Response.Element.Add(link);
context.Response.Element.SetElementValue("description", item.GetBody());
context.Response.Contextualize(requestContext => link.Add(url.AbsoluteAction(()=>url.ItemDisplayUrl(item))));
}
else
{
context.Builder.AddProperty(context, null, "title", GetTitle(item.GetTitle(), site));
context.Builder.AddProperty(context, null, "description", item.GetBody());
context.Response.Contextualize(requestContext => context.Builder.AddProperty(context, null, "link", url.AbsoluteAction(() => url.ItemDisplayUrl(item))));
}
foreach (var child in connectors)
{
context.Builder.AddItem(context, child.RightContent.ContentItem);
}
}
示例10: CreateBlogStruct
private static XRpcStruct CreateBlogStruct(
BlogPostPart blogPostPart,
UrlHelper urlHelper)
{
var url = urlHelper.AbsoluteAction(() => urlHelper.ItemDisplayUrl(blogPostPart));
if (blogPostPart.HasDraft()) {
url = urlHelper.AbsoluteAction("Preview", "Item", new { area = "Contents", id = blogPostPart.ContentItem.Id });
}
var blogStruct = new XRpcStruct()
.Set("postid", blogPostPart.Id)
.Set("title", HttpUtility.HtmlEncode(blogPostPart.Title))
.Set("description", blogPostPart.Text)
.Set("link", url)
.Set("permaLink", url);
blogStruct.Set("wp_slug", blogPostPart.As<IAliasAspect>().Path);
if (blogPostPart.PublishedUtc != null) {
blogStruct.Set("dateCreated", blogPostPart.PublishedUtc);
blogStruct.Set("date_created_gmt", blogPostPart.PublishedUtc);
}
return blogStruct;
}
示例11: CreateUrl
public string CreateUrl(IContent content)
{
var workContext = _orchardServices.WorkContext;
if (workContext.HttpContext != null)
{
var url = new UrlHelper(workContext.HttpContext.Request.RequestContext);
return url.ItemDisplayUrl(content);
}
return null;
}