<commit_before>﻿using System;
using Assets.UtymapLib.Core;
using Assets.UtymapLib.Core.Models;
using Assets.UtymapLib.Infrastructure.Dependencies;
using Assets.UtymapLib.Infrastructure.Primitives;

namespace Assets.UtymapLib.Maps.Data
{
    /// <summary> Specifies behavior of element editor. </summary>
    public interface IElementEditor
    {
        /// <summary> Adds element. </summary>
        void Add(Element element, Range<int> levelOfDetails);

        /// <summary> Edits element. </summary>
        void Edit(Element element, Range<int> levelOfDetails);

        /// <summary> Marks element with given id. </summary>
        void Delete(long elementId, Range<int> levelOfDetails);
    }

    /// <summary>
    ///     Default implementation of <see cref="IElementEditor"/> which
    ///     works with in-memory store.
    /// </summary>
    internal class ElementEditor : IElementEditor
    {
        private readonly Stylesheet _stylesheet;

        [Dependency]
        public ElementEditor(Stylesheet stylesheet)
        {
            _stylesheet = stylesheet;
        }

        /// <inheritdoc />
        public void Add(Element element, Range<int> levelOfDetails)
        {
            UtymapLib.AddElementToInMemoryStore(_stylesheet.Path, element, levelOfDetails, message =>
            {
                if (!String.IsNullOrEmpty(message))
                    throw new MapDataException(message);
            });
        }

        /// <inheritdoc />
        public void Edit(Element element, Range<int> levelOfDetails)
        {
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        public void Delete(long elementId, Range<int> levelOfDetails)
        {
            throw new NotImplementedException();
        }<commit_msg>unity: add path resolver to ElementEditor<commit_after>﻿using System;
using Assets.UtymapLib.Core;
using Assets.UtymapLib.Core.Models;
using Assets.UtymapLib.Infrastructure.Dependencies;
using Assets.UtymapLib.Infrastructure.IO;
using Assets.UtymapLib.Infrastructure.Primitives;

namespace Assets.UtymapLib.Maps.Data
{
    /// <summary> Specifies behavior of element editor. </summary>
    public interface IElementEditor
    {
        /// <summary> Adds element. </summary>
        void Add(Element element, Range<int> levelOfDetails);

        /// <summary> Edits element. </summary>
        void Edit(Element element, Range<int> levelOfDetails);

        /// <summary> Marks element with given id. </summary>
        void Delete(long elementId, Range<int> levelOfDetails);
    }

    /// <summary>
    ///     Default implementation of <see cref="IElementEditor"/> which
    ///     works with in-memory store.
    /// </summary>
    internal class ElementEditor : IElementEditor
    {
        private readonly Stylesheet _stylesheet;
        private readonly IPathResolver _resolver;

        [Dependency]
        public ElementEditor(Stylesheet stylesheet, IPathResolver resolver)
        {
            _stylesheet = stylesheet;
            _resolver = resolver;
        }

        /// <inheritdoc />
        public void Add(Element element, Range<int> levelOfDetails)
        {
            UtymapLib.AddElementToInMemoryStore(_resolver.Resolve(_stylesheet.Path), 
                element, levelOfDetails, message =>
                {
                    if (!String.IsNullOrEmpty(message))
                        throw new MapDataException(message);
                });
        }

        /// <inheritdoc />
        public void Edit(Element element, Range<int> levelOfDetails)
        {
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        public void Delete(long elementId, Range<int> levelOfDetails)
        {
            throw new NotImplementedException();
        }
{'fraction_non_alphanumeric': 0.09873949579831932, 'fraction_numerical': 0.0, 'mean_word_length': 2.2062289562289563, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 45, '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': '2006781', 'n_tokens_mistral': 1005, 'n_tokens_neox': 980, 'n_words': 243}