<commit_before>﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace KirinWindows.Core
{
    public class NativeContext
    {
        private Dictionary<string, NativeObjectHolder> objects;
        public NativeContext()
        {
            objects = new Dictionary<string, NativeObjectHolder>();
        }

        public void RegisterNativeObject(object obj, string name, bool isGwt)
        {
            objects.Add(name, new NativeObjectHolder(obj, isGwt));
        }

        private object ConvertParameter(object param, Type expectedType)
        {
            // ints all come through as Int64s.  These need converting to ints.
            if (param is Int64)
            {
                if (expectedType != new Int32().GetType())
                {
                    throw new InvalidOperationException(param + " is an int, but expected " + expectedType);<commit_msg>Update to check key on dictionary for Registration of Native Objects<commit_after>﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace KirinWindows.Core
{
    public class NativeContext
    {
        private Dictionary<string, NativeObjectHolder> objects;
        public NativeContext()
        {
            objects = new Dictionary<string, NativeObjectHolder>();
        }

        public void RegisterNativeObject(object obj, string name, bool isGwt)
        {
            if (objects.ContainsKey(name))
                objects[name] = new NativeObjectHolder(obj, isGwt);
            else
                objects.Add(name, new NativeObjectHolder(obj, isGwt));
        }

        private object ConvertParameter(object param, Type expectedType)
        {
            // ints all come through as Int64s.  These need converting to ints.
            if (param is Int64)
            {
                if (expectedType != new Int32().GetType())
                {
                    throw new InvalidOperationException(param + " is an int, but expected " + expectedType);
{'fraction_non_alphanumeric': 0.0790273556231003, 'fraction_numerical': 0.005210594876248371, 'mean_word_length': 2.388235294117647, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5621877', 'n_tokens_mistral': 581, 'n_tokens_neox': 566, 'n_words': 174}