System.IO.Packaging.Check.IdIsValid C# (CSharp) Method

IdIsValid() public static method

public static IdIsValid ( string id ) : void
id string
return void
        public static void IdIsValid(string id)
        {
            if (id == null)
                return;

            // If the ID is a zero string, need to throw a ArgNullEx
            if (id.Length == 0)
                throw new ArgumentNullException("id", "Cannot be whitespace or empty");

            // FIXME: I need to XSD parse this to make sure it's valid
            // If it's not, throw an XmlException
        }

Usage Example

示例#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);
        }
All Usage Examples Of System.IO.Packaging.Check::IdIsValid