<commit_before>﻿namespace AngleSharp.DOM.Css
{
    using AngleSharp.Css;
    using AngleSharp.Extensions;
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Information can be found on MDN:
    /// https://developer.mozilla.org/en-US/docs/Web/CSS/quotes
    /// </summary>
    sealed class CSSQuotesProperty : CSSProperty, ICssQuotesProperty
    {
        #region Fields

        static readonly Tuple<String, String>[] _default = new Tuple<String, String>[] { Tuple.Create("«", "»") };
        static readonly Tuple<String, String>[] _none = new Tuple<String, String>[0];
        Tuple<String, String>[] _quotes;

        #endregion

        #region ctor

        internal CSSQuotesProperty(CSSStyleDeclaration rule)
            : base(PropertyNames.Quotes, rule, PropertyFlags.Inherited)
        {
            Reset();
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the enumeration with pairs of values for open-quote and
        /// close-quote. The first pair represents the outer level of quotation,
        /// the second pair is for the first nested level, next pair for third
        /// level and so on.
        /// </summary>
        public IEnumerable<Tuple<String, String>> Quotes
        {
            get { return _quotes; }
        }

        #endregion

        #region Methods

        public void SetQuotes(Tuple<String, String>[] quotes)
        {
            _quotes = quotes;
        }

        internal override void Reset()
        {
            _quotes = _default;
        }

        Tuple<String, String>[] CreateArrays(String[] arrays)
        {
            var tuples = new Tuple<String, String>[arrays.Length / 2];

            for (int i = 0, k = 0; i < arrays.Length; i+=2, k++)
                tuples[k] = Tuple.Create(arrays[i], arrays[i + 1]);

            return tuples;
        }

        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            return this.TakeOne(Keywords.None, _none).Or(
                this.TakeMany(this.WithString()).Constraint(m => m.Length % 2 == 0).To(CreateArrays)).TryConvert(value, SetQuotes);
        }

        #endregion
    }
}<commit_msg>Renamed transformation method<commit_after>﻿namespace AngleSharp.DOM.Css
{
    using AngleSharp.Css;
    using AngleSharp.Extensions;
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Information can be found on MDN:
    /// https://developer.mozilla.org/en-US/docs/Web/CSS/quotes
    /// </summary>
    sealed class CSSQuotesProperty : CSSProperty, ICssQuotesProperty
    {
        #region Fields

        static readonly Tuple<String, String>[] _default = new Tuple<String, String>[] { Tuple.Create("«", "»") };
        static readonly Tuple<String, String>[] _none = new Tuple<String, String>[0];
        Tuple<String, String>[] _quotes;

        #endregion

        #region ctor

        internal CSSQuotesProperty(CSSStyleDeclaration rule)
            : base(PropertyNames.Quotes, rule, PropertyFlags.Inherited)
        {
            Reset();
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the enumeration with pairs of values for open-quote and
        /// close-quote. The first pair represents the outer level of quotation,
        /// the second pair is for the first nested level, next pair for third
        /// level and so on.
        /// </summary>
        public IEnumerable<Tuple<String, String>> Quotes
        {
            get { return _quotes; }
        }

        #endregion

        #region Methods

        public void SetQuotes(Tuple<String, String>[] quotes)
        {
            _quotes = quotes;
        }

        internal override void Reset()
        {
            _quotes = _default;
        }

        /// <summary>
        /// Determines if the given value represents a valid state of this property.
        /// </summary>
        /// <param name="value">The state that should be used.</param>
        /// <returns>True if the state is valid, otherwise false.</returns>
        protected override Boolean IsValid(CSSValue value)
        {
            return this.TakeOne(Keywords.None, _none).Or(
                this.TakeMany(this.WithString()).Constraint(m => m.Length % 2 == 0).To(TransformArray)).TryConvert(value, SetQuotes);
        }

        #endregion

        #region Helpers

        static Tuple<String, String>[] TransformArray(String[] arrays)
        {
            var tuples = new Tuple<String, String>[arrays.Length / 2];

            for (int i = 0, k = 0; i < arrays.Length; i += 2, k++)
                tuples[k] = Tuple.Create(arrays[i], arrays[i + 1]);

            return tuples;
        }

        #endregion
    }
}
{'fraction_non_alphanumeric': 0.11503371677905593, 'fraction_numerical': 0.0031733439111463705, 'mean_word_length': 1.9167148640832852, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 2, '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': '4146921', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1357, 'n_words': 391}