Exemplo n.º 1
0
		public virtual void CopyState(object original, object destination, ICounterpartFinder
			 counterpartFinder)
		{
			IDictionary originalMap = (IDictionary)original;
			IDictionary destinationMap = (IDictionary)destination;
			destinationMap.Clear();
			IEnumerator it = originalMap.GetEnumerator();
			while (it.MoveNext())
			{
				DictionaryEntry entry = (DictionaryEntry)it.Current;
				object keyClone = counterpartFinder.FindCounterpart(entry.Key);
				object valueClone = counterpartFinder.FindCounterpart(entry.Value);
				destinationMap[keyClone] = valueClone;
			}
		}
Exemplo n.º 2
0
        public virtual void CopyState(object original, object destination, ICounterpartFinder
                                      counterpartFinder)
        {
            IDictionary originalMap    = (IDictionary)original;
            IDictionary destinationMap = (IDictionary)destination;

            destinationMap.Clear();
            IEnumerator it = originalMap.GetEnumerator();

            while (it.MoveNext())
            {
                DictionaryEntry entry      = (DictionaryEntry)it.Current;
                object          keyClone   = counterpartFinder.FindCounterpart(entry.Key);
                object          valueClone = counterpartFinder.FindCounterpart(entry.Value);
                destinationMap[keyClone] = valueClone;
            }
        }
        public static void CopyCollectionState(object original, object destination, ICounterpartFinder counterpartFinder)
        {
            IEnumerable            originalCollection    = (IEnumerable )original;
            ICollectionInitializer destinationCollection = CollectionInitializer.For(destination);

            destinationCollection.Clear();

            foreach (object element in originalCollection)
            {
                object counterpart = counterpartFinder.FindCounterpart(element);
                destinationCollection.Add(counterpart);
            }
        }