forked from samus/mongodb-csharp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ArrayCollectionAdapter.cs
34 lines (32 loc) · 1.03 KB
/
ArrayCollectionAdapter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections;
namespace MongoDB.Configuration.CollectionAdapters
{
/// <summary>
///
/// </summary>
public class ArrayCollectionAdapter : ICollectionAdapter
{
/// <summary>
/// Adds the element to instance.
/// </summary>
/// <param name="elementType">Type of the element.</param>
/// <param name="elements">The elements.</param>
/// <returns></returns>
public object CreateCollection(Type elementType, object[] elements)
{
var array = Array.CreateInstance(elementType, elements.Length);
elements.CopyTo(array, 0);
return array;
}
/// <summary>
/// Gets the elements from collection.
/// </summary>
/// <param name="collection">The collection.</param>
/// <returns></returns>
public IEnumerable GetElementsFromCollection(object collection)
{
return (IEnumerable)collection;
}
}
}