本文整理汇总了C#中IPublishedContent.Descendants方法的典型用法代码示例。如果您正苦于以下问题:C# IPublishedContent.Descendants方法的具体用法?C# IPublishedContent.Descendants怎么用?C# IPublishedContent.Descendants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPublishedContent
的用法示例。
在下文中一共展示了IPublishedContent.Descendants方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Frontpage
protected Frontpage(IPublishedContent content)
: base(content)
{
IPublishedContent skills = content.Children.FirstOrDefault(x => x.DocumentTypeAlias == "Skills");
IPublishedContent portfolio = content.Children.FirstOrDefault(x => x.DocumentTypeAlias == "Portfoliolist");
IPublishedContent contact = content.Children.FirstOrDefault(x => x.DocumentTypeAlias == "Contact");
Sliders = ArcheTypeSlider.GetFromContent(content.GetPropertyValue<ArchetypeModel>("sliders"));
KompetencerHeadline = skills.GetPropertyValue<string>("title");
KompetencerText = skills.GetPropertyValue<string>("content");
Kompetencer = ArchetypeSkill.GetFromContent(skills.GetPropertyValue<ArchetypeModel>("skills"));
PortfolioHeadline = portfolio.GetPropertyValue<string>("title");
PortfolioItems = content
.Descendants("PortfolioPage")
.Where(x => !x.Hidden())
.Select(PortfolioItem.GetFromContent);
KontaktHeadline = contact.GetPropertyValue<string>("title");
KontaktTeaser = contact.GetPropertyValue<string>("teaser");
KontaktForm = contact.GetPropertyValue<string>("form");
AdrHeadline = contact.GetPropertyValue<string>("adrHeadline");
AdrShortText = contact.GetPropertyValue<string>("adrShortText");
AdrCompany = contact.GetPropertyValue<string>("adrCompany");
AdrAddress = contact.GetPropertyValue<string>("adrAddress");
AdrZip = contact.GetPropertyValue<string>("adrZip");
AdrCity = contact.GetPropertyValue<string>("adrCity");
AdrMobile = contact.GetPropertyValue<string>("adrMobile");
AdrEmail = contact.GetPropertyValue<string>("adrEmail");
}
示例2: GetAtoZPages
private static SortedDictionary<string, AtoZInfo> GetAtoZPages(UmbracoHelper umbHelper, string[] excludedTypes, IPublishedContent root)
{
var cacheName = string.Format("AtoZPages_{0}", root.Id);
var appCache = ApplicationContext.Current.ApplicationCache;
SortedDictionary<string, AtoZInfo> azPages = appCache.GetCacheItem<SortedDictionary<string, AtoZInfo>>(cacheName);
if (azPages == null)
{
Stopwatch sw = new Stopwatch();
sw.Start();
// no cache - so we have to build it...
LogHelper.Debug<AtoZEventHelper>("Building AtoZ Cache");
azPages = new SortedDictionary<string, AtoZInfo>();
var sitePages = root.Descendants().Where(
x => x.IsVisible()
&& !excludedTypes.Contains(x.DocumentTypeAlias)
&& !x.GetPropertyValue<bool>("excludeFromAtoZSearch")
&& !x.HasProperty("isComponent"));
foreach(var page in sitePages)
{
var title = page.GetPropertyValue<string>("title", page.Name).Trim();
if (!azPages.ContainsKey(title))
{
azPages.Add(title, new AtoZInfo()
{
Url = page.Url,
Id = page.Id,
Title = title
});
}
}
appCache.InsertCacheItem <SortedDictionary<string, AtoZInfo>>
(cacheName, CacheItemPriority.Default, () => azPages);
sw.Stop();
LogHelper.Info<AtoZEventHelper>("Built atoz cache for {0} pages in {1}ms",
() => azPages.Count(), () => sw.ElapsedMilliseconds);
}
return azPages;
}
示例3: MoveAndDeleteImages
/*
private void MoveAndDeleteImages(string oldMediaIds, string newMediaIds)
{
var oldMediaList = oldMediaIds != null ? oldMediaIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList() : new List<int>();
var newMediaList = newMediaIds != null ? newMediaIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList() : new List<int>();
foreach (var newMediaId in newMediaList.Where(newMediaId => !oldMediaList.Contains(newMediaId)))
{
var newMedia = Services.MediaService.GetById(newMediaId);
if (newMedia != null) Services.MediaService.Move(newMedia, ArborImageFolderId);
}
foreach (var oldMediaId in oldMediaList.Where(oldMediaId => !newMediaList.Contains(oldMediaId)))
{
var oldMedia = Services.MediaService.GetById(oldMediaId);
if (oldMedia != null) Services.MediaService.Move(oldMedia, TempFolderId);
}
}
*/
public static ArborEventModel GetEventModel(IPublishedContent content)
{
if (content == null) return null;
var startDate = content.GetPropertyValue<DateTime>("startDate");
var endDate = content.GetPropertyValue<DateTime>("endDate");
var location = content.GetPropertyValue<IPublishedContent>("location");
var links = content.GetPropertyValue<IPublishedContent>("links");
var attendeeList = content.Descendants("Person")
.Select(
x =>
new Attendee()
{
Id = x.Id.ToString(),
Name = x.GetPropertyValue<string>("name"),
Email = x.GetPropertyValue<string>("email"),
Phone = x.GetPropertyValue<string>("phoneNumber")
})
.Reverse().ToList();
return new ArborEventModel()
{
Id = content.Id,
Title = content.GetPropertyValue<string>("title"),
Description = content.GetPropertyValue<string>("description"),
StartDate = startDate.ToString("d"),
StartTime = startDate.ToString("t"),
EndDate = endDate.ToString("d"),
EndTime = endDate.ToString("t"),
Street = location.GetPropertyValue<string>("street"),
City = location.GetPropertyValue<string>("city"),
State = location.GetPropertyValue<string>("state"),
ZipCode = location.GetPropertyValue<string>("zipCode"),
Facebook = links.GetPropertyValue<string>("facebook"),
Twitter = links.GetPropertyValue<string>("twitter"),
Instagram = links.GetPropertyValue<string>("instagram"),
Blog = links.GetPropertyValue<string>("blog"),
Images = content.GetPropertyValue<string>("images"),
AttendeesJson = JsonConvert.SerializeObject(attendeeList)
};
}
示例4: GetNearestOffice
/// <returns>Узел офиса из имеющихся в городе, ближайший к точке, соответствущей переданному аргументу.</returns>
public static IPublishedContent GetNearestOffice(IPublishedContent region, GeoInfo geoInfo)
{
if (region == null) return null;
if (geoInfo == null || geoInfo.Latitude == null || geoInfo.Longitude == null) {
return region.Descendants("regOffice").FirstOrDefault();
}
var targetLat = geoInfo.Latitude.Value;
var targetLong = geoInfo.Longitude.Value;
var yacPattern = new System.Text.RegularExpressions.Regex(@"\[(.*)\]\|(.*)");
return region.Descendants("regOffice").OrderBy(x => {
var match = yacPattern.Match(x.GetPropertyValue<string>("coords"));
if (match.Success) {
var officeCoords = match.Groups[1].Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(y => y.Trim()).ToArray();
if (officeCoords.Length > 1) {
decimal officeLat, officeLong;
if (Decimal.TryParse(officeCoords[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out officeLat)) {
if (Decimal.TryParse(officeCoords[1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out officeLong)) {
return GetMetric(officeLat, officeLong, targetLat, targetLong);
}
}
}
}
return Double.MaxValue;
}).FirstOrDefault();
}