mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
Better name for TryFirst extension method
This commit is contained in:
@@ -53,12 +53,12 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
/// <param name="extends"></param>
|
/// <param name="extends"></param>
|
||||||
/// <param name="item">Outputs the first item in the sequence.</param>
|
/// <param name="item">Outputs the first item in the sequence.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool TryFirstOrDefault<T>(this IEnumerable<T> extends, out T item)
|
public static bool TryFirst<T>(this IEnumerable<T> extends, out T item)
|
||||||
{
|
{
|
||||||
if (extends == null)
|
if (extends == null)
|
||||||
throw new ArgumentNullException("extends");
|
throw new ArgumentNullException("extends");
|
||||||
|
|
||||||
return extends.TryFirstOrDefault(i => true, out item);
|
return extends.TryFirst(i => true, out item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -69,7 +69,7 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
/// <param name="predicate"></param>
|
/// <param name="predicate"></param>
|
||||||
/// <param name="item">Outputs the first item in the sequence.</param>
|
/// <param name="item">Outputs the first item in the sequence.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool TryFirstOrDefault<T>(this IEnumerable<T> extends, Func<T, bool> predicate, out T item)
|
public static bool TryFirst<T>(this IEnumerable<T> extends, Func<T, bool> predicate, out T item)
|
||||||
{
|
{
|
||||||
if (extends == null)
|
if (extends == null)
|
||||||
throw new ArgumentNullException("extends");
|
throw new ArgumentNullException("extends");
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace ICD.Common.Utils.Xml
|
|||||||
public static IcdXmlAttribute GetAttribute(string xml, string name)
|
public static IcdXmlAttribute GetAttribute(string xml, string name)
|
||||||
{
|
{
|
||||||
IcdXmlAttribute output;
|
IcdXmlAttribute output;
|
||||||
if (GetAttributes(xml).TryFirstOrDefault(a => a.Name == name, out output))
|
if (GetAttributes(xml).TryFirst(a => a.Name == name, out output))
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
throw new KeyNotFoundException(string.Format("No attribute with name {0}", name));
|
throw new KeyNotFoundException(string.Format("No attribute with name {0}", name));
|
||||||
|
|||||||
Reference in New Issue
Block a user