Exemple #1
0
        public static T Peek <T>(this IPop <T> c)
        {
            bool isEmpty;
            T    next = c.TryPeek(out isEmpty);

            if (isEmpty)
            {
                throw new InvalidOperationException("The {0} is empty".Localized(MemoizedTypeName.Get(c.GetType())));
            }
            return(next);
        }
Exemple #2
0
        public static T Pop <T>(this ITryPop <T> c)
        {
            bool isEmpty;
            T    next = c.TryPop(out isEmpty);

            if (isEmpty)
            {
                throw new EmptySequenceException("The {0} is empty".Localized(MemoizedTypeName.Get(c.GetType())));
            }
            return(next);
        }
Exemple #3
0
        internal static string VisualizerName(string name)
        {
            string typeName = MemoizedTypeName <T> .GenericName();

            if (!string.IsNullOrEmpty(name))
            {
                return(string.Format("{0}: {1}", name, typeName));
            }
            else
            {
                return(typeName);
            }
        }
Exemple #4
0
        public ComputedList(Func <IEnumerable <T> > computeCollection)
        {
            _computeCollection = computeCollection;

            _computedSentry = new NamedComputed(MemoizedTypeName <ComputedList <T> > .GenericName(),
                                                delegate {
                using (var bin = new RecycleBin <T>(_list))
                {
                    _list.Clear();

                    foreach (T item in computeCollection())
                    {
                        _list.Add(bin.Extract(item));
                    }
                }
            });
        }
 public DependentDictionary(Func <IEnumerable <KeyValuePair <TKey, TValue> > > updateCollection, bool recycleValues)
 {
     _computeCollection = updateCollection;
     _dependentSentry   = new NamedDependent(MemoizedTypeName <DependentDictionary <TKey, TValue> > .GenericName(), Update);
     _recycleValues     = recycleValues;
 }