コード例 #1
0
        /// <summary>
        /// Loads this <see cref="YahooMediaHash"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaHash"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="YahooMediaHash"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            if (source.HasAttributes)
            {
                string algorithmAttribute = source.GetAttribute("algo", String.Empty);
                if (!String.IsNullOrEmpty(algorithmAttribute))
                {
                    YahooMediaHashAlgorithm algorithm = YahooMediaHash.HashAlgorithmByName(algorithmAttribute);
                    if (algorithm != YahooMediaHashAlgorithm.None)
                    {
                        this.Algorithm = algorithm;
                        wasLoaded      = true;
                    }
                }
            }

            if (!String.IsNullOrEmpty(source.Value))
            {
                this.Value = source.Value;
                wasLoaded  = true;
            }

            return(wasLoaded);
        }
コード例 #2
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source)
        /// <summary>
        /// Loads this <see cref="YahooMediaHash"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaHash"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="YahooMediaHash"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasAttributes)
            {
                string algorithmAttribute = source.GetAttribute("algo", String.Empty);
                if (!String.IsNullOrEmpty(algorithmAttribute))
                {
                    YahooMediaHashAlgorithm algorithm = YahooMediaHash.HashAlgorithmByName(algorithmAttribute);
                    if (algorithm != YahooMediaHashAlgorithm.None)
                    {
                        this.Algorithm = algorithm;
                        wasLoaded      = true;
                    }
                }
            }

            if (!String.IsNullOrEmpty(source.Value))
            {
                this.Value = source.Value;
                wasLoaded  = true;
            }

            return(wasLoaded);
        }