コード例 #1
0
        /// <summary>
        /// Evaluates this <see cref="Precondition"/> against the contents of the
        /// indicated <see cref="NodeIndex"/>.
        /// </summary>
        /// <param name="nodeIndex">The <see cref="NodeIndex"/> of a <see cref="XmlDocument"/></param>
        /// <param name="cache">A cache of previously evaluated precondition results.</param>
        /// <returns>A <see cref="bool"/> value indicating the applicability of this
        /// <see cref="Precondition"/> to the <see cref="XmlDocument"/>.</returns>
        public override bool Evaluate(NodeIndex nodeIndex, Dictionary <Precondition, bool> cache)
        {
            HandCoded.FpML.Util.Version version;

            // Find the document version
            XmlNodeList list = nodeIndex.GetElementsByName("FpML");

            if (list.Count > 0)
            {
                version = FpML.Util.Version.Parse(((XmlElement)list [0]).GetAttribute("version"));
            }
            else
            {
                list = nodeIndex.GetAttributesByName("fpmlVersion");
                if (list.Count > 0)
                {
                    version = FpML.Util.Version.Parse(((XmlAttribute)list [0]).Value);
                }
                else
                {
                    return(false);
                }
            }

//		    System.Console.Write ("Range (Doc=" + version
//				+ " Min=" + ((minimumVersion != null) ? minimumVersion.ToString () : "*")
//				+ " Max=" + ((maximumVersion != null) ? maximumVersion.ToString () : "*"));

            bool validMin = (minimumVersion != null) ? (version.CompareTo(minimumVersion) >= 0) : true;
            bool validMax = (maximumVersion != null) ? (version.CompareTo(maximumVersion) <= 0) : true;

//		    System.Console.WriteLine (") => " + (validMin & validMax));

            return(validMin & validMax);
        }
コード例 #2
0
        /// <summary>
        /// Evaluates this <b>Precondition</b> against the contents of the
        /// indicated <see cref="NodeIndex"/>.
        /// </summary>
        /// <param name="nodeIndex">The <see cref="NodeIndex"/> of a <see cref="XmlDocument"/>.</param>
        /// <param name="cache">A cache of previously evaluated precondition results.</param>
        /// <returns>A <c>bool</c> value indicating the applicability of this
        /// <b>Precondition</b> to the <see cref="XmlDocument"/>.</returns>
        public override bool Evaluate(NodeIndex nodeIndex, Dictionary <Precondition, bool> cache)
        {
            XmlElement rootElement;

            // Find the document element
            XmlNodeList list = nodeIndex.GetElementsByName("FpML");

            if (list.Count > 0)
            {
                rootElement = (XmlElement)list [0];
            }
            else
            {
                list = nodeIndex.GetAttributesByName("fpmlVersion");
                if (list.Count > 0)
                {
                    rootElement = ((XmlAttribute)list [0]).OwnerElement;
                }
                else
                {
                    return(false);
                }
            }

            string ns = rootElement.NamespaceURI;

            return((ns != null) ? (ns.CompareTo(namespaceUri) == 0) : false);
        }
コード例 #3
0
        /// <summary>
        /// Evaluates this <see cref="Precondition"/> against the contents of the
        /// indicated <see cref="NodeIndex"/>.
        /// </summary>
        /// <param name="nodeIndex">The <see cref="NodeIndex"/> of a <see cref="XmlDocument"/>.</param>
        /// <param name="cache">A cache of previously evaluated precondition results.</param>
        /// <returns>A <see cref="bool"/> value indicating the applicability of this
        /// <see cref="Precondition"/> to the <see cref="XmlDocument"/>.</returns>
        public override bool Evaluate(NodeIndex nodeIndex, Dictionary <Precondition, bool> cache)
        {
            HandCoded.FpML.Util.Version version;

            // Find the document version
            XmlNodeList list = nodeIndex.GetElementsByName("FpML");

            if (list.Count > 0)
            {
                version = HandCoded.FpML.Util.Version.Parse(((XmlElement)list [0]).GetAttribute("version"));
            }
            else
            {
                list = nodeIndex.GetAttributesByName("fpmlVersion");
                if (list.Count > 0)
                {
                    version = HandCoded.FpML.Util.Version.Parse(((XmlAttribute)list [0]).Value);
                }
                else
                {
                    return(false);
                }
            }

            return(version.Equals(targetVersion));
        }