示例#1
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);
        }
        /// <summary>
        /// Writes the attributes of a XmlAttribute element
        /// </summary>
        /// <param name="destination">The destination <see cref="XmlWriter"/></param>
        /// <returns>A <see cref="bool"/> indicating if the write was succesful</returns>
        /// <param name="baseUri">
        /// The base <see cref="Uri"/> used to make written <see cref="Uri"/>s relative,
        /// if <c>null</c> absolute <see cref="Uri"/>s are written
        /// </param>
        protected override void XukOutAttributes(XmlWriter destination, Uri baseUri)
        {
            base.XukOutAttributes(destination, baseUri);

            if (String.IsNullOrEmpty(mLocalName))
            {
                throw new exception.XukException("The XmlAttribute has no name");
            }
            destination.WriteAttributeString(XukAble.LocalName_NAME.z(PrettyFormat), mLocalName);

            if (mValue == null)
            {
                throw new exception.XukException("The XmlAttribute has no value");
            }
            destination.WriteAttributeString(XukAble.Value_NAME.z(PrettyFormat), mValue);

            if (!string.IsNullOrEmpty(mNamespaceUri) &&
                (mParent == null || !mNamespaceUri.Equals(mParent.GetNamespaceUri(), StringComparison.InvariantCulture))
                )
            {
                destination.WriteAttributeString(XukAble.NamespaceUri_NAME.z(PrettyFormat), mNamespaceUri);
            }
        }