/// <summary>
/// Resolves the target uri in the relationship against the source part or the
/// package root. This resolved Uri is then used by the Add method to figure
/// out if a relationship is being created to another relationship part.
/// </summary>
/// <param name="target">PackageRelationship target uri</param>
/// <param name="targetMode"> Enum value specifying the interpretation of the base uri
/// for the relationship target uri</param>
/// <returns>Resolved Uri</returns>
private Uri GetResolvedTargetUri(Uri target, TargetMode targetMode)
{
if (targetMode == TargetMode.Internal)
{
Debug.Assert(!target.IsAbsoluteUri, "Uri should be relative at this stage");
if (_sourcePart == null) //indicates that the source is the package root
{
return(PackUriHelper.ResolvePartUri(PackUriHelper.PackageRootUri, target));
}
else
{
return(PackUriHelper.ResolvePartUri(_sourcePart.Uri, target));
}
}
else
{
if (target.IsAbsoluteUri)
{
if (String.CompareOrdinal(target.Scheme, PackUriHelper.UriSchemePack) == 0)
{
return(PackUriHelper.GetPartUri(target));
}
}
else
{
Debug.Assert(false, "Uri should not be relative at this stage");
}
}
// relative to the location of the package.
return(target);
}