title: Deepcopy viewport (non-serializable class)
body: <p>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 : <a href="https://stackoverflow.com/questions/78536/deep-cloning-objects">here</a>) : </p>
  
  <pre><code> public static T Clone&lt;T&gt;(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);
          }
      }
  </code></pre>
  
  <p>but the class <strong>is not</strong> 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. </p>
  
  <p>Have you suggestions or other solutions ? </p>
  
  <p>Thanks.</p>