<commit_before>﻿using RocketLeagueReplayParser.NetworkStream;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Collections;

namespace RocketLeagueReplayParser.Serializers
{
    public class MetadataPropertyConverter : JavaScriptConverter
    {
        bool _raw;
        Func<long, double> _frameToTimeCallback;

        public MetadataPropertyConverter(bool raw, Func<long, double> frameToTimeCallback)
        {
            _raw = raw;
            _frameToTimeCallback = frameToTimeCallback;
        }

        public override IEnumerable<Type> SupportedTypes
        {
            get
            {
                return new[] { typeof(Property) };
            }
        }

        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            throw new NotSupportedException();
        }

        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var p = obj as Property;

            object value = p.Value;
            if ( p.Name == "frame" )
            {
                value = _frameToTimeCallback((int)value);
            }
            return new Dictionary<string, object> { { p.Name, value } };
        }
    }

    public class MetadataPropertyDictionaryConverter : JavaScriptConverter
    {
        bool _raw;
        Func<long, double> _frameToTimeCallback;
        MetadataPropertyConverter propertyConverter;

        public MetadataPropertyDictionaryConverter(bool raw, Func<long, double> frameToTimeCallback)
        {
            _raw = raw;
            _frameToTimeCallback = frameToTimeCallback;
            propertyConverter = new MetadataPropertyConverter(_raw, _frameToTimeCallback);
        }<commit_msg>Fix renaming of "frame" property to "Time" when converted<commit_after>﻿using RocketLeagueReplayParser.NetworkStream;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Collections;

namespace RocketLeagueReplayParser.Serializers
{
    public class MetadataPropertyConverter : JavaScriptConverter
    {
        bool _raw;
        Func<long, double> _frameToTimeCallback;

        public MetadataPropertyConverter(bool raw, Func<long, double> frameToTimeCallback)
        {
            _raw = raw;
            _frameToTimeCallback = frameToTimeCallback;
        }

        public override IEnumerable<Type> SupportedTypes
        {
            get
            {
                return new[] { typeof(Property) };
            }
        }

        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            throw new NotSupportedException();
        }

        public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            var p = obj as Property;

            object value = p.Value;
            var name = p.Name;
            if (name == "frame" )
            {
                name = "Time";
                value = _frameToTimeCallback((int)value);
            }
            return new Dictionary<string, object> { { name, value } };
        }
    }

    public class MetadataPropertyDictionaryConverter : JavaScriptConverter
    {
        bool _raw;
        Func<long, double> _frameToTimeCallback;
        MetadataPropertyConverter propertyConverter;

        public MetadataPropertyDictionaryConverter(bool raw, Func<long, double> frameToTimeCallback)
        {
            _raw = raw;
            _frameToTimeCallback = frameToTimeCallback;
            propertyConverter = new MetadataPropertyConverter(_raw, _frameToTimeCallback);
        }
{'fraction_non_alphanumeric': 0.07038648579472741, 'fraction_numerical': 0.0, 'mean_word_length': 2.357388316151203, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5451318', 'n_tokens_mistral': 963, 'n_tokens_neox': 938, 'n_words': 233}