diff options
| author | LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com> | 2019-02-11 22:48:50 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-11 22:48:50 -0800 |
| commit | 8bf88f4cb2ddb140baffd8e4542d8f528b482a67 (patch) | |
| tree | 5f60f345a22c2468b504b925c0bf4785869185ae /MediaBrowser.Model/Extensions | |
| parent | 4519ce26e2250cb233836296d292ddb7b3cf6346 (diff) | |
| parent | eb4b7051676b7493a57a99a821d5dd38bd9d4919 (diff) | |
Merge pull request #9 from jellyfin/master
Yanking in latest changes
Diffstat (limited to 'MediaBrowser.Model/Extensions')
| -rw-r--r-- | MediaBrowser.Model/Extensions/LinqExtensions.cs | 85 | ||||
| -rw-r--r-- | MediaBrowser.Model/Extensions/StringHelper.cs | 2 |
2 files changed, 1 insertions, 86 deletions
diff --git a/MediaBrowser.Model/Extensions/LinqExtensions.cs b/MediaBrowser.Model/Extensions/LinqExtensions.cs deleted file mode 100644 index f0febf1d0..000000000 --- a/MediaBrowser.Model/Extensions/LinqExtensions.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; - -// TODO: @bond Remove -namespace MediaBrowser.Model.Extensions -{ - // MoreLINQ - Extensions to LINQ to Objects - // Copyright (c) 2008 Jonathan Skeet. All rights reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. - // You may obtain a copy of the License at - // - // http://www.apache.org/licenses/LICENSE-2.0 - // - // Unless required by applicable law or agreed to in writing, software - // distributed under the License is distributed on an "AS IS" BASIS, - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - // See the License for the specific language governing permissions and - // limitations under the License. - - public static class LinqExtensions - { - /// <summary> - /// Returns all distinct elements of the given source, where "distinctness" - /// is determined via a projection and the default equality comparer for the projected type. - /// </summary> - /// <remarks> - /// This operator uses deferred execution and streams the results, although - /// a set of already-seen keys is retained. If a key is seen multiple times, - /// only the first element with that key is returned. - /// </remarks> - /// <typeparam name="TSource">Type of the source sequence</typeparam> - /// <typeparam name="TKey">Type of the projected element</typeparam> - /// <param name="source">Source sequence</param> - /// <param name="keySelector">Projection for determining "distinctness"</param> - /// <returns>A sequence consisting of distinct elements from the source sequence, - /// comparing them by the specified key projection.</returns> - - public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, - Func<TSource, TKey> keySelector) - { - return source.DistinctBy(keySelector, null); - } - - /// <summary> - /// Returns all distinct elements of the given source, where "distinctness" - /// is determined via a projection and the specified comparer for the projected type. - /// </summary> - /// <remarks> - /// This operator uses deferred execution and streams the results, although - /// a set of already-seen keys is retained. If a key is seen multiple times, - /// only the first element with that key is returned. - /// </remarks> - /// <typeparam name="TSource">Type of the source sequence</typeparam> - /// <typeparam name="TKey">Type of the projected element</typeparam> - /// <param name="source">Source sequence</param> - /// <param name="keySelector">Projection for determining "distinctness"</param> - /// <param name="comparer">The equality comparer to use to determine whether or not keys are equal. - /// If null, the default equality comparer for <c>TSource</c> is used.</param> - /// <returns>A sequence consisting of distinct elements from the source sequence, - /// comparing them by the specified key projection.</returns> - - public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, - Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) - { - if (source == null) throw new ArgumentNullException(nameof(source)); - if (keySelector == null) throw new ArgumentNullException(nameof(keySelector)); - return DistinctByImpl(source, keySelector, comparer); - } - - private static IEnumerable<TSource> DistinctByImpl<TSource, TKey>(IEnumerable<TSource> source, - Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer) - { - var knownKeys = new HashSet<TKey>(comparer); - foreach (var element in source) - { - if (knownKeys.Add(keySelector(element))) - { - yield return element; - } - } - } - } -} diff --git a/MediaBrowser.Model/Extensions/StringHelper.cs b/MediaBrowser.Model/Extensions/StringHelper.cs index 78e23e767..75ba12a17 100644 --- a/MediaBrowser.Model/Extensions/StringHelper.cs +++ b/MediaBrowser.Model/Extensions/StringHelper.cs @@ -51,7 +51,7 @@ namespace MediaBrowser.Model.Extensions public static string FirstToUpper(this string str) { - return string.IsNullOrEmpty(str) ? "" : str.Substring(0, 1).ToUpper() + str.Substring(1); + return string.IsNullOrEmpty(str) ? string.Empty : str.Substring(0, 1).ToUpperInvariant() + str.Substring(1); } } } |
