<commit_before>﻿namespace Winium.StoreApps.InnerServer.Commands
{
    #region

    using System;
    using System.Collections.Generic;

    using Newtonsoft.Json;
    using Newtonsoft.Json.Linq;

    using Windows.UI.Core;

    using Winium.StoreApps.Common;
    using Winium.StoreApps.Common.Exceptions;

    #endregion

    internal class CommandBase
    {
        #region Public Properties

        public Automator Automator { get; set; }

        public IDictionary<string, JToken> Parameters { get; set; }

        public string Session { get; set; }

        #endregion

        #region Public Methods and Operators

        public string Do()
        {
            if (this.Automator == null)
            {
                throw new InvalidOperationException("Automator must be set before Do() is called");
            }

            var response = string.Empty;
            try
            {
                InvokeSync(this.Automator.UiThreadDispatcher, () => { response = this.DoImpl(); });
            }
            catch (AutomationException exception)
            {
                response = this.JsonResponse(exception.Status, exception);
            }
            catch (Exception exception)
            {
                response = this.JsonResponse(ResponseStatus.UnknownError, exception);
            }

            return response;
        }

        #endregion

        #region Methods

        protected virtual string DoImpl()<commit_msg>Use ToString on exceptions to get stack trace of inner exceptions too.<commit_after>﻿namespace Winium.StoreApps.InnerServer.Commands
{
    #region

    using System;
    using System.Collections.Generic;

    using Newtonsoft.Json;
    using Newtonsoft.Json.Linq;

    using Windows.UI.Core;

    using Winium.StoreApps.Common;
    using Winium.StoreApps.Common.Exceptions;

    #endregion

    internal class CommandBase
    {
        #region Public Properties

        public Automator Automator { get; set; }

        public IDictionary<string, JToken> Parameters { get; set; }

        public string Session { get; set; }

        #endregion

        #region Public Methods and Operators

        public string Do()
        {
            if (this.Automator == null)
            {
                throw new InvalidOperationException("Automator must be set before Do() is called");
            }

            var response = string.Empty;
            try
            {
                InvokeSync(this.Automator.UiThreadDispatcher, () => { response = this.DoImpl(); });
            }
            catch (AutomationException exception)
            {
                response = this.JsonResponse(exception.Status, exception.ToString());
            }
            catch (Exception exception)
            {
                response = this.JsonResponse(ResponseStatus.UnknownError, exception.ToString());
            }

            return response;
        }

        #endregion

        #region Methods

        protected virtual string DoImpl()
{'fraction_non_alphanumeric': 0.0789736754415195, 'fraction_numerical': 0.0, 'mean_word_length': 1.7977632805219013, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3312956', 'n_tokens_mistral': 751, 'n_tokens_neox': 710, 'n_words': 190}