diff --git a/src/managed/OpenLiveWriter.ApplicationFramework/CommandBarEntryCollection.cs b/src/managed/OpenLiveWriter.ApplicationFramework/CommandBarEntryCollection.cs index fa328c94..5ee0f0bf 100644 --- a/src/managed/OpenLiveWriter.ApplicationFramework/CommandBarEntryCollection.cs +++ b/src/managed/OpenLiveWriter.ApplicationFramework/CommandBarEntryCollection.cs @@ -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. /// [Editor(typeof(CommandBarEntryCollectionEditor), typeof(UITypeEditor))] - public class CommandBarEntryCollection : CollectionBase + public class CommandBarEntryCollection : List { - /// - /// Initializes a new instance of the CommandBarEntryCollection class. - /// - public CommandBarEntryCollection() - { - } - - /// - /// Initializes a new instance of the CommandBarEntryCollection class. - /// - /// Command bar entry collection to initializes this command bar entry collection with. - public CommandBarEntryCollection(CommandBarEntryCollection value) - { - AddRange(value); - } - - /// - /// Initializes a new instance of the CommandBarEntryCollection class. - /// - /// Array of commands to initializes this command collection with. - public CommandBarEntryCollection(CommandBarEntry[] value) - { - AddRange(value); - } - - /// - /// Gets or sets the command bar entry at the specified index. - /// - public CommandBarEntry this[int index] - { - get - { - return (CommandBarEntry)List[index]; - } - set - { - List[index] = value; - } - } - - /// - /// Adds the specified command bar entry to the end of the command bar entry collection. - /// - /// The command bar entry to be added to the end of the command bar entry collection. - /// The index at which the command bar entry has been added. - public int Add(CommandBarEntry value) - { - return List.Add(value); - } - - /// - /// Adds the entries from the specified CommandBarEntryCollection to the end of this CommandBarEntryCollection. - /// - /// The CommandBarEntryCollection to be added to the end of this CommandBarEntryCollection. - public void AddRange(CommandBarEntryCollection value) - { - foreach (CommandBarEntry commandBarEntry in value) - Add(commandBarEntry); - } - - /// - /// Adds the specified array of CommandBarEntry values to the end of the CommandBarEntryCollection. - /// - /// The array of CommandBarEntry values to be added to the end of the CommandBarEntryCollection. - public void AddRange(CommandBarEntry[] value) - { - foreach (CommandBarEntry commandBarEntry in value) - this.Add(commandBarEntry); - } - - /// - /// Determines whether the CommandBarEntryCollection contains a specific element. - /// - /// The CommandBarEntry to locate in the CommandBarEntryCollection. - /// true if the CommandBarEntryCollection contains the specified value; otherwise, false. - public bool Contains(CommandBarEntry value) - { - return List.Contains(value); - } - - /// - /// Copies the entire CommandBarEntryCollection to a one-dimensional Array, starting at the - /// specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from CommandBarEntryCollection. The Array must have zero-based indexing. - /// The zero-based index in array at which copying begins. - public void CopyTo(CommandBarEntry[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// Searches for the specified CommandBarEntry and returns the zero-based index of the - /// first occurrence within the entire CommandBarEntryCollection. - /// - /// The CommandBarEntry to locate in the CommandBarEntryCollection. - /// The zero-based index of the first occurrence of value within the entire CommandBarEntryCollection, if found; otherwise, -1. - public int IndexOf(CommandBarEntry value) - { - return List.IndexOf(value); - } - - /// - /// Inserts an element into the CommandBarEntryCollection at the specified index. - /// - /// The zero-based index at which value should be inserted. - /// The CommandBarEntry to insert. - public void Insert(int index, CommandBarEntry value) - { - List.Insert(index, value); - } - - /// - /// Returns an enumerator that can iterate through the CommandBarEntryCollection. - /// - /// An CommandBarEntryEnumerator for the CommandBarEntryCollection instance. - public new CommandBarEntryEnumerator GetEnumerator() - { - return new CommandBarEntryEnumerator(this); - } - - /// - /// Removes the first occurrence of a specific Command from the CommandCollection. - /// - /// The Command to remove. - public void Remove(CommandBarEntry value) - { - List.Remove(value); - } - - /// - /// Supports a simple iteration over a CommandBarEntryCollection. - /// - public class CommandBarEntryEnumerator : object, IEnumerator - { - /// - /// Private data. - /// - private IEnumerator baseEnumerator; - private IEnumerable temp; - - /// - /// Initializes a new instance of the CommandBarEntryEnumerator class. - /// - /// The CommandBarEntryCollection to enumerate. - public CommandBarEntryEnumerator(CommandBarEntryCollection mappings) - { - temp = (IEnumerable)mappings; - baseEnumerator = temp.GetEnumerator(); - } - - /// - /// Gets the current element in the collection. - /// - public CommandBarEntry Current - { - get - { - return (CommandBarEntry)baseEnumerator.Current; - } - } - - /// - /// Gets the current element in the collection. - /// - object IEnumerator.Current - { - get - { - return baseEnumerator.Current; - } - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - public bool MoveNext() - { - return baseEnumerator.MoveNext(); - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - bool IEnumerator.MoveNext() - { - return baseEnumerator.MoveNext(); - } - - /// - /// Sets the enumerator to its initial position, which is before the first element in the collection. - /// - public void Reset() - { - baseEnumerator.Reset(); - } - - /// - /// Sets the enumerator to its initial position, which is before the first element in the collection. - /// - void IEnumerator.Reset() - { - baseEnumerator.Reset(); - } - } } } diff --git a/src/managed/OpenLiveWriter.ApplicationFramework/CommandCollection.cs b/src/managed/OpenLiveWriter.ApplicationFramework/CommandCollection.cs index 92baa8ac..ef24bd6a 100644 --- a/src/managed/OpenLiveWriter.ApplicationFramework/CommandCollection.cs +++ b/src/managed/OpenLiveWriter.ApplicationFramework/CommandCollection.cs @@ -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. /// [Editor(typeof(CommandCollectionEditor), typeof(UITypeEditor))] - public class CommandCollection : CollectionBase + public class CommandCollection : List { - /// - /// Initializes a new instance of the CommandCollection class. - /// - public CommandCollection() - { - } + public CommandCollection() : base() { } - /// - /// Initializes a new instance of the CommandCollection class. - /// - /// Command collection to initializes this command collection with. - public CommandCollection(CommandCollection value) - { - AddRange(value); - } + public CommandCollection(int capacity) : base(capacity) { } - /// - /// Initializes a new instance of the CommandCollection class. - /// - /// Array of commands to initializes this command collection with. - public CommandCollection(Command[] value) - { - AddRange(value); - } - - /// - /// Gets or sets the command at the specified index. - /// - public Command this[int index] - { - get - { - return (Command)List[index]; - } - set - { - List[index] = value; - } - } - - /// - /// Adds the specified command to the end of the command collection. - /// - /// The command to be added to the end of the command collection. - /// The index at which the command has been added. - public int Add(Command value) - { - return List.Add(value); - } - - /// - /// Adds the entries from the specified CommandCollection to the end of this CommandCollection. - /// - /// The CommandCollection to be added to the end of this CommandCollection. - public void AddRange(CommandCollection value) - { - foreach (Command command in value) - Add(command); - } - - /// - /// Adds the specified array of Command values to the end of the CommandCollection. - /// - /// The array of Command values to be added to the end of the CommandCollection. - public void AddRange(Command[] value) - { - foreach (Command command in value) - Add(command); - } - - /// - /// Determines whether the CommandCollection contains a specific element. - /// - /// The Command to locate in the CommandCollection. - /// true if the CommandCollection contains the specified value; otherwise, false. - public bool Contains(Command value) - { - return List.Contains(value); - } - - /// - /// Copies the entire CommandCollection to a one-dimensional Array, starting at the - /// specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from CommandCollection. The Array must have zero-based indexing. - /// The zero-based index in array at which copying begins. - public void CopyTo(Command[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// Searches for the specified Command and returns the zero-based index of the first - /// occurrence within the entire CommandCollection. - /// - /// The Command to locate in the CommandCollection. - /// The zero-based index of the first occurrence of value within the entire CommandCollection, if found; otherwise, -1. - public int IndexOf(Command value) - { - return List.IndexOf(value); - } - - /// - /// Inserts an element into the CommandCollection at the specified index. - /// - /// The zero-based index at which value should be inserted. - /// The Command to insert. - public void Insert(int index, Command value) - { - List.Insert(index, value); - } - - /// - /// Returns an enumerator that can iterate through the CommandCollection. - /// - /// An CommandEnumerator for the CommandCollection instance. - public new CommandEnumerator GetEnumerator() - { - return new CommandEnumerator(this); - } - - /// - /// Removes the first occurrence of a specific Command from the CommandCollection. - /// - /// The Command to remove. - public void Remove(Command value) - { - List.Remove(value); - } - - /// - /// Supports a simple iteration over a CommandCollection. - /// - public class CommandEnumerator : object, IEnumerator - { - /// - /// Private data. - /// - private IEnumerator baseEnumerator; - private IEnumerable temp; - - /// - /// Initializes a new instance of the CommandEnumerator class. - /// - /// The CommandCollection to enumerate. - public CommandEnumerator(CommandCollection mappings) - { - temp = (IEnumerable)mappings; - baseEnumerator = temp.GetEnumerator(); - } - - /// - /// Gets the current element in the collection. - /// - public Command Current - { - get - { - return (Command)baseEnumerator.Current; - } - } - - /// - /// Gets the current element in the collection. - /// - object IEnumerator.Current - { - get - { - return baseEnumerator.Current; - } - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - public bool MoveNext() - { - return baseEnumerator.MoveNext(); - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - bool IEnumerator.MoveNext() - { - return baseEnumerator.MoveNext(); - } - - /// - /// Sets the enumerator to its initial position, which is before the first element in the collection. - /// - public void Reset() - { - baseEnumerator.Reset(); - } - - /// - /// Sets the enumerator to its initial position, which is before the first element in the collection. - /// - void IEnumerator.Reset() - { - baseEnumerator.Reset(); - } - } + public CommandCollection(IEnumerable commands) : base(commands) { } } } diff --git a/src/managed/OpenLiveWriter.ApplicationFramework/MenuDefinitionEntryCollection.cs b/src/managed/OpenLiveWriter.ApplicationFramework/MenuDefinitionEntryCollection.cs index 5cbb0ac5..5c37223d 100644 --- a/src/managed/OpenLiveWriter.ApplicationFramework/MenuDefinitionEntryCollection.cs +++ b/src/managed/OpenLiveWriter.ApplicationFramework/MenuDefinitionEntryCollection.cs @@ -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. /// [Editor(typeof(MenuDefinitionEntryCollectionEditor), typeof(UITypeEditor))] - public class MenuDefinitionEntryCollection : CollectionBase + public class MenuDefinitionEntryCollection : List { - /// - /// Initializes a new instance of the MenuDefinitionEntryCollection class. - /// - public MenuDefinitionEntryCollection() - { - } - - /// - /// Initializes a new instance of the MenuDefinitionEntryCollection class. - /// - /// Command bar entry collection to initializes this command bar entry collection with. - public MenuDefinitionEntryCollection(MenuDefinitionEntryCollection value) - { - AddRange(value); - } - - /// - /// Initializes a new instance of the MenuDefinitionEntryCollection class. - /// - /// Array of commands to initializes this command collection with. - public MenuDefinitionEntryCollection(MenuDefinitionEntry[] value) - { - AddRange(value); - } - - /// - /// Gets or sets the command bar entry at the specified index. - /// - public MenuDefinitionEntry this[int index] - { - get - { - return (MenuDefinitionEntry)List[index]; - } - set - { - List[index] = value; - } - } - - /// - /// Adds the specified command bar entry to the end of the command bar entry collection. - /// - /// The command bar entry to be added to the end of the command bar entry collection. - /// The index at which the command bar entry has been added. - public int Add(MenuDefinitionEntry value) - { - return List.Add(value); - } - /// /// Use strongly typed overload instead of this if possible!! /// - 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); - } - - /// - /// Adds the entries from the specified MenuDefinitionEntryCollection to the end of this MenuDefinitionEntryCollection. - /// - /// The MenuDefinitionEntryCollection to be added to the end of this MenuDefinitionEntryCollection. - public void AddRange(MenuDefinitionEntryCollection value) - { - foreach (MenuDefinitionEntry commandBarEntry in value) - Add(commandBarEntry); - } - - /// - /// Adds the specified array of MenuDefinitionEntry values to the end of the MenuDefinitionEntryCollection. - /// - /// The array of MenuDefinitionEntry values to be added to the end of the MenuDefinitionEntryCollection. - public void AddRange(MenuDefinitionEntry[] value) - { - foreach (MenuDefinitionEntry commandBarEntry in value) - this.Add(commandBarEntry); - } - - /// - /// Determines whether the MenuDefinitionEntryCollection contains a specific element. - /// - /// The MenuDefinitionEntry to locate in the MenuDefinitionEntryCollection. - /// true if the MenuDefinitionEntryCollection contains the specified value; otherwise, false. - public bool Contains(MenuDefinitionEntry value) - { - return List.Contains(value); - } - - /// - /// Copies the entire MenuDefinitionEntryCollection to a one-dimensional Array, starting at the - /// specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from MenuDefinitionEntryCollection. The Array must have zero-based indexing. - /// The zero-based index in array at which copying begins. - public void CopyTo(MenuDefinitionEntry[] array, int index) - { - List.CopyTo(array, index); - } - - /// - /// Searches for the specified MenuDefinitionEntry and returns the zero-based index of the - /// first occurrence within the entire MenuDefinitionEntryCollection. - /// - /// The MenuDefinitionEntry to locate in the MenuDefinitionEntryCollection. - /// The zero-based index of the first occurrence of value within the entire MenuDefinitionEntryCollection, if found; otherwise, -1. - public int IndexOf(MenuDefinitionEntry value) - { - return List.IndexOf(value); - } - - /// - /// Inserts an element into the MenuDefinitionEntryCollection at the specified index. - /// - /// The zero-based index at which value should be inserted. - /// The MenuDefinitionEntry to insert. - public void Insert(int index, MenuDefinitionEntry value) - { - List.Insert(index, value); - } - - /// - /// Returns an enumerator that can iterate through the MenuDefinitionEntryCollection. - /// - /// An MenuDefinitionEntryEnumerator for the MenuDefinitionEntryCollection instance. - public new MenuDefinitionEntryEnumerator GetEnumerator() - { - return new MenuDefinitionEntryEnumerator(this); - } - - /// - /// Removes the first occurrence of a specific Command from the CommandCollection. - /// - /// The Command to remove. - public void Remove(MenuDefinitionEntry value) - { - List.Remove(value); - } - - /// - /// Supports a simple iteration over a MenuDefinitionEntryCollection. - /// - public class MenuDefinitionEntryEnumerator : object, IEnumerator - { - /// - /// Private data. - /// - private IEnumerator baseEnumerator; - private IEnumerable temp; - - /// - /// Initializes a new instance of the MenuDefinitionEntryEnumerator class. - /// - /// The MenuDefinitionEntryCollection to enumerate. - public MenuDefinitionEntryEnumerator(MenuDefinitionEntryCollection mappings) - { - temp = (IEnumerable)mappings; - baseEnumerator = temp.GetEnumerator(); - } - - /// - /// Gets the current element in the collection. - /// - public MenuDefinitionEntry Current - { - get - { - return (MenuDefinitionEntry)baseEnumerator.Current; - } - } - - /// - /// Gets the current element in the collection. - /// - object IEnumerator.Current - { - get - { - return baseEnumerator.Current; - } - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - public bool MoveNext() - { - return baseEnumerator.MoveNext(); - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - bool IEnumerator.MoveNext() - { - return baseEnumerator.MoveNext(); - } - - /// - /// Sets the enumerator to its initial position, which is before the first element in the collection. - /// - public void Reset() - { - baseEnumerator.Reset(); - } - - /// - /// Sets the enumerator to its initial position, which is before the first element in the collection. - /// - void IEnumerator.Reset() - { - baseEnumerator.Reset(); - } + Add(mde); } + } }