Virtual Happy Hour is canceled this month (March) due to Good Friday.
Try our conversational search powered by Generative AI!
AI OnAI Off
Virtual Happy Hour is canceled this month (March) due to Good Friday.
PageTypeCollection ptc = PageType.List();
foreach(PageType pt in ptc)
{
System.Diagnostics.Debug.WriteLine(pt.LocalizedName);
}
ptc = SortPageTypes(ptc, "LocalizedName");
foreach(PageType pt in ptc)
{
System.Diagnostics.Debug.WriteLine(pt.LocalizedName);
}
internal static PageTypeCollection SortPageTypes(PageTypeCollection unSortedCollection, string sortProperty)
{
PageTypeCollection sortedCollection = new PageTypeCollection();
foreach(PageType pageType in unSortedCollection)
{
System.Reflection.PropertyInfo propInfo = pageType.GetType().GetProperty(sortProperty);
if(propInfo == null)
{
throw new ApplicationException(string.Format("Property '{0}' not a member of type '{1}'", sortProperty, pageType.GetType().Name));
}
object currentValue = propInfo.GetValue(pageType, null);
bool inserted = false;
if(currentValue != null)
{
for(int i = 0; i < sortedCollection.Count; i++)
{
object compareValue = sortedCollection[i].GetType().GetProperty(sortProperty).GetValue(sortedCollection[i], null);
if(currentValue.ToString().CompareTo(compareValue) < 0)
{
sortedCollection.Insert(i, pageType);
inserted = true;
break;
}
}
if(!inserted)
{
sortedCollection.Add(pageType);
}
}
}
return sortedCollection;
}
/HAXEN
EPiServer.DataAbstraction.PageTypeCollection ptc = EPiServer.DataAbstraction.PageType.List();
System.Collections.SortedList sl = new System.Collections.SortedList();
foreach (EPiServer.DataAbstraction.PageType pt in ptc)
{
sl.Add(pt.Name, pt);
}