Change some custom collections to inherit from List<T> to avoid duplicating the same logic over and over again
This commit is contained in:
parent
6e4d928109
commit
2c3d8f93d6
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
|
||||
|
@ -11,212 +12,7 @@ namespace OpenLiveWriter.ApplicationFramework
|
|||
/// Represents a collection of CommandBarEntry objects.
|
||||
/// </summary>
|
||||
[Editor(typeof(CommandBarEntryCollectionEditor), typeof(UITypeEditor))]
|
||||
public class CommandBarEntryCollection : CollectionBase
|
||||
public class CommandBarEntryCollection : List<CommandBarEntry>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandBarEntryCollection class.
|
||||
/// </summary>
|
||||
public CommandBarEntryCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandBarEntryCollection class.
|
||||
/// </summary>
|
||||
/// <param name="value">Command bar entry collection to initializes this command bar entry collection with.</param>
|
||||
public CommandBarEntryCollection(CommandBarEntryCollection value)
|
||||
{
|
||||
AddRange(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandBarEntryCollection class.
|
||||
/// </summary>
|
||||
/// <param name="value">Array of commands to initializes this command collection with.</param>
|
||||
public CommandBarEntryCollection(CommandBarEntry[] value)
|
||||
{
|
||||
AddRange(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command bar entry at the specified index.
|
||||
/// </summary>
|
||||
public CommandBarEntry this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CommandBarEntry)List[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
List[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified command bar entry to the end of the command bar entry collection.
|
||||
/// </summary>
|
||||
/// <param name="value">The command bar entry to be added to the end of the command bar entry collection.</param>
|
||||
/// <returns>The index at which the command bar entry has been added.</returns>
|
||||
public int Add(CommandBarEntry value)
|
||||
{
|
||||
return List.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the entries from the specified CommandBarEntryCollection to the end of this CommandBarEntryCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The CommandBarEntryCollection to be added to the end of this CommandBarEntryCollection.</param>
|
||||
public void AddRange(CommandBarEntryCollection value)
|
||||
{
|
||||
foreach (CommandBarEntry commandBarEntry in value)
|
||||
Add(commandBarEntry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified array of CommandBarEntry values to the end of the CommandBarEntryCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The array of CommandBarEntry values to be added to the end of the CommandBarEntryCollection.</param>
|
||||
public void AddRange(CommandBarEntry[] value)
|
||||
{
|
||||
foreach (CommandBarEntry commandBarEntry in value)
|
||||
this.Add(commandBarEntry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the CommandBarEntryCollection contains a specific element.
|
||||
/// </summary>
|
||||
/// <param name="value">The CommandBarEntry to locate in the CommandBarEntryCollection.</param>
|
||||
/// <returns>true if the CommandBarEntryCollection contains the specified value; otherwise, false.</returns>
|
||||
public bool Contains(CommandBarEntry value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the entire CommandBarEntryCollection to a one-dimensional Array, starting at the
|
||||
/// specified index of the target array.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination of the elements copied from CommandBarEntryCollection. The Array must have zero-based indexing.</param>
|
||||
/// <param name="index">The zero-based index in array at which copying begins.</param>
|
||||
public void CopyTo(CommandBarEntry[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specified CommandBarEntry and returns the zero-based index of the
|
||||
/// first occurrence within the entire CommandBarEntryCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The CommandBarEntry to locate in the CommandBarEntryCollection.</param>
|
||||
/// <returns>The zero-based index of the first occurrence of value within the entire CommandBarEntryCollection, if found; otherwise, -1.</returns>
|
||||
public int IndexOf(CommandBarEntry value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an element into the CommandBarEntryCollection at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The CommandBarEntry to insert.</param>
|
||||
public void Insert(int index, CommandBarEntry value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the CommandBarEntryCollection.
|
||||
/// </summary>
|
||||
/// <returns>An CommandBarEntryEnumerator for the CommandBarEntryCollection instance.</returns>
|
||||
public new CommandBarEntryEnumerator GetEnumerator()
|
||||
{
|
||||
return new CommandBarEntryEnumerator(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific Command from the CommandCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The Command to remove.</param>
|
||||
public void Remove(CommandBarEntry value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supports a simple iteration over a CommandBarEntryCollection.
|
||||
/// </summary>
|
||||
public class CommandBarEntryEnumerator : object, IEnumerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Private data.
|
||||
/// </summary>
|
||||
private IEnumerator baseEnumerator;
|
||||
private IEnumerable temp;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandBarEntryEnumerator class.
|
||||
/// </summary>
|
||||
/// <param name="mappings">The CommandBarEntryCollection to enumerate.</param>
|
||||
public CommandBarEntryEnumerator(CommandBarEntryCollection mappings)
|
||||
{
|
||||
temp = (IEnumerable)mappings;
|
||||
baseEnumerator = temp.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
public CommandBarEntry Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CommandBarEntry)baseEnumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseEnumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
public bool MoveNext()
|
||||
{
|
||||
return baseEnumerator.MoveNext();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
return baseEnumerator.MoveNext();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
baseEnumerator.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
void IEnumerator.Reset()
|
||||
{
|
||||
baseEnumerator.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
|
||||
|
@ -11,212 +12,12 @@ namespace OpenLiveWriter.ApplicationFramework
|
|||
/// Represents a collection of commands.
|
||||
/// </summary>
|
||||
[Editor(typeof(CommandCollectionEditor), typeof(UITypeEditor))]
|
||||
public class CommandCollection : CollectionBase
|
||||
public class CommandCollection : List<Command>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandCollection class.
|
||||
/// </summary>
|
||||
public CommandCollection()
|
||||
{
|
||||
}
|
||||
public CommandCollection() : base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandCollection class.
|
||||
/// </summary>
|
||||
/// <param name="value">Command collection to initializes this command collection with.</param>
|
||||
public CommandCollection(CommandCollection value)
|
||||
{
|
||||
AddRange(value);
|
||||
}
|
||||
public CommandCollection(int capacity) : base(capacity) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandCollection class.
|
||||
/// </summary>
|
||||
/// <param name="value">Array of commands to initializes this command collection with.</param>
|
||||
public CommandCollection(Command[] value)
|
||||
{
|
||||
AddRange(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command at the specified index.
|
||||
/// </summary>
|
||||
public Command this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Command)List[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
List[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified command to the end of the command collection.
|
||||
/// </summary>
|
||||
/// <param name="value">The command to be added to the end of the command collection.</param>
|
||||
/// <returns>The index at which the command has been added.</returns>
|
||||
public int Add(Command value)
|
||||
{
|
||||
return List.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the entries from the specified CommandCollection to the end of this CommandCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The CommandCollection to be added to the end of this CommandCollection.</param>
|
||||
public void AddRange(CommandCollection value)
|
||||
{
|
||||
foreach (Command command in value)
|
||||
Add(command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified array of Command values to the end of the CommandCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The array of Command values to be added to the end of the CommandCollection.</param>
|
||||
public void AddRange(Command[] value)
|
||||
{
|
||||
foreach (Command command in value)
|
||||
Add(command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the CommandCollection contains a specific element.
|
||||
/// </summary>
|
||||
/// <param name="value">The Command to locate in the CommandCollection.</param>
|
||||
/// <returns>true if the CommandCollection contains the specified value; otherwise, false.</returns>
|
||||
public bool Contains(Command value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the entire CommandCollection to a one-dimensional Array, starting at the
|
||||
/// specified index of the target array.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination of the elements copied from CommandCollection. The Array must have zero-based indexing.</param>
|
||||
/// <param name="index">The zero-based index in array at which copying begins.</param>
|
||||
public void CopyTo(Command[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specified Command and returns the zero-based index of the first
|
||||
/// occurrence within the entire CommandCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The Command to locate in the CommandCollection.</param>
|
||||
/// <returns>The zero-based index of the first occurrence of value within the entire CommandCollection, if found; otherwise, -1.</returns>
|
||||
public int IndexOf(Command value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an element into the CommandCollection at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The Command to insert.</param>
|
||||
public void Insert(int index, Command value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the CommandCollection.
|
||||
/// </summary>
|
||||
/// <returns>An CommandEnumerator for the CommandCollection instance.</returns>
|
||||
public new CommandEnumerator GetEnumerator()
|
||||
{
|
||||
return new CommandEnumerator(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific Command from the CommandCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The Command to remove.</param>
|
||||
public void Remove(Command value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supports a simple iteration over a CommandCollection.
|
||||
/// </summary>
|
||||
public class CommandEnumerator : object, IEnumerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Private data.
|
||||
/// </summary>
|
||||
private IEnumerator baseEnumerator;
|
||||
private IEnumerable temp;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CommandEnumerator class.
|
||||
/// </summary>
|
||||
/// <param name="mappings">The CommandCollection to enumerate.</param>
|
||||
public CommandEnumerator(CommandCollection mappings)
|
||||
{
|
||||
temp = (IEnumerable)mappings;
|
||||
baseEnumerator = temp.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
public Command Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Command)baseEnumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseEnumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
public bool MoveNext()
|
||||
{
|
||||
return baseEnumerator.MoveNext();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
return baseEnumerator.MoveNext();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
baseEnumerator.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
void IEnumerator.Reset()
|
||||
{
|
||||
baseEnumerator.Reset();
|
||||
}
|
||||
}
|
||||
public CommandCollection(IEnumerable<Command> commands) : base(commands) { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for details.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Design;
|
||||
using OpenLiveWriter.Localization;
|
||||
|
@ -12,233 +13,28 @@ namespace OpenLiveWriter.ApplicationFramework
|
|||
/// Represents a collection of MenuDefinitionEntry objects.
|
||||
/// </summary>
|
||||
[Editor(typeof(MenuDefinitionEntryCollectionEditor), typeof(UITypeEditor))]
|
||||
public class MenuDefinitionEntryCollection : CollectionBase
|
||||
public class MenuDefinitionEntryCollection : List<MenuDefinitionEntry>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MenuDefinitionEntryCollection class.
|
||||
/// </summary>
|
||||
public MenuDefinitionEntryCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MenuDefinitionEntryCollection class.
|
||||
/// </summary>
|
||||
/// <param name="value">Command bar entry collection to initializes this command bar entry collection with.</param>
|
||||
public MenuDefinitionEntryCollection(MenuDefinitionEntryCollection value)
|
||||
{
|
||||
AddRange(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MenuDefinitionEntryCollection class.
|
||||
/// </summary>
|
||||
/// <param name="value">Array of commands to initializes this command collection with.</param>
|
||||
public MenuDefinitionEntryCollection(MenuDefinitionEntry[] value)
|
||||
{
|
||||
AddRange(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command bar entry at the specified index.
|
||||
/// </summary>
|
||||
public MenuDefinitionEntry this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (MenuDefinitionEntry)List[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
List[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified command bar entry to the end of the command bar entry collection.
|
||||
/// </summary>
|
||||
/// <param name="value">The command bar entry to be added to the end of the command bar entry collection.</param>
|
||||
/// <returns>The index at which the command bar entry has been added.</returns>
|
||||
public int Add(MenuDefinitionEntry value)
|
||||
{
|
||||
return List.Add(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use strongly typed overload instead of this if possible!!
|
||||
/// </summary>
|
||||
public int Add(string commandIdentifier, bool separatorBefore, bool separatorAfter)
|
||||
public void Add(string commandIdentifier, bool separatorBefore, bool separatorAfter)
|
||||
{
|
||||
MenuDefinitionEntryCommand mde = new MenuDefinitionEntryCommand();
|
||||
mde.CommandIdentifier = commandIdentifier;
|
||||
mde.SeparatorBefore = separatorBefore;
|
||||
mde.SeparatorAfter = separatorAfter;
|
||||
return Add(mde);
|
||||
Add(mde);
|
||||
}
|
||||
|
||||
public int Add(CommandId commandIdentifier, bool separatorBefore, bool separatorAfter)
|
||||
public void Add(CommandId commandIdentifier, bool separatorBefore, bool separatorAfter)
|
||||
{
|
||||
MenuDefinitionEntryCommand mde = new MenuDefinitionEntryCommand();
|
||||
mde.CommandIdentifier = commandIdentifier.ToString();
|
||||
mde.SeparatorBefore = separatorBefore;
|
||||
mde.SeparatorAfter = separatorAfter;
|
||||
return Add(mde);
|
||||
Add(mde);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the entries from the specified MenuDefinitionEntryCollection to the end of this MenuDefinitionEntryCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The MenuDefinitionEntryCollection to be added to the end of this MenuDefinitionEntryCollection.</param>
|
||||
public void AddRange(MenuDefinitionEntryCollection value)
|
||||
{
|
||||
foreach (MenuDefinitionEntry commandBarEntry in value)
|
||||
Add(commandBarEntry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified array of MenuDefinitionEntry values to the end of the MenuDefinitionEntryCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The array of MenuDefinitionEntry values to be added to the end of the MenuDefinitionEntryCollection.</param>
|
||||
public void AddRange(MenuDefinitionEntry[] value)
|
||||
{
|
||||
foreach (MenuDefinitionEntry commandBarEntry in value)
|
||||
this.Add(commandBarEntry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the MenuDefinitionEntryCollection contains a specific element.
|
||||
/// </summary>
|
||||
/// <param name="value">The MenuDefinitionEntry to locate in the MenuDefinitionEntryCollection.</param>
|
||||
/// <returns>true if the MenuDefinitionEntryCollection contains the specified value; otherwise, false.</returns>
|
||||
public bool Contains(MenuDefinitionEntry value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the entire MenuDefinitionEntryCollection to a one-dimensional Array, starting at the
|
||||
/// specified index of the target array.
|
||||
/// </summary>
|
||||
/// <param name="array">The one-dimensional Array that is the destination of the elements copied from MenuDefinitionEntryCollection. The Array must have zero-based indexing.</param>
|
||||
/// <param name="index">The zero-based index in array at which copying begins.</param>
|
||||
public void CopyTo(MenuDefinitionEntry[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specified MenuDefinitionEntry and returns the zero-based index of the
|
||||
/// first occurrence within the entire MenuDefinitionEntryCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The MenuDefinitionEntry to locate in the MenuDefinitionEntryCollection.</param>
|
||||
/// <returns>The zero-based index of the first occurrence of value within the entire MenuDefinitionEntryCollection, if found; otherwise, -1.</returns>
|
||||
public int IndexOf(MenuDefinitionEntry value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an element into the MenuDefinitionEntryCollection at the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index at which value should be inserted.</param>
|
||||
/// <param name="value">The MenuDefinitionEntry to insert.</param>
|
||||
public void Insert(int index, MenuDefinitionEntry value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the MenuDefinitionEntryCollection.
|
||||
/// </summary>
|
||||
/// <returns>An MenuDefinitionEntryEnumerator for the MenuDefinitionEntryCollection instance.</returns>
|
||||
public new MenuDefinitionEntryEnumerator GetEnumerator()
|
||||
{
|
||||
return new MenuDefinitionEntryEnumerator(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the first occurrence of a specific Command from the CommandCollection.
|
||||
/// </summary>
|
||||
/// <param name="value">The Command to remove.</param>
|
||||
public void Remove(MenuDefinitionEntry value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supports a simple iteration over a MenuDefinitionEntryCollection.
|
||||
/// </summary>
|
||||
public class MenuDefinitionEntryEnumerator : object, IEnumerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Private data.
|
||||
/// </summary>
|
||||
private IEnumerator baseEnumerator;
|
||||
private IEnumerable temp;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MenuDefinitionEntryEnumerator class.
|
||||
/// </summary>
|
||||
/// <param name="mappings">The MenuDefinitionEntryCollection to enumerate.</param>
|
||||
public MenuDefinitionEntryEnumerator(MenuDefinitionEntryCollection mappings)
|
||||
{
|
||||
temp = (IEnumerable)mappings;
|
||||
baseEnumerator = temp.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
public MenuDefinitionEntry Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return (MenuDefinitionEntry)baseEnumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element in the collection.
|
||||
/// </summary>
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return baseEnumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
public bool MoveNext()
|
||||
{
|
||||
return baseEnumerator.MoveNext();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next element of the collection.
|
||||
/// </summary>
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
return baseEnumerator.MoveNext();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
baseEnumerator.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the collection.
|
||||
/// </summary>
|
||||
void IEnumerator.Reset()
|
||||
{
|
||||
baseEnumerator.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue