Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SectionCollection.cs
Go to the documentation of this file.
1 #region License
2 
3 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
4 // This file is distributed under MIT License. See LICENSE.md for details.
5 //
6 // SLNTools
7 // Copyright (c) 2009
8 // by Christian Warren
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
12 // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
13 // to permit persons to whom the Software is furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all copies or substantial portions
16 // of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23 
24 #endregion
25 
26 using System;
27 using System.Collections.Generic;
28 using System.Collections.ObjectModel;
29 using System.Diagnostics;
30 
31 namespace SiliconStudio.Core.VisualStudio
32 {
33  /// <summary>
34  /// A collection of <see cref="Section"/>
35  /// </summary>
36  [DebuggerDisplay("Count = {Count}")]
37  public sealed class SectionCollection
38  : KeyedCollection<string, Section>
39  {
40  /// <summary>
41  /// Initializes a new instance of the <see cref="SectionCollection"/> class.
42  /// </summary>
44  : base(StringComparer.InvariantCultureIgnoreCase)
45  {
46  }
47 
48  /// <summary>
49  /// Initializes a new instance of the <see cref="SectionCollection"/> class.
50  /// </summary>
51  /// <param name="items">The items.</param>
53  : this()
54  {
55  this.AddRange(items);
56  }
57 
58  protected override string GetKeyForItem(Section item)
59  {
60  return item.Name;
61  }
62 
63  protected override void InsertItem(int index, Section item)
64  {
65  if (item == null) throw new ArgumentNullException("item");
66 
67  // Add a clone of the item instead of the item itself
68  base.InsertItem(index, item.Clone());
69  }
70 
71  protected override void SetItem(int index, Section item)
72  {
73  if (item == null) throw new ArgumentNullException("item");
74 
75  // Add a clone of the item instead of the item itself
76  base.SetItem(index, item.Clone());
77  }
78  }
79 }
override void InsertItem(int index, Section item)
SectionCollection()
Initializes a new instance of the SectionCollection class.
A section defined in a Project
Definition: Section.cs:34
SectionCollection(IEnumerable< Section > items)
Initializes a new instance of the SectionCollection class.
override void SetItem(int index, Section item)