Mercurial > repos > IBBoard
changeset 11:ba9239164de2
Fixes #5 - Converting dictionary to array
* Add genericed DictionaryToArrayConverter class to IBBoard utils
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jan 2009 14:44:19 +0000 |
parents | 3b7a321e7c4c |
children | 465b672e9682 |
files | Collections/DictionaryToArrayConverter.cs IBBoard.mdp |
diffstat | 2 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Collections/DictionaryToArrayConverter.cs Sun Jan 04 14:44:19 2009 +0000 @@ -0,0 +1,35 @@ +// DictionaryToArrayConverter.cs is a part of the IBBoard utils library (referred to from here as "this program") +// +// Copyright (C) 2009 IBBoard +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +using System; +using System.Collections.Generic; + +namespace IBBoard +{ + + + public class DictionaryToArrayConverter + { + public static VALUE_TYPE[] Convert<KEY_TYPE, VALUE_TYPE>(Dictionary<KEY_TYPE, VALUE_TYPE> dictionary) + { + VALUE_TYPE[] col = (VALUE_TYPE[]) new object[dictionary.Count]; + dictionary.Values.CopyTo(col, 0); + return (VALUE_TYPE[])col; + } + } +}
--- a/IBBoard.mdp Sun Jan 04 12:02:36 2009 +0000 +++ b/IBBoard.mdp Sun Jan 04 14:44:19 2009 +0000 @@ -45,6 +45,7 @@ <File name="Collections/SimpleSet.cs" subtype="Code" buildaction="Compile" /> <File name="dtds" subtype="Directory" buildaction="Compile" /> <File name="dtds/translation.dtd" subtype="Code" buildaction="Nothing" /> + <File name="Collections/DictionaryToArrayConverter.cs" subtype="Code" buildaction="Compile" /> </Contents> <References> <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />