Exemplo n.º 1
0
        /// <summary>
        /// Saves an <see cref="Identicon"/> icon as a Scalable Vector Graphics (SVG) file asynchronously.
        /// </summary>
        /// <param name="icon">The identicon to save.</param>
        /// <param name="stream">The stream to which the SVG data will be written.</param>
        /// <param name="fragment">
        /// If <c>true</c> the generated SVG will not be encapsulated in the root svg element making
        /// it suitable to be embedded in another SVG.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> was <c>null</c>.</exception>
        public static Task SaveAsSvgAsync(this Identicon icon, Stream stream, bool fragment)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var binarySvg = icon.GenerateBinarySvg(fragment);

            return(stream.WriteAsync(binarySvg, 0, binarySvg.Length));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves an <see cref="Identicon"/> icon as a Scalable Vector Graphics (SVG) file.
        /// </summary>
        /// <param name="icon">The identicon to save.</param>
        /// <param name="fragment">
        /// If <c>true</c> the generated SVG will not be encapsulated in the root svg element making
        /// it suitable to be embedded in another SVG.
        /// </param>
        public static Stream SaveAsSvg(this Identicon icon, bool fragment)
        {
            var binarySvg = icon.GenerateBinarySvg(fragment);

            return(new MemoryStream(binarySvg, false));
        }