public static ContentTypeIsValid ( string contentType ) : void | ||
contentType | string | |
return | void |
public static void ContentTypeIsValid(string contentType)
{
if (string.IsNullOrEmpty(contentType))
return;
// Must be in form of: type/subtype
int index = contentType.IndexOf('/');
bool result = (index > 0) && contentType.Length > (index + 1) && contentType.IndexOf('/', index + 1) == -1;
if (!result)
throw new ArgumentException("contentType", "contentType must be in the form of 'type/subtype'");
}
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); }