first of all I'm a beginner in c#. I want to perform a deepcopy of a viewport class so I tried to copy items this way (like described on this post : here) :
 public static T Clone<T>(T source)
    {
        if (!typeof(T).IsSerializable)
        {
            throw new ArgumentException("The type must be serializable.", "source");
        }
        // Don't serialize a null object, simply return the default for that object
        if (Object.ReferenceEquals(source, null))
        {
            return default(T);
        }
        IFormatter formatter = new BinaryFormatter();
        Stream stream = new MemoryStream();
        using (stream)
        {
            formatter.Serialize(stream, source);
            stream.Seek(0, SeekOrigin.Begin);
            return (T)formatter.Deserialize(stream);
        }
    }
but the class is not serializable and I don't own it. So I'm thinking about put an extension on the viewport class in order to add a method wich may copy variables content to the new instance but I'm not sure that's the good way.
Have you suggestions or other solutions ?
Thanks.
 
    