Source/NFX/DataAccess/Distributed/Parcel.cs
/// <summary>
/// Duplicates this parcel by doing a complete deep-clone of its state via serialization.
/// This method is useful for making copies of the same parcel for different threads as it is thread-safe while no other thread mutates the instance,
/// however Parcel instances are NOT THREAD-SAFE for parallel changes.
/// The existing parcel MUST be SEALED (otherwise it can not be serialized).
/// This method is also used before a call to Open() if parcel needs to be "un-opened" the cloned instance may be reverted to
/// </summary>
Duplicates this parcel by doing a complete deep-clone of its state via serialization.
This method is useful for making copies of the same parcel for different threads as it is thread-safe while no other thread mutates the instance,
however Parcel instances are NOT THREAD-SAFE for parallel changes.
The existing parcel MUST be SEALED (otherwise it can not be serialized).
This method is also used before a call to Open() if parcel needs to be "un-opened" the cloned instance may be reverted to
Duplicates this parcel by doing a complete deep - clone of its state via serialization . This method is useful for making copies of the same parcel for different threads as it is thread - safe while no other thread mutates the instance however Parcel instances are NOT THREAD - SAFE for parallel changes . The existing parcel MUST be SEALED ( otherwise it can not be serialized ) . This method is also used before a call to Open () if parcel needs to be " un - opened " the cloned instance may be reverted to
public Parcel DeepClone()
            {
              if (m_State!=ParcelState.Sealed)
                 throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("DeepClone", GetType().FullName, m_State) );
              using(var ms = new System.IO.MemoryStream(4*1024))
              {
                var serializer = new SlimSerializer( STANDARD_KNOWN_SERIALIZER_TYPES );
                serializer.Serialize(ms, this);
                ms.Position = 0;
                return serializer.Deserialize(ms) as Parcel;
              }
            }
public Parcel DeepClone ( ) { if ( m_State != ParcelState . Sealed ) throw new DistributedDataAccessException ( StringConsts . DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR . Args ( " " , GetType ( ) . FullName , m_State ) ) ; using ( var ms = new System . IO . MemoryStream ( 4 * 1024 ) ) { var serializer = new SlimSerializer ( STANDARD_KNOWN_SERIALIZER_TYPES ) ; serializer . Serialize ( ms , this ) ; ms . Position = 0 ; return serializer . Deserialize ( ms ) as Parcel ; } }
Duplicates this parcel by doing a complete deep-clone of its state via serialization.
Duplicates this parcel by doing a complete deep - clone of its state via serialization .