public void DeletePart(Uri partUri) { CheckIsReadOnly(); Check.PartUri(partUri); PackagePart part = GetPart(partUri); if (part != null) { if (part.Package == null) { throw new InvalidOperationException("This part has already been removed"); } // FIXME: MS.NET doesn't remove the relationship part // Instead it throws an exception if you try to use it if (PartExists(part.RelationshipsPartUri)) { GetPart(part.RelationshipsPartUri).Package = null; } part.Package = null; DeletePartCore(partUri); PartsCollection.Parts.RemoveAll(p => p.Uri == partUri); } }
protected internal PackagePart(Package package, Uri partUri, string contentType, CompressionOption compressionOption) { Check.Package(package); Check.PartUri(partUri); Check.ContentTypeIsValid(contentType); Package = package; Uri = partUri; ContentType = contentType; CompressionOption = compressionOption; RelationshipsPartUri = PackUriHelper.GetRelationshipPartUri(Uri); }
public PackagePart CreatePart(Uri partUri, string contentType, CompressionOption compressionOption) { CheckIsReadOnly(); Check.PartUri(partUri); Check.ContentTypeIsValid(contentType); if (PartExists(partUri)) { throw new InvalidOperationException("This partUri is already contained in the package"); } PackagePart part = CreatePartCore(partUri, contentType, compressionOption); PartsCollection.Parts.Add(part); return(part); }