<commit_before>﻿using Arduino;
using ArduinoWindowsRemoteControl.Repositories;
using Core.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArduinoWindowsRemoteControl.Services
{
    /// <summary>
    /// Service that returns parsers for different remote input devices
    /// </summary>
    public class RemoteCommandParserService
    {
        #region Private Fields

        private DictionaryRepository _dictionaryRepository;

        #endregion

        #region Constructor

        public RemoteCommandParserService()
        {
            _dictionaryRepository = new DictionaryRepository();
        }

        #endregion

        #region Public Methods

        public ArduinoRemoteCommandParser LoadArduinoCommandParser(string filename)
        {
            var dictionary = _dictionaryRepository.Load<int, RemoteCommand>(filename);

            return new ArduinoRemoteCommandParser(dictionary);
        }

        public void SaveArduinoCommandParser(ArduinoRemoteCommandParser commandParser, string filename)
        {

        }

        #endregion
    }
}<commit_msg>Add ability to save commands mapping<commit_after>﻿using Arduino;
using ArduinoWindowsRemoteControl.Repositories;
using Core.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArduinoWindowsRemoteControl.Services
{
    /// <summary>
    /// Service that returns parsers for different remote input devices
    /// </summary>
    public class RemoteCommandParserService
    {
        #region Private Fields

        private DictionaryRepository _dictionaryRepository;

        #endregion

        #region Constructor

        public RemoteCommandParserService()
        {
            _dictionaryRepository = new DictionaryRepository();
        }

        #endregion

        #region Public Methods

        public ArduinoRemoteCommandParser LoadArduinoCommandParser(string filename)
        {
            var dictionary = _dictionaryRepository.Load<int, RemoteCommand>(filename);

            return new ArduinoRemoteCommandParser(dictionary);
        }

        public void SaveArduinoCommandParser(ArduinoRemoteCommandParser commandParser, string filename)
        {
            _dictionaryRepository.Save(commandParser.CommandsMapping, filename);
        }

        #endregion
    }
}
{'fraction_non_alphanumeric': 0.06303724928366762, 'fraction_numerical': 0.0, 'mean_word_length': 2.9104, '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': '4441452', 'n_tokens_mistral': 594, 'n_tokens_neox': 551, 'n_words': 143}