Beispiel #1
0
        /// <summary>
        /// Searches a <see cref="XContainer" /> for the first <see cref="XElement" /> instance with the specified
        /// specified <see cref="XName" /> and then parses and returns its value as a
        /// base-64 encoded byte array.
        /// </summary>
        /// <param name="container">The <see cref="XContainer" /></param>
        /// <param name="name">The attribute <see cref="XName" />.</param>
        /// <param name="def">The default value.</param>
        /// <returns>The parsed value on success, the default value on failure.</returns>
        public static byte[] ParseElementBase64(this XContainer container, XName name, byte[] def)
        {
            var element = container.Element(name);
            var value   = element != null ? element.Value : null;

            return(Serialize.ParseBase64(value, def));
        }
Beispiel #2
0
        /// <summary>
        /// Searches a <see cref="XElement" /> for the first attribute instance with the
        /// specified <see cref="XName" /> and then parses and returns its value as a
        /// base-64 encoded byte array.
        /// </summary>
        /// <param name="element">The <see cref="XElement" /></param>
        /// <param name="name">The attribute <see cref="XName" />.</param>
        /// <param name="def">The default value.</param>
        /// <returns>The parsed value on success, the default value on failure.</returns>
        public static byte[] ParseAttributeBase64(this XElement element, XName name, byte[] def)
        {
            var attribute = element.Attribute(name);
            var value     = attribute != null ? attribute.Value : null;

            return(Serialize.ParseBase64(value, def));
        }
Beispiel #3
0
 /// <summary>
 /// Parses the base-64 encoded string passed unless the string is
 /// null or the parse failed, in which case the default value
 /// will be returned.
 /// </summary>
 /// <param name="columnName">The column name.</param>
 /// <param name="def">The default value.</param>
 /// <returns>The parsed value on success, the default value on failure.</returns>
 public byte[] ParseBase64(string columnName, byte[] def)
 {
     return(Serialize.ParseBase64(GetColumn(columnName), def));
 }