TargetUri() публичный статический Метод

public static TargetUri ( Uri targetUri ) : void
targetUri System.Uri
Результат void
Пример #1
0
        private PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType, string id, bool loading)
        {
            if (!loading)
            {
                Package.CheckIsReadOnly();
            }
            Check.TargetUri(targetUri);
            Check.RelationshipTypeIsValid(relationshipType);
            Check.IdIsValid(id);

            if (id == null)
            {
                id = NextId();
            }

            if (Relationships.ContainsKey(id))
            {
                throw new XmlException("A relationship with this ID already exists");
            }

            PackageRelationship r = new PackageRelationship(id, Package, relationshipType, Uri, targetMode, targetUri);

            Relationships.Add(r.Id, r);

            if (!loading)
            {
                WriteRelationships();
            }
            return(r);
        }
Пример #2
0
        public static Uri ResolvePartUri(Uri sourcePartUri, Uri targetUri)
        {
            Check.SourcePartUri(sourcePartUri);
            Check.TargetUri(targetUri);

            Check.PartUriIsValid(sourcePartUri);
            if (targetUri.IsAbsoluteUri)
            {
                throw new ArgumentException("targetUri", "Absolute URIs are not supported");
            }

            // Need to trim first 7 chars as they are: "file://"
            return(new Uri(new Uri(sourcePartUri, targetUri).OriginalString.Substring(7), UriKind.Relative));
        }
Пример #3
0
        internal PackageRelationship(string id, Package package, string relationshipType,
                                     Uri sourceUri, TargetMode targetMode, Uri targetUri)
        {
            Check.IdIsValid(id);
            Check.Package(package);
            Check.RelationshipTypeIsValid(relationshipType);
            Check.SourceUri(sourceUri);
            Check.TargetUri(targetUri);

            Id               = id;
            Package          = package;
            RelationshipType = relationshipType;
            SourceUri        = sourceUri;
            TargetMode       = targetMode;
            TargetUri        = targetUri;
        }
Пример #4
0
        public static Uri ResolvePartUri(Uri sourcePartUri, Uri targetUri)
        {
            Check.SourcePartUri(sourcePartUri);
            Check.TargetUri(targetUri);

            Check.PartUriIsValid(sourcePartUri);
            // commented out because on Android they are absolute file:///
            //   if (targetUri.IsAbsoluteUri)
            //       throw new ArgumentException("targetUri", "Absolute URIs are not supported");

            Uri uri = new Uri("http://fake.com");

            uri = new Uri(uri, sourcePartUri);
            uri = new Uri(uri, targetUri);

            // Trim out 'http://fake.com'
            return(new Uri(uri.OriginalString.Substring(15), UriKind.Relative));
        }
Пример #5
0
        internal PackageRelationship CreateRelationship(Uri targetUri, TargetMode targetMode, string relationshipType,
                                                        string id, bool loading)
        {
            if (!loading)
            {
                CheckIsReadOnly();
            }

            Check.TargetUri(targetUri);
            if (targetUri.IsAbsoluteUri && targetMode == TargetMode.Internal)
            {
                throw new ArgumentException("TargetUri cannot be absolute for an internal relationship");
            }

            Check.RelationshipTypeIsValid(relationshipType);
            Check.IdIsValid(id);

            if (id == null)
            {
                id = NextId();
            }

            PackageRelationship r = new PackageRelationship(id, this, relationshipType, Uri, targetMode, targetUri);

            if (!PartExists(RelationshipUri))
            {
                CreatePartCore(RelationshipUri, RelationshipContentType, CompressionOption.NotCompressed).IsRelationship
                    = true;
            }

            Relationships.Add(r.Id, r);
            relationshipsCollection.Relationships.Add(r);

            if (!loading)
            {
                using (Stream s = GetPart(RelationshipUri).GetStream())
                    WriteRelationships(relationships, s);
            }

            return(r);
        }