// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license 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