Exemplo n.º 1
0
        /// <summary>
        /// Creates a copy of <c>this</c> including copies of any <see cref="XmlAttribute"/>s
        /// </summary>
        /// <returns>The copy</returns>
        protected override Property CopyProtected()
        {
            XmlProperty xmlProp = (XmlProperty)base.CopyProtected();
            string      nsUri   = GetNamespaceUri();

            xmlProp.SetQName(LocalName, nsUri == null ? "" : nsUri);
            foreach (XmlAttribute attr in Attributes.ContentsAs_Enumerable)
            {
                xmlProp.SetAttribute(attr.Copy());
            }
            return(xmlProp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the QName of the <see cref="XmlAttribute"/>
        /// </summary>
        /// <param name="newNamespaceUri">The namespace part of the new QName</param>
        /// <param name="newLocalName">The localName part of the new QName</param>
        /// <exception cref="exception.MethodParameterIsNullException">
        /// Throw when <paramref name="newNamespaceUri"/> or <paramref name="newLocalName"/> is <c>null</c>
        /// </exception>
        /// <exception cref="exception.MethodParameterIsEmptyStringException">
        /// Thrown when <paramref name="newLocalName"/> is an <see cref="String.Empty"/>
        /// </exception>
        /// <remarks>
        /// If the <see cref="XmlAttribute"/> has already been set on a <see cref="XmlProperty"/>,
        /// setting the QName will overwrite any <see cref="XmlAttribute"/> of the owning <see cref="XmlProperty"/>
        /// with matching QName
        /// </remarks>
        public void SetQName(string newLocalName, string newNamespaceUri)
        {
            if (newLocalName == null)
            {
                throw new exception.MethodParameterIsNullException("The local localName must not be null");
            }
            if (newLocalName == String.Empty)
            {
                throw new exception.MethodParameterIsEmptyStringException("The local localName must not be empty");
            }
            if (newNamespaceUri == null)
            {
                throw new exception.MethodParameterIsNullException("The namespace uri must not be null");
            }
            if (newLocalName != mLocalName || newNamespaceUri != mNamespaceUri)
            {
                XmlProperty parent = Parent;
                if (parent != null)
                {
                    parent.RemoveAttribute(this);
                }
                mLocalName    = newLocalName;
                mNamespaceUri = newNamespaceUri;

                string prefix;
                string realLocalName;
                XmlProperty.SplitLocalName(mLocalName, out prefix, out realLocalName);
                m_Prefix            = prefix;
                m_PrefixedLocalName = realLocalName;

                //#if DEBUG
                //                //Debugger.Break();

                //                if (m_Prefix != null)
                //                {
                //                    DebugFix.Assert(!string.IsNullOrEmpty(mNamespaceUri));
                //                }
                //#endif //DEBUG

                if (parent != null)
                {
                    parent.SetAttribute(this);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an export of <c>this</c> for a given destination <see cref="Presentation"/>
        /// </summary>
        /// <param name="destPres">The given destination presentaton</param>
        /// <returns>The exported xml property</returns>
        protected override Property ExportProtected(Presentation destPres)
        {
            XmlProperty xmlProp = base.ExportProtected(destPres) as XmlProperty;

            if (xmlProp == null)
            {
                throw new exception.FactoryCannotCreateTypeException(String.Format(
                                                                         "The property factory can not create an XmlProperty matching QName {0}:{1}",
                                                                         GetXukNamespace(),
                                                                         GetXukName()));
            }
            string nsUri = GetNamespaceUri();

            xmlProp.SetQName(LocalName, nsUri == null ? "" : nsUri);
            foreach (XmlAttribute attr in Attributes.ContentsAs_Enumerable)
            {
                xmlProp.SetAttribute(attr.Copy());
            }
            return(xmlProp);
        }