Ejemplo n.º 1
0
        //------------------------------------------------------
        //
        //  Public Constructors
        //
        //------------------------------------------------------

        #region Public Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sourceUri">Source Uri of the PackagePart or PackageRoot ("/") that owns the relationship</param>
        /// <param name="selectorType">PackageRelationshipSelectorType enum representing the type of the selectionCriteria</param>
        /// <param name="selectionCriteria">The actual string that is used to select the relationships</param>
        /// <exception cref="ArgumentNullException">If sourceUri is null</exception>
        /// <exception cref="ArgumentNullException">If selectionCriteria is null</exception>
        /// <exception cref="ArgumentOutOfRangeException">If selectorType Enumeration does not have a valid value</exception>
        /// <exception cref="System.Xml.XmlException">If PackageRelationshipSelectorType.Id and selection criteria is not valid Xsd Id</exception>
        /// <exception cref="ArgumentException">If PackageRelationshipSelectorType.Type and selection criteria is not valid relationship type</exception>
        /// <exception cref="ArgumentException">If sourceUri is not "/" to indicate the PackageRoot, then it must conform to the 
        /// valid PartUri syntax</exception>
        public PackageRelationshipSelector(Uri sourceUri, PackageRelationshipSelectorType selectorType, string selectionCriteria)
        {
            if (sourceUri == null)
                throw new ArgumentNullException("sourceUri");

            if (selectionCriteria == null)
                throw new ArgumentNullException("selectionCriteria");

            //If the sourceUri is not equal to "/", it must be a valid part name.
            if (Uri.Compare(sourceUri, PackUriHelper.PackageRootUri, UriComponents.SerializationInfoString, UriFormat.UriEscaped, StringComparison.Ordinal) != 0)
                sourceUri = PackUriHelper.ValidatePartUri(sourceUri);

            //selectionCriteria is tested here as per the value of the selectorType.
            //If selectionCriteria is empty string we will throw the appropriate error message.
            if (selectorType == PackageRelationshipSelectorType.Type)
                InternalRelationshipCollection.ThrowIfInvalidRelationshipType(selectionCriteria);
            else
            if (selectorType == PackageRelationshipSelectorType.Id)
                InternalRelationshipCollection.ThrowIfInvalidXsdId(selectionCriteria);
            else
                throw new ArgumentOutOfRangeException("selectorType");

            _sourceUri = sourceUri;
            _selectionCriteria = selectionCriteria;
            _selectorType = selectorType;
        }
        //------------------------------------------------------
        //
        //  Public Constructors
        //
        //------------------------------------------------------

        #region Public Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sourceUri">Source Uri of the PackagePart or PackageRoot ("/") that owns the relationship</param>
        /// <param name="selectorType">PackageRelationshipSelectorType enum representing the type of the selectionCriteria</param>
        /// <param name="selectionCriteria">The actual string that is used to select the relationships</param>
        /// <exception cref="ArgumentNullException">If sourceUri is null</exception>
        /// <exception cref="ArgumentNullException">If selectionCriteria is null</exception>
        /// <exception cref="ArgumentOutOfRangeException">If selectorType Enumeration does not have a valid value</exception>
        /// <exception cref="System.Xml.XmlException">If PackageRelationshipSelectorType.Id and selection criteria is not valid Xsd Id</exception>
        /// <exception cref="ArgumentException">If PackageRelationshipSelectorType.Type and selection criteria is not valid relationship type</exception>
        /// <exception cref="ArgumentException">If sourceUri is not "/" to indicate the PackageRoot, then it must conform to the
        /// valid PartUri syntax</exception>
        public PackageRelationshipSelector(Uri sourceUri, PackageRelationshipSelectorType selectorType, string selectionCriteria)
        {
            if (sourceUri == null)
            {
                throw new ArgumentNullException("sourceUri");
            }

            if (selectionCriteria == null)
            {
                throw new ArgumentNullException("selectionCriteria");
            }

            //If the sourceUri is not equal to "/", it must be a valid part name.
            if (Uri.Compare(sourceUri, PackUriHelper.PackageRootUri, UriComponents.SerializationInfoString, UriFormat.UriEscaped, StringComparison.Ordinal) != 0)
            {
                sourceUri = PackUriHelper.ValidatePartUri(sourceUri);
            }

            //selectionCriteria is tested here as per the value of the selectorType.
            //If selectionCriteria is empty string we will throw the appropriate error message.
            if (selectorType == PackageRelationshipSelectorType.Type)
            {
                InternalRelationshipCollection.ThrowIfInvalidRelationshipType(selectionCriteria);
            }
            else
            if (selectorType == PackageRelationshipSelectorType.Id)
            {
                InternalRelationshipCollection.ThrowIfInvalidXsdId(selectionCriteria);
            }
            else
            {
                throw new ArgumentOutOfRangeException("selectorType");
            }

            _sourceUri         = sourceUri;
            _selectionCriteria = selectionCriteria;
            _selectorType      = selectorType;
        }
 public PackageRelationshipSelector(Uri sourceUri, PackageRelationshipSelectorType selectorType, string selectionCriteria)
 {
     throw new NotImplementedException ();
 }
Ejemplo n.º 4
0
 public PackageRelationshipSelector(Uri sourceUri, PackageRelationshipSelectorType selectorType, string selectionCriteria)
 {
     throw new NotImplementedException();
 }