// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. #if !NO_PERF using System; using System.Collections.Generic; using System.Reactive.Linq.ObservableImpl; namespace System.Reactive { internal static class Helpers { public static int? GetLength(IEnumerable source) { var array = source as T[]; if (array != null) return array.Length; var list = source as IList; if (list != null) return list.Count; return null; } public static IObservable Unpack(IObservable source) { var hasOpt = default(bool); do { hasOpt = false; var eval = source as IEvaluatableObservable; if (eval != null) { source = eval.Eval(); hasOpt = true; } } while (hasOpt); return source; } } } #endif