RelationshipTypeIsValid() public static method

public static RelationshipTypeIsValid ( string relationshipType ) : void
relationshipType string
return 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
        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;
        }
示例#3
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);
        }