Data Types C#

//******************************
// Written by Peter Golde
// Copyright (c) 2004-2007, Wintellect
//
// Use and restribution of this code is subject to the license agreement 
// contained in the file "License.txt" accompanying this file.
//******************************
using System;
using System.Collections;
using System.Collections.Generic;
namespace Wintellect.PowerCollections
{
  /// 
  /// A holder class for various internal utility functions that need to be shared.
  /// 

    internal static class Util
    {
        /// 
        /// Wrap an enumerable so that clients can't get to the underlying
        /// implementation via a down-case
        /// 

        /// Enumerable to wrap.
        /// A wrapper around the enumerable.
        public static IEnumerable CreateEnumerableWrapper(IEnumerable wrapped)
        {
            return new WrapEnumerable(wrapped);
        }
        /// 
        /// Wrap an enumerable so that clients can't get to the underlying 
        /// implementation via a down-cast.
        /// 

        class WrapEnumerable : IEnumerable
        {
            IEnumerable wrapped;
            /// 
            /// Create the wrapper around an enumerable.
            /// 

            /// IEnumerable to wrap.
            public WrapEnumerable(IEnumerable wrapped)
            {
                this.wrapped = wrapped;
            }
            public IEnumerator GetEnumerator()
            {
                return wrapped.GetEnumerator();
            }
            IEnumerator IEnumerable.GetEnumerator()
            {
                return ((IEnumerable)wrapped).GetEnumerator();
            }
        }
   }
}