public Parcel(Guid id, ParcelSize size, Address address, ParcelState state = ParcelState.New) { Id = id; Size = size; Address = address; State = state; }
/// <summary> /// Seal parcel after modification /// May call this method on parcels in either Creating or Modifying states. /// Bank is used to create the ReplicationVersionInfo which is depends on store/bank implementation. /// Parcels can replicate only within stores/technologies that have sealed them /// </summary> public void Seal(IBank bank) { if (bank == null) { throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR + "Parcel.Seal(bank==null)"); } if (m_State != ParcelState.Creating && m_State != ParcelState.Modifying) { throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Seal", GetType().FullName, m_State)); } Validate(bank); if (ValidationExceptions.Any()) { throw ParcelSealValidationException.ForErrors(GetType().FullName, ValidationExceptions); } m_ReplicationVersionInfo = bank.GenerateReplicationVersionInfo(this); DoSeal(bank); m_State = ParcelState.Sealed; m_NewlySealed = true; }
public ParcelDocument(Parcel parcel) { Id = parcel.Id; Size = parcel.Size; Address = parcel.Address; State = parcel.State; }
/// <summary> /// Opens parcel for modification. Parcel must be in the Sealed state for this call and must not be ReadOnly. /// Once open for modification, a parcel can not be "UnOpened", only Seal()-ed. This is because there is no way to track /// whether some part of payload object has changed by the calling code. Use DeepClone() before calling Open to retain a copy of Sealed parcel /// to revert to the cloned instance instead /// </summary> public void Open() { if (m_State != ParcelState.Sealed) { throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Open", GetType().FullName, m_State)); } if (ReadOnly) { throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Open", GetType().FullName + "(ReadOnly)", m_State)); } if (ReplicationVersionInfo != null && ReplicationVersionInfo.VersionDeleted) { throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Open", GetType().FullName + "(VersionDeleted)", m_State)); } DoOpen(); m_State = ParcelState.Modifying; }
/// <summary> /// Opens parcel for modification. Parcel must be in the Sealed state for this call and must not be ReadOnly. /// Once open for modification, a parcel can not be "UnOpened", only Seal()-ed. This is because there is no way to track /// whether some part of payload object has changed by the calling code. Use DeepClone() before calling Open to retain a copy of Sealed parcel /// to revert to the cloned instance instead /// </summary> public void Open() { if (m_State != ParcelState.Sealed) { throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Open", GetType().FullName, m_State)); } if (ReadOnly) { throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Open", GetType().FullName + "(ReadOnly)", m_State)); } EnsurePayloadUnwrapped(); m_PayloadData = null; m_WrappedPayloadFormat = null; DoOpen(); m_State = ParcelState.Modifying; }
/// <summary> /// Seal parcel after modification /// May call this method on parcels in either Creating or Modifying states. /// Bank is used to create the ReplicationVersionInfo which is depends on store/bank implementation. /// Parcels can replicate only within stores/technologies that have sealed them /// </summary> public void Seal(IBank bank) { if (bank==null) throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR+"Parcel.Seal(bank==null)"); if (m_State!= ParcelState.Creating && m_State!=ParcelState.Modifying) throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Seal", GetType().FullName, m_State) ); Validate(bank); if (ValidationExceptions.Any()) throw ParcelSealValidationException.ForErrors(GetType().FullName, ValidationExceptions); m_ReplicationVersionInfo = bank.GenerateReplicationVersionInfo(this); DoSeal(bank); m_State = ParcelState.Sealed; m_NewlySealed = true; }
/// <summary> /// Opens parcel for modification. Parcel must be in the Sealed state for this call and must not be ReadOnly. /// Once open for modification, a parcel can not be "UnOpened", only Seal()-ed. This is because there is no way to track /// whether some part of payload object has changed by the calling code. Use DeepClone() before calling Open to retain a copy of Sealed parcel /// to revert to the cloned instance instead /// </summary> public void Open() { if (m_State!=ParcelState.Sealed) throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Open", GetType().FullName, m_State) ); if (ReadOnly) throw new DistributedDataAccessException(StringConsts.DISTRIBUTED_DATA_PARCEL_INVALID_OPERATION_ERROR.Args("Open", GetType().FullName+"(ReadOnly)", m_State) ); DoOpen(); m_State = ParcelState.Modifying; }
/// <summary> /// This ctor is never public, used with __ctor__injectID /// </summary> protected Parcel(object payload) { if (payload==null) throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR+GetType().FullName+".ctor(payload==null)"); m_State = ParcelState.Creating; m_Payload = payload; }
/// <summary> /// Called by device to load parcel from storage. /// The new instance is in 'ParcelState.Sealed' state. /// Business logic devs - do not call /// </summary> protected Parcel(GDID id, object payload, IReplicationVersionInfo versInfo) { m_GDID = id; if (versInfo==null) throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR+GetType().FullName+".ctor(versInfo==null)"); if (payload==null && !versInfo.VersionDeleted) throw new DistributedDataAccessException(StringConsts.ARGUMENT_ERROR+GetType().FullName+".ctor(payload==null)"); m_State = ParcelState.Sealed; m_Payload = payload; m_ReplicationVersionInfo = versInfo; }