SpeckleGrasshopper/ObjectCreation/ConvertSpeckleObject.cs
/// <summary>
/// Creates a deep copy of a SpeckleObject.
/// </summary>
/// <param name="inputObject"></param>
/// <returns></returns>
Creates a deep copy of a SpeckleObject.
Creates a deep copy of a SpeckleObject .
public object CreateCopy(object inputObject)
    {
      using (MemoryStream stream = new MemoryStream())
      {
        if (inputObject.GetType().IsSerializable)
        {
          BinaryFormatter formatter = new BinaryFormatter();
          formatter.Serialize(stream, inputObject);
          stream.Position = 0;
          SpeckleObject val = (SpeckleObject)formatter.Deserialize(stream);
          val._id = null;
          return val;
        }
        return null;
      }
    }
public object CreateCopy ( object inputObject ) { using ( MemoryStream stream = new MemoryStream ( ) ) { if ( inputObject . GetType ( ) . IsSerializable ) { BinaryFormatter formatter = new BinaryFormatter ( ) ; formatter . Serialize ( stream , inputObject ) ; stream . Position = 0 ; SpeckleObject val = ( SpeckleObject ) formatter . Deserialize ( stream ) ; val . _id = null ; return val ; } return null ; } }
Creates a deep copy of a SpeckleObject.
Creates a deep copy of a SpeckleObject .
None
inputObject
object
None