Esempio n. 1
0
        /// <summary>
        /// Maps each element of <see cref="CodeSnippetElement"/> sequence to the newly created <see cref="CodeSnippetElement"/>, optionally modifying serialization process.
        /// </summary>
        /// <param name="snippets">An enumerable collection of code snippets to be serialized.</param>
        /// <param name="settings">A <see cref="SaveSettings"/> that modify serialization process.</param>
        /// <returns>An enumerable collection of <see cref="CodeSnippetElement"/>.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="snippets"/> is <c>null</c>.</exception>
        public static IEnumerable <CodeSnippetElement> MapToElement(IEnumerable <Snippet> snippets, SaveSettings settings)
        {
            if (snippets == null)
            {
                throw new ArgumentNullException(nameof(snippets));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            return(MapToElement());

            IEnumerable <CodeSnippetElement> MapToElement()
            {
                foreach (Snippet snippet in snippets)
                {
                    yield return(SnippetMapper.MapToElement(snippet, settings));
                }
            }
        }
Esempio n. 2
0
 private static void Serialize(XmlWriter xmlWriter, IEnumerable <Snippet> snippets, SaveSettings settings)
 {
     Serialize(xmlWriter, SnippetMapper.MapToElement(snippets, settings).ToArray(), settings);
 }
Esempio n. 3
0
 private static void Serialize(XmlWriter xmlWriter, Snippet snippet, SaveSettings settings)
 {
     Serialize(xmlWriter, new CodeSnippetElement[] { SnippetMapper.MapToElement(snippet, settings) }, settings);
 }