Пример #1
0
 /// <summary>
 /// Constructor setting the parent <see cref="XmlProperty"/>
 /// </summary>
 /// <exception cref="exception.MethodParameterIsNullException">
 /// Thrown when the parent is <c>null</c>
 /// </exception>
 public XmlAttribute()
 {
     mParent       = null;
     mLocalName    = null;
     mNamespaceUri = "";
     mValue        = "";
 }
Пример #2
0
        /// <summary>
        /// Fires the <see cref="XmlAttributeSet"/> event
        /// </summary>
        /// <param name="src">The source, that is the <see cref="XmlProperty"/> on which an attribute was set</param>
        /// <param name="attrLN">The local name part of the QName of the attribute that was set</param>
        /// <param name="attrNS">The namespace uri part of the QName of the attribute that was set</param>
        /// <param name="newVal">The new value of the attribute - may be <c>null</c></param>
        /// <param name="prevVal">The previous value of the attribute - may be <c>null</c></param>
        protected void NotifyXmlAttributeSet(XmlProperty src, string attrLN, string attrNS, string newVal,
                                             string prevVal)
        {
            EventHandler <urakawa.events.property.xml.XmlAttributeSetEventArgs> d = XmlAttributeSet;

            if (d != null)
            {
                d(this, new urakawa.events.property.xml.XmlAttributeSetEventArgs(src, attrLN, attrNS, newVal, prevVal));
            }
        }
Пример #3
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);
        }
Пример #4
0
        /// <summary>
        /// Fires the <see cref="QNameChanged"/> event
        /// </summary>
        /// <param name="src">The source, that is the <see cref="XmlProperty"/> whoose QName changed</param>
        /// <param name="newLocalName">The local name part of the new QName</param>
        /// <param name="newNamespaceUri">The namespace uri part of the new QName</param>
        /// <param name="prevLocalName">The local name part of the QName before the change</param>
        /// <param name="prevNamespaceUri">The namespace uri part of the QName before the change</param>
        protected void NotifyQNameChanged(XmlProperty src, string newLocalName, string newNamespaceUri,
                                          string prevLocalName, string prevNamespaceUri)
        {
            EventHandler <urakawa.events.property.xml.QNameChangedEventArgs> d = QNameChanged;

            if (d != null)
            {
                d(this,
                  new urakawa.events.property.xml.QNameChangedEventArgs(src, newLocalName, newNamespaceUri,
                                                                        prevLocalName, prevNamespaceUri));
            }
        }
Пример #5
0
        public override bool ValueEquals(WithPresentation other)
        {
            if (!base.ValueEquals(other))
            {
                return(false);
            }

            XmlProperty otherz = other as XmlProperty;

            if (otherz == null)
            {
                return(false);
            }
            if (LocalName != otherz.LocalName)
            {
                //System.Diagnostics.Debug.Fail("! ValueEquals !");
                return(false);
            }

            string nsUri      = GetNamespaceUri();
            string nsUriOther = otherz.GetNamespaceUri();

            if (nsUri != nsUriOther)
            {
                //System.Diagnostics.Debug.Fail("! ValueEquals !");
                return(false);
            }
            ObjectListProvider <XmlAttribute> thisAttrs  = Attributes;
            ObjectListProvider <XmlAttribute> otherAttrs = otherz.Attributes;

            if (thisAttrs.Count != otherAttrs.Count)
            {
                //System.Diagnostics.Debug.Fail("! ValueEquals !");
                return(false);
            }
            foreach (XmlAttribute thisAttr in thisAttrs.ContentsAs_Enumerable)
            {
                XmlAttribute otherAttr = otherz.GetAttribute(thisAttr.LocalName, thisAttr.GetNamespaceUri());
                if (otherAttr == null)
                {
                    //System.Diagnostics.Debug.Fail("! ValueEquals !");
                    return(false);
                }
                if (otherAttr.Value != thisAttr.Value)
                {
                    //System.Diagnostics.Debug.Fail("! ValueEquals !");
                    return(false);
                }
            }
            return(true);
        }
Пример #6
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);
                }
            }
        }
Пример #7
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);
        }