<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;

using UmbracoVault.Exceptions;
using UmbracoVault.Extensions;
using UmbracoVault.TypeHandlers;
using uComponents.DataTypes.DataTypeGrid.Model;

namespace UmbracoVault.uComponents.TypeHandlers
{
    public class DataTypeGridTypeHandler : ITypeHandler
    {
        public object GetAsType<T>(object input)
        {
            var result = new List<T>();
            var rows = input as GridRowCollection;
            if (rows == null)
            {
                return result;
            }
            foreach (var row in rows)
            {
                var item = typeof (T).CreateWithNoParams<T>();

                // ReSharper disable once CompareNonConstrainedGenericWithNull
                if (item == null)
                {
                    throw new ConstructorUnavailableException(typeof (T));
                }

                var currentRow = row;
                Vault.Context.FillClassProperties(item, (alias, recursive) =>
                {
                    // recursive is currently ignored in this case

                    string value = null;
                    if (!string.IsNullOrWhiteSpace(alias) && currentRow != null)
                    {
                        var cell = currentRow.FirstOrDefault(c => c.Alias == alias);
                        if (cell != null)
                        {
                            value = string.IsNullOrWhiteSpace(cell.Value) ? null : cell.Value;
                        }
                    }
<commit_msg>Fixed issue where property names were being compared in a case sensitive manner in DataTypeGridTypeHandler<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;

using UmbracoVault.Exceptions;
using UmbracoVault.Extensions;
using UmbracoVault.TypeHandlers;
using uComponents.DataTypes.DataTypeGrid.Model;

namespace UmbracoVault.uComponents.TypeHandlers
{
    public class DataTypeGridTypeHandler : ITypeHandler
    {
        public object GetAsType<T>(object input)
        {
            var result = new List<T>();
            var rows = input as GridRowCollection;
            if (rows == null)
            {
                return result;
            }
            foreach (var row in rows)
            {
                var item = typeof (T).CreateWithNoParams<T>();

                // ReSharper disable once CompareNonConstrainedGenericWithNull
                if (item == null)
                {
                    throw new ConstructorUnavailableException(typeof (T));
                }

                var currentRow = row;
                Vault.Context.FillClassProperties(item, (alias, recursive) =>
                {
                    // recursive is currently ignored in this case

                    string value = null;
                    if (!string.IsNullOrWhiteSpace(alias) && currentRow != null)
                    {
                        var cell = currentRow.FirstOrDefault(c => c.Alias.Equals(alias, StringComparison.OrdinalIgnoreCase));
                        if (cell != null)
                        {
                            value = string.IsNullOrWhiteSpace(cell.Value) ? null : cell.Value;
                        }
                    }

{'fraction_non_alphanumeric': 0.07586837294332724, 'fraction_numerical': 0.0, 'mean_word_length': 1.5022865853658536, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '6345414', 'n_tokens_mistral': 809, 'n_tokens_neox': 766, 'n_words': 194}