// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace System.Net.Http.Formatting
{
///
/// Helper class to serialize types by delegating them through a concrete implementation."/>.
///
/// The interface implementing to proxy.
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "Enumerable conveys the meaning of collection")]
public sealed class DelegatingEnumerable : IEnumerable
{
private IEnumerable _source;
///
/// Initialize a DelegatingEnumerable. This constructor is necessary for to work.
///
public DelegatingEnumerable()
{
_source = Enumerable.Empty();
}
///
/// Initialize a DelegatingEnumerable with an . This is a helper class to proxy interfaces for .
///
/// The instance to get the enumerator from.
public DelegatingEnumerable(IEnumerable source)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
_source = source;
}
///
/// Get the enumerator of the associated .
///
/// The enumerator of the source.
public IEnumerator GetEnumerator()
{
return _source.GetEnumerator();
}
///
/// This method is not implemented but is required method for serialization to work. Do not use.
///
/// The item to add. Unused.
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "Required by XmlSerializer, never used.")]
public void Add(object item)
{
throw new NotImplementedException();
}
///
/// Get the enumerator of the associated .
///
/// The enumerator of the source.
IEnumerator IEnumerable.GetEnumerator()
{
return _source.GetEnumerator();
}
}
}