本文整理汇总了C#中Sdl.Web.Common.Configuration.Localization.GetBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:C# Localization.GetBaseUrl方法的具体用法?C# Localization.GetBaseUrl怎么用?C# Localization.GetBaseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sdl.Web.Common.Configuration.Localization
的用法示例。
在下文中一共展示了Localization.GetBaseUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetLocalizations
/// <summary>
/// Set the localizations from a List loaded from configuration
/// </summary>
/// <param name="localizations">List of configuration data</param>
public static void SetLocalizations(List<Dictionary<string, string>> localizations)
{
Localizations = new Dictionary<string, Localization>();
foreach (var loc in localizations)
{
var localization = new Localization
{
Protocol = !loc.ContainsKey("Protocol") ? "http" : loc["Protocol"],
Domain = !loc.ContainsKey("Domain") ? "no-domain-in-cd_link_conf" : loc["Domain"],
Port = !loc.ContainsKey("Port") ? String.Empty : loc["Port"],
Path = (!loc.ContainsKey("Path") || loc["Path"] == "/") ? String.Empty : loc["Path"],
LocalizationId = !loc.ContainsKey("LocalizationId") ? "0" : loc["LocalizationId"]
};
Localizations.Add(localization.GetBaseUrl(), localization);
}
}
示例2: ProcessPageMetadata
protected virtual string ProcessPageMetadata(IPage page, IDictionary<string, string> meta, Localization localization)
{
//First grab metadata from the page
if (page.MetadataFields != null)
{
foreach (IField field in page.MetadataFields.Values)
{
ProcessMetadataField(field, meta);
}
}
string description = meta.ContainsKey("description") ? meta["description"] : null;
string title = meta.ContainsKey("title") ? meta["title"] : null;
string image = meta.ContainsKey("image") ? meta["image"] : null;
//If we don't have a title or description - go hunting for a title and/or description from the first component in the main region on the page
if (title == null || description == null)
{
bool first = true;
foreach (IComponentPresentation cp in page.ComponentPresentations)
{
MvcData regionMvcData = GetRegionMvcData(cp);
// determine title and description from first component in 'main' region
if (first && regionMvcData.ViewName.Equals(RegionForPageTitleComponent))
{
first = false;
IFieldSet metadata = cp.Component.MetadataFields;
IFieldSet fields = cp.Component.Fields;
if (metadata.ContainsKey(StandardMetadataXmlFieldName) && metadata[StandardMetadataXmlFieldName].EmbeddedValues.Count > 0)
{
IFieldSet standardMeta = metadata[StandardMetadataXmlFieldName].EmbeddedValues[0];
if (title == null && standardMeta.ContainsKey(StandardMetadataTitleXmlFieldName))
{
title = standardMeta[StandardMetadataTitleXmlFieldName].Value;
}
if (description == null && standardMeta.ContainsKey(StandardMetadataDescriptionXmlFieldName))
{
description = standardMeta[StandardMetadataDescriptionXmlFieldName].Value;
}
}
if (title == null && fields.ContainsKey(ComponentXmlFieldNameForPageTitle))
{
title = fields[ComponentXmlFieldNameForPageTitle].Value;
}
//Try to find an image
if (image == null && fields.ContainsKey("image"))
{
image = fields["image"].LinkedComponentValues[0].Multimedia.Url;
}
}
}
}
string titlePostfix = GetResource("core.pageTitleSeparator") + GetResource("core.pageTitlePostfix");
//if we still dont have a title, use the page title
if (title == null)
{
title = Regex.Replace(page.Title, @"^\d{3}\s", String.Empty);
// Index and Default are not a proper titles for an HTML page
if (title.ToLowerInvariant().Equals("index") || title.ToLowerInvariant().Equals("default"))
{
title = GetResource("core.defaultPageTitle");
}
}
meta.Add("twitter:card", "summary");
meta.Add("og:title", title);
// TODO: if the URL is really needed, it should be added higher up (e.g. in the View code): meta.Add("og:url", WebRequestContext.RequestUrl);
// TODO: is this always article?
meta.Add("og:type", "article");
meta.Add("og:locale", localization.Culture);
if (description != null)
{
meta.Add("og:description", description);
}
if (image != null)
{
image = localization.GetBaseUrl() + image;
meta.Add("og:image", image);
}
if (!meta.ContainsKey("description"))
{
meta.Add("description", description ?? title);
}
// TODO: meta.Add("fb:admins", Configuration.GetConfig("core.fbadmins");
return title + titlePostfix;
}