/// <summary>
/// Protected constructor for the abstract Base class.
/// This is the current contract between the subclass and the base class
/// If we decide some registration mechanism then this might change
///
/// NOTE : If you are using this constructor from your subclass or passing a null
/// for the content type parameter, be sure to implement the GetContentTypeCore
/// method, as that will be called to get the content type value. This is provided
/// to enable lazy initialization of the ContentType property.
///
/// </summary>
/// <param name="package">Package in which this part is being created</param>
/// <param name="partUri">uri of the part</param>
/// <param name="contentType">Content Type of the part, can be null if the value
/// is unknown at the time of construction. However the value has to be made
/// available anytime the ContentType property is called. A null value only indicates
/// that the value will be provided later. Every PackagePart must have a valid
/// Content Type</param>
/// <param name="compressionOption">compression option for this part</param>
/// <exception cref="ArgumentNullException">If parameter "package" is null</exception>
/// <exception cref="ArgumentNullException">If parameter "partUri" is null</exception>
/// <exception cref="ArgumentOutOfRangeException">If CompressionOption enumeration [compressionOption] does not have one of the valid values</exception>
/// <exception cref="ArgumentException">If parameter "partUri" does not conform to the valid partUri syntax</exception>
protected PackagePart(Package package,
Uri partUri,
string contentType,
CompressionOption compressionOption)
{
if (package == null)
{
throw new ArgumentNullException("package");
}
if (partUri == null)
{
throw new ArgumentNullException("partUri");
}
Package.ThrowIfCompressionOptionInvalid(compressionOption);
_uri = PackUriHelper.ValidatePartUri(partUri);
_container = package;
if (contentType == null)
{
_contentType = null;
}
else
{
_contentType = new ContentType(contentType);
}
_requestedStreams = null;
_compressionOption = compressionOption;
_isRelationshipPart = PackUriHelper.IsRelationshipPartUri(partUri);
}