You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SCJMapper-V2/Common/CloneableItems.cs

35 lines
886 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SCJMapper_V2
{
//[Serializable]
public class CloneableDictionary<TKey, TValue> : Dictionary<TKey, TValue> where TValue : ICloneable
{
public virtual object Clone( )
{
CloneableDictionary<TKey, TValue> clone = new CloneableDictionary<TKey, TValue>();
foreach ( KeyValuePair<TKey, TValue> kvp in this ) {
clone.Add( kvp.Key, ( TValue )kvp.Value.Clone( ) );
}
return clone;
}
}
public class CloneableList<TValue> : List<TValue> where TValue : ICloneable
{
public virtual CloneableList<TValue> Clone( )
{
CloneableList<TValue> clone = new CloneableList<TValue>();
foreach ( TValue kvp in this ) {
clone.Add( ( TValue )kvp.Clone( ) );
}
return clone;
}
}
}