-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAlbumProfileCollection.cs
93 lines (82 loc) · 2.91 KB
/
AlbumProfileCollection.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System.Collections.Generic;
using GalleryServerPro.Business.Interfaces;
using System;
using System.Collections.ObjectModel;
namespace GalleryServerPro.Business
{
/// <summary>
/// A collection of <see cref="IAlbumProfile" /> objects.
/// </summary>
public class AlbumProfileCollection : KeyedCollection<int, IAlbumProfile>, IAlbumProfileCollection
{
/// <summary>
/// Adds the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <exception cref="System.ArgumentNullException">Thrown when <paramref name="item" /> is null.</exception>
public new void Add(IAlbumProfile item)
{
if (item == null)
throw new ArgumentNullException("item", "Cannot add null to an existing AlbumSortDefinitionCollection. Items.Count = " + Items.Count);
base.Add(item);
}
/// <summary>
/// Adds the <paramref name="items" /> to the current collection.
/// </summary>
/// <param name="items">The items to add to the current collection.</param>
/// <exception cref="System.ArgumentNullException">Thrown when <paramref name="items" /> is null.</exception>
public void AddRange(IEnumerable<IAlbumProfile> items)
{
if (items == null)
throw new ArgumentNullException("items");
foreach (var item in items)
{
this.Add(item);
}
}
/// <summary>
/// Find the album profile in the collection that matches the specified <paramref name="albumId" />. If no matching object is found,
/// null is returned.
/// </summary>
/// <param name="albumId">The ID for the album to find.</param>
/// <returns>Returns an <see cref="IAlbumProfile" />object from the collection that matches the specified <paramref name="albumId" />,
/// or null if no matching object is found.</returns>
public IAlbumProfile Find(int albumId)
{
return (base.Contains(albumId) ? base[albumId] : null);
}
/// <summary>
/// Generates as string representation of the items in the collection.
/// </summary>
/// <returns>Returns a string representation of the items in the collection.</returns>
public string Serialize()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(base.Items);
}
/// <summary>
/// Perform a deep copy of this collection.
/// </summary>
/// <returns>Returns a deep copy of this collection.</returns>
public IAlbumProfileCollection Copy()
{
IAlbumProfileCollection itemCollectionCopy = new AlbumProfileCollection();
foreach (IAlbumProfile item in this.Items)
{
itemCollectionCopy.Add(item.Copy());
}
return itemCollectionCopy;
}
/// <summary>
/// Gets the key for item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>System.Int32.</returns>
/// <exception cref="System.ArgumentNullException">Thrown when <paramref name="item" /> is null.</exception>
protected override int GetKeyForItem(IAlbumProfile item)
{
if (item == null)
throw new ArgumentNullException("item");
return item.AlbumId;
}
}
}