<commit_before>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;

namespace Grean.AtomEventStore
{
    public class AtomEntry : IXmlWritable
    {
        private readonly UuidIri id;
        private readonly string title;
        private readonly DateTimeOffset published;
        private readonly DateTimeOffset updated;
        private readonly AtomAuthor author;
        private readonly XmlAtomContent content;
        private readonly IEnumerable<AtomLink> links;

        public AtomEntry(
            UuidIri id,
            string title,
            DateTimeOffset published,
            DateTimeOffset updated,
            AtomAuthor author,
            XmlAtomContent content,
            IEnumerable<AtomLink> links)
        {
            if (title == null)
                throw new ArgumentNullException("title");
            if (author == null)
                throw new ArgumentNullException("author");
            if (content == null)
                throw new ArgumentNullException("content");
            if (links == null)
                throw new ArgumentNullException("links");
            
            this.id = id;
            this.title = title;
            this.published = published;
            this.updated = updated;
            this.author = author;
            this.content = content;
            this.links = links;
        }

        public UuidIri Id
        {
            get { return this.id; }
        }

        public string Title
        {
            get { return this.title; }
        }

        public DateTimeOffset Published
        {
            get { return this.published; }
        }

        public DateTimeOffset Updated
        {
            get { return this.updated; }
        }

        public AtomAuthor Author
        {
            get { return this.author; }
        }

        public XmlAtomContent Content
        {
            get { return this.content; }
        }

        public IEnumerable<AtomLink> Links
        {
            get { return this.links; }
        }

        public AtomEntry WithTitle(string newTitle)
        {
            return new AtomEntry(
                this.id,
                newTitle,
                this.published,
                this.updated,
                this.author,
                this.content,
                this.links);
        }

        public AtomEntry WithUpdated(DateTimeOffset newUpdated)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                newUpdated,
                this.author,
                this.content,
                this.links);
        }

        public AtomEntry WithAuthor(AtomAuthor newAuthor)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                this.updated,
                newAuthor,
                this.content,
                this.links);
        }

        public AtomEntry WithContent(XmlAtomContent newContent)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                this.updated,
                this.author,
                newContent,
                this.links);
        }

        public AtomEntry WithLinks(IEnumerable<AtomLink> newLinks)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                this.updated,
                this.author,
                this.content,
                newLinks);
        }

        public void WriteTo(XmlWriter xmlWriter)
        {
            if (xmlWriter == null)
                throw new ArgumentNullException("xmlWriter");

            xmlWriter.WriteStartElement("entry", "http://www.w3.org/2005/Atom");

            xmlWriter.WriteElementString("id", this.id.ToString());

            xmlWriter.WriteStartElement("title");
            xmlWriter.WriteAttributeString("type", "text");
            xmlWriter.WriteString(this.title);
            xmlWriter.WriteEndElement();

            xmlWriter.WriteElementString(
                "published",
                this.published.ToString(
                    "o",
                    CultureInfo.InvariantCulture));

            xmlWriter.WriteElementString("updated", this.updated.ToString("o"));

            this.author.WriteTo(xmlWriter);

            this.WriteLinksTo(xmlWriter);

            this.content.WriteTo(xmlWriter);

            xmlWriter.WriteEndElement();
        }<commit_msg>Addressed Code Analysis CA1305.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;

namespace Grean.AtomEventStore
{
    public class AtomEntry : IXmlWritable
    {
        private readonly UuidIri id;
        private readonly string title;
        private readonly DateTimeOffset published;
        private readonly DateTimeOffset updated;
        private readonly AtomAuthor author;
        private readonly XmlAtomContent content;
        private readonly IEnumerable<AtomLink> links;

        public AtomEntry(
            UuidIri id,
            string title,
            DateTimeOffset published,
            DateTimeOffset updated,
            AtomAuthor author,
            XmlAtomContent content,
            IEnumerable<AtomLink> links)
        {
            if (title == null)
                throw new ArgumentNullException("title");
            if (author == null)
                throw new ArgumentNullException("author");
            if (content == null)
                throw new ArgumentNullException("content");
            if (links == null)
                throw new ArgumentNullException("links");
            
            this.id = id;
            this.title = title;
            this.published = published;
            this.updated = updated;
            this.author = author;
            this.content = content;
            this.links = links;
        }

        public UuidIri Id
        {
            get { return this.id; }
        }

        public string Title
        {
            get { return this.title; }
        }

        public DateTimeOffset Published
        {
            get { return this.published; }
        }

        public DateTimeOffset Updated
        {
            get { return this.updated; }
        }

        public AtomAuthor Author
        {
            get { return this.author; }
        }

        public XmlAtomContent Content
        {
            get { return this.content; }
        }

        public IEnumerable<AtomLink> Links
        {
            get { return this.links; }
        }

        public AtomEntry WithTitle(string newTitle)
        {
            return new AtomEntry(
                this.id,
                newTitle,
                this.published,
                this.updated,
                this.author,
                this.content,
                this.links);
        }

        public AtomEntry WithUpdated(DateTimeOffset newUpdated)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                newUpdated,
                this.author,
                this.content,
                this.links);
        }

        public AtomEntry WithAuthor(AtomAuthor newAuthor)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                this.updated,
                newAuthor,
                this.content,
                this.links);
        }

        public AtomEntry WithContent(XmlAtomContent newContent)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                this.updated,
                this.author,
                newContent,
                this.links);
        }

        public AtomEntry WithLinks(IEnumerable<AtomLink> newLinks)
        {
            return new AtomEntry(
                this.id,
                this.title,
                this.published,
                this.updated,
                this.author,
                this.content,
                newLinks);
        }

        public void WriteTo(XmlWriter xmlWriter)
        {
            if (xmlWriter == null)
                throw new ArgumentNullException("xmlWriter");

            xmlWriter.WriteStartElement("entry", "http://www.w3.org/2005/Atom");

            xmlWriter.WriteElementString("id", this.id.ToString());

            xmlWriter.WriteStartElement("title");
            xmlWriter.WriteAttributeString("type", "text");
            xmlWriter.WriteString(this.title);
            xmlWriter.WriteEndElement();

            xmlWriter.WriteElementString(
                "published",
                this.published.ToString(
                    "o",
                    CultureInfo.InvariantCulture));

            xmlWriter.WriteElementString(
                "updated",
                this.updated.ToString(
                    "o",
                    CultureInfo.InvariantCulture));

            this.author.WriteTo(xmlWriter);

            this.WriteLinksTo(xmlWriter);

            this.content.WriteTo(xmlWriter);

            xmlWriter.WriteEndElement();
        }
{'fraction_non_alphanumeric': 0.0744035161155295, 'fraction_numerical': 0.0014650481372959396, 'mean_word_length': 1.2869107441971763, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 30}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1523562', 'n_tokens_mistral': 2352, 'n_tokens_neox': 2198, 'n_words': 498}