diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs
index 0f03615108..b14b1380ce 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/NodeExtensions.cs
@@ -45,7 +45,7 @@ namespace umbraco
/// Node as IEnumerable
public static IEnumerable GetAncestorNodes(this Node node)
{
- return (IEnumerable) GetAncestorNodes((INode)node);
+ return GetAncestorNodes((INode)node).Cast();
}
///
@@ -73,7 +73,7 @@ namespace umbraco
/// Node as IEnumerable
public static IEnumerable GetAncestorOrSelfNodes(this Node node)
{
- return (IEnumerable) GetAncestorOrSelfNodes((INode)node);
+ return GetAncestorOrSelfNodes((INode)node).Cast();
}
///
@@ -98,7 +98,7 @@ namespace umbraco
/// Node as IEumerable
public static IEnumerable GetPrecedingSiblingNodes(this Node node)
{
- return (IEnumerable) GetPrecedingSiblingNodes((INode)node);
+ return GetPrecedingSiblingNodes((INode)node).Cast();
}
///
@@ -125,7 +125,7 @@ namespace umbraco
/// Node as IEumerable
public static IEnumerable GetFollowingSiblingNodes(this Node node)
{
- return (IEnumerable) GetFollowingSiblingNodes((INode)node);
+ return GetFollowingSiblingNodes((INode)node).Cast();
}
///
@@ -152,7 +152,7 @@ namespace umbraco
/// Node as IEumerable
public static IEnumerable GetSiblingNodes(this Node node)
{
- return (IEnumerable) GetSiblingNodes((INode)node);
+ return GetSiblingNodes((INode)node).Cast();
}
///
@@ -179,7 +179,7 @@ namespace umbraco
/// Node as IEnumerable
public static IEnumerable GetDescendantOrSelfNodes(this Node node)
{
- return (IEnumerable) GetDescendantOrSelfNodes((INode)node);
+ return GetDescendantOrSelfNodes((INode)node).Cast();
}
///
@@ -206,7 +206,7 @@ namespace umbraco
/// Node as IEnumerable
public static IEnumerable GetDescendantNodes(this Node node)
{
- return (IEnumerable) GetDescendantNodes((INode) node);
+ return GetDescendantNodes((INode) node).Cast();
}
///
@@ -238,7 +238,7 @@ namespace umbraco
/// Nodes as IEnumerable
public static IEnumerable GetDescendantNodes(this Node node, Func func)
{
- return (IEnumerable) GetDescendantNodes((INode)node, (Func) func);
+ return GetDescendantNodes((INode)node, (Func) func).Cast();
}
///
@@ -273,7 +273,7 @@ namespace umbraco
/// Nodes as IEnumerable
public static IEnumerable GetDescendantNodesByType(this Node node, string documentTypeAlias)
{
- return (IEnumerable) GetDescendantNodesByType((INode)node, documentTypeAlias);
+ return GetDescendantNodesByType((INode)node, documentTypeAlias).Cast();
}
///
@@ -298,7 +298,7 @@ namespace umbraco
/// Node as IEnumerable
public static IEnumerable GetChildNodes(this Node node)
{
- return (IEnumerable) GetChildNodes((INode)node);
+ return GetChildNodes((INode)node).Cast();
}
///
@@ -311,10 +311,7 @@ namespace umbraco
/// INode as IEnumerable
public static IEnumerable GetChildNodes(this INode node)
{
- foreach (INode child in node.ChildrenAsList)
- {
- yield return child;
- }
+ return node.ChildrenAsList;
}
///
@@ -325,7 +322,7 @@ namespace umbraco
/// Nodes as IEnumerable
public static IEnumerable GetChildNodes(this Node node, Func func)
{
- return (IEnumerable) GetChildNodes((INode)node, (Func) func);
+ return GetChildNodes((INode)node, (Func) func).Cast();
}
///
@@ -334,9 +331,9 @@ namespace umbraco
/// The umbraco.interfaces.INode.
/// The func.
/// INodes as IEnumerable
- public static IEnumerable GetChildNodes(this INode node, Func func)
+ public static IEnumerable GetChildNodes(this INode node, Func func)
{
- foreach (Node child in node.ChildrenAsList)
+ foreach (INode child in node.ChildrenAsList)
{
if (func(child))
{
@@ -353,7 +350,7 @@ namespace umbraco
/// Nodes as IEnumerable
public static IEnumerable GetChildNodesByType(this Node node, string documentTypeAlias)
{
- return (IEnumerable) GetChildNodesByType((INode)node, documentTypeAlias);
+ return GetChildNodesByType((INode)node, documentTypeAlias).Cast();
}
///
@@ -386,20 +383,7 @@ namespace umbraco
/// null or INode
public static INode GetChildNodeByName(this INode parentNode, string nodeName)
{
- INode node = null;
-
- foreach (INode child in parentNode.ChildrenAsList)
- {
- if (child.Name == nodeName)
- {
- node = child;
- break;
- }
- }
-
- return node;
-
- //// return node.GetChildNodes(n => n.Name == nodeName);
+ return parentNode.ChildrenAsList.FirstOrDefault(child => child.Name == nodeName);
}
///
@@ -462,6 +446,8 @@ namespace umbraco
return (T)t;
}
+ //TODO: This should be converted to our extension method TryConvertTo ....
+
var typeConverter = TypeDescriptor.GetConverter(typeof(T));
if (typeConverter != null)
{
@@ -744,7 +730,7 @@ namespace umbraco
///
public static Node GetRandom(this IList nodes)
{
- return GetRandom(nodes);
+ return (Node)GetRandom(nodes.Cast().ToList());
}
///
@@ -770,7 +756,8 @@ namespace umbraco
///
public static IEnumerable GetRandom(this IList nodes, int numberOfItems)
{
- return GetRandom(nodes, numberOfItems);
+ var randomNodes = GetRandom(nodes.Cast().ToList(), numberOfItems);
+ return randomNodes.Cast().ToList();
}
///
@@ -851,9 +838,9 @@ namespace umbraco
/// The language.
/// if set to true [SSL].
///
- public static string GetFullNiceUrl(this Node node, string langauge, bool ssl)
+ public static string GetFullNiceUrl(this Node node, string language, bool ssl)
{
- return GetFullNiceUrl((INode)node, langauge, ssl);
+ return GetFullNiceUrl((INode)node, language, ssl);
}
///