<commit_before>﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Skybrud.Umbraco.GridData.Interfaces;
using Skybrud.Umbraco.GridData.Values;

namespace Skybrud.Umbraco.GridData {
    
    public class PiggyBank {
        
        readonly Dictionary<string, Func<JToken, IGridControlValue>> _oink = new Dictionary<string, Func<JToken, IGridControlValue>>();
 
        private static readonly PiggyBank NomNom = new PiggyBank();

        public static PiggyBank OneLittlePiggy {
            get { return NomNom; }
        }

        public Func<JToken, IGridControlValue> this[string comeHereLittlePiggy] {
            get { return _oink[comeHereLittlePiggy]; }
            set { _oink[comeHereLittlePiggy] = value; }
        }

        private PiggyBank() {

            _oink["media"] = ConvertMediaValue;
            _oink["embed"] = ConvertEmbedValue;
            _oink["rte"] = ConvertRichTextValue;
            _oink["macro"] = ConvertMacroValue;
            
        }

        public bool TryGetValue(string alias, out Func<JToken, IGridControlValue> func) {
            return _oink.TryGetValue(alias, out func);
        }

        public static IGridControlValue ConvertMediaValue(JToken token) {

            // At this point the token should be a JObject, but we cast it safely to be sure
            JObject obj = token as JObject;

            // Return the converted media value (or NULL if the object is already NULL)
            return obj == null ? null : obj.ToObject<GridControlMediaValue>();

        }

        public static IGridControlValue ConvertEmbedValue(JToken token) {
            return new GridControlEmbedValue {
                Value = token.Value<string>()
            };
        }

        public static IGridControlValue ConvertRichTextValue(JToken token) {
            return new GridControlRichTextValue {
                Value = token.Value<string>()
            };
        }

        public static IGridControlValue ConvertMacroValue(JToken token) {
            return new GridControlMacroValue();
        }
    
    }<commit_msg>Added "quote" and "headline" valuetypes<commit_after>﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Skybrud.Umbraco.GridData.Interfaces;
using Skybrud.Umbraco.GridData.Values;

namespace Skybrud.Umbraco.GridData {
    
    public class PiggyBank {
        
        readonly Dictionary<string, Func<JToken, IGridControlValue>> _oink = new Dictionary<string, Func<JToken, IGridControlValue>>();
 
        private static readonly PiggyBank NomNom = new PiggyBank();

        public static PiggyBank OneLittlePiggy {
            get { return NomNom; }
        }

        public Func<JToken, IGridControlValue> this[string comeHereLittlePiggy] {
            get { return _oink[comeHereLittlePiggy]; }
            set { _oink[comeHereLittlePiggy] = value; }
        }

        private PiggyBank() {

            _oink["media"] = ConvertMediaValue;
            _oink["embed"] = ConvertEmbedValue;
            _oink["rte"] = ConvertRichTextValue;
            _oink["macro"] = ConvertMacroValue;
            _oink["quote"] = ConvertTextValue;
            _oink["headline"] = ConvertTextValue;
            
        }

        public bool TryGetValue(string alias, out Func<JToken, IGridControlValue> func) {
            return _oink.TryGetValue(alias, out func);
        }

        public static IGridControlValue ConvertMediaValue(JToken token) {

            // At this point the token should be a JObject, but we cast it safely to be sure
            JObject obj = token as JObject;

            // Return the converted media value (or NULL if the object is already NULL)
            return obj == null ? null : obj.ToObject<GridControlMediaValue>();

        }

        public static IGridControlValue ConvertEmbedValue(JToken token) {
            return new GridControlEmbedValue {
                Value = token.Value<string>()
            };
        }

        public static IGridControlValue ConvertRichTextValue(JToken token) {
            return new GridControlRichTextValue {
                Value = token.Value<string>()
            };
        }

        public static IGridControlValue ConvertMacroValue(JToken token) {
            return new GridControlMacroValue();
        }

        public static IGridControlValue ConvertTextValue(JToken token)
        {
            return new GridControlTextValue
            {
                Value = token.Value<string>()
            };
        }
    
    }
{'fraction_non_alphanumeric': 0.07863436123348018, 'fraction_numerical': 0.0, 'mean_word_length': 2.2160056657223794, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '1202460', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1196, 'n_words': 306}