<commit_before>﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;

namespace Kevsoft.Ssml
{
    public class BreakWriter : IBreak, ISsmlWriter
    {
        private readonly ISsml _ssml;
        private TimeSpan? _duration;
        private BreakStrength _strength;

        public BreakWriter(ISsml ssml)
        {
            _ssml = ssml;
        }

        public async Task WriteAsync(XmlWriter writer)
        {
            await writer.WriteStartElementAsync(null, "break", null)
                .ConfigureAwait(false);

            if (_strength != BreakStrength.NotSet)
            {
                var value = _breakStrengthAttributeMap[_strength];

                await writer.WriteAttributeStringAsync(null, "strength", null, value)
                    .ConfigureAwait(false);
            }

            if (_duration.HasValue)
            {
                var milliseconds = _duration.Value.TotalMilliseconds;
                await writer.WriteAttributeStringAsync(null, "time", null, $"{milliseconds:F0}ms")
                    .ConfigureAwait(false);
            }

            await writer.WriteEndElementAsync()
                .ConfigureAwait(false);
        }

        ISay ISsml.Say(string value)
        {
            return _ssml.Say(value);
        }

        Task<string> ISsml.ToStringAsync()
        {
            return _ssml.ToStringAsync();
        }

        IBreak ISsml.Break()
        {
            return _ssml.Break();
        }

        public IBreak For(TimeSpan duration)
        {
            _duration = duration;

            return this;
        }

        public IBreak WithStrength(BreakStrength strength)
        {
            _strength = strength;

            return this;
        }

        private static IReadOnlyDictionary<BreakStrength, string> _breakStrengthAttributeMap =
            new Dictionary<BreakStrength, string>()
            {
                {BreakStrength.None, "none"},
                {BreakStrength.ExtraWeak, "x-weak"},
                {BreakStrength.Weak, "weak"},
                {BreakStrength.Medium, "medium"},
                {BreakStrength.Strong, "strong"},
                {BreakStrength.ExtraStrong, "x-strong"},
            };

    }
}<commit_msg>Conforming to coding styles.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;

namespace Kevsoft.Ssml
{
    public class BreakWriter : IBreak, ISsmlWriter
    {
        private readonly ISsml _ssml;
        private TimeSpan? _duration;
        private BreakStrength _strength;

        public BreakWriter(ISsml ssml)
        {
            _ssml = ssml;
        }

        public async Task WriteAsync(XmlWriter writer)
        {
            await writer.WriteStartElementAsync(null, "break", null)
                .ConfigureAwait(false);

            if (_strength != BreakStrength.NotSet)
            {
                var value = BreakStrengthAttributeMap[_strength];

                await writer.WriteAttributeStringAsync(null, "strength", null, value)
                    .ConfigureAwait(false);
            }

            if (_duration.HasValue)
            {
                var milliseconds = _duration.Value.TotalMilliseconds;
                await writer.WriteAttributeStringAsync(null, "time", null, $"{milliseconds:F0}ms")
                    .ConfigureAwait(false);
            }

            await writer.WriteEndElementAsync()
                .ConfigureAwait(false);
        }

        ISay ISsml.Say(string value)
        {
            return _ssml.Say(value);
        }

        Task<string> ISsml.ToStringAsync()
        {
            return _ssml.ToStringAsync();
        }

        IBreak ISsml.Break()
        {
            return _ssml.Break();
        }

        public IBreak For(TimeSpan duration)
        {
            _duration = duration;

            return this;
        }

        public IBreak WithStrength(BreakStrength strength)
        {
            _strength = strength;

            return this;
        }

        private static readonly IReadOnlyDictionary<BreakStrength, string> BreakStrengthAttributeMap =
            new Dictionary<BreakStrength, string>()
            {
                {BreakStrength.None, "none"},
                {BreakStrength.ExtraWeak, "x-weak"},
                {BreakStrength.Weak, "weak"},
                {BreakStrength.Medium, "medium"},
                {BreakStrength.Strong, "strong"},
                {BreakStrength.ExtraStrong, "x-strong"},
            };

    }
}
{'fraction_non_alphanumeric': 0.08806818181818182, 'fraction_numerical': 0.00043706293706293706, 'mean_word_length': 1.6334867663981587, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7225819', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1174, 'n_words': 234}