/*
i-net software provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties
of merchantability and/or fitness for a particular purpose. This programming example
assumes that you are familiar with the programming language being demonstrated and
the tools used to create and debug procedures. i-net software support professionals
can help explain the functionality of a particular procedure, but they will not modify
these examples to provide added functionality or construct procedures to meet your
specific needs.
© i-net software 1998-2013
*/
namespace Inet.Viewer.Helper
{
using System;
using System.Collections.Generic;
///
///
///
public static class Collections
{
///
/// Creates a copy of the source IDictionary and puts all
/// entries into the dest IDictionary
///
///
///
public static void PutAll(IDictionary dest, IDictionary source)
{
foreach (KeyValuePair entry in source)
{
if (!dest.ContainsKey(entry.Key))
{
dest.Add(entry.Key, entry.Value);
}
}
}
///
/// Content compares two Dictionaries
///
///
///
/// the first Dictionary
/// the second Dictionary
/// true if they are identical, false if they differ
public static bool DictionaryEqual(this IDictionary first, IDictionary second)
{
if (first == second) return true;
if ((first == null) || (second == null)) return false;
if (first.Count != second.Count) return false;
var comparer = EqualityComparer.Default;
foreach (KeyValuePair kvp in first)
{
TValue secondValue;
if (!second.TryGetValue(kvp.Key, out secondValue)) return false;
if (!comparer.Equals(kvp.Value, secondValue)) return false;
}
return true;
}
}
}