/// <summary> /// Returns a ReadOnlyEnumerableOfT that is the result of <paramref name="source"/> plus <paramref name="item"/>. /// </summary> /// <typeparam name="T">The element type of the enumerable.</typeparam> /// <param name="source">The source enumerable to concat.</param> /// <param name="collectionName">The name of the collection to report in case there's an error.</param> /// <param name="item">Item to concat to the source enumerable.</param> /// <returns>Returns a ReadOnlyEnumerableOfT that is the result of <paramref name="source"/> plus <paramref name="item"/>.</returns> internal static ReadOnlyEnumerable <T> ConcatToReadOnlyEnumerable <T>(this IEnumerable <T> source, string collectionName, T item) { ReadOnlyEnumerable <T> readOnlyEnumerable = source.GetOrCreateReadOnlyEnumerable(collectionName); readOnlyEnumerable.AddToSourceList(item); return(readOnlyEnumerable); }
/// <summary> /// Casts an IEnumerableOfT to ReadOnlyEnumerableOfT. /// </summary> /// <typeparam name="T">The element type of the enumerable.</typeparam> /// <param name="source">The source enumerable.</param> /// <param name="collectionName">The name of the collection to report in case there's an error.</param> /// <returns>The casted ReadOnlyEnumerableOfT.</returns> internal static ReadOnlyEnumerable <T> ToReadOnlyEnumerable <T>(this IEnumerable <T> source, string collectionName) { Debug.Assert(!String.IsNullOrEmpty(collectionName), "!string.IsNullOrEmpty(collectionName)"); ReadOnlyEnumerable <T> readonlyCollection = source as ReadOnlyEnumerable <T>; if (readonlyCollection == null) { throw new ODataException(Strings.ReaderUtils_EnumerableModified(collectionName)); } return(readonlyCollection); }
/// <summary> /// true if <paramref name="source"/> is the same instance as ReadOnlyEnumerableOfT.Empty(). false otherwise. /// </summary> /// <typeparam name="T">The element type of the enumerable.</typeparam> /// <param name="source">The enumerable in question.</param> /// <returns>Returns true if <paramref name="source"/> is the empty ReadOnlyEnumerableOfT. false otherwise.</returns> internal static bool IsEmptyReadOnlyEnumerable <T>(this IEnumerable <T> source) { return(ReferenceEquals(source, ReadOnlyEnumerable <T> .Empty())); }