<commit_before>﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Resources;
using System.Text;

namespace AzureFunctions.ResxConvertor
{
    public class ResxConvertor
    {
        public JObject ConvertResxToJObject(string resxFilePath)
        {
            // Create a ResXResourceReader for the file items.resx.
            ResXResourceReader rsxr = new ResXResourceReader(resxFilePath);

            var jo = new JObject();

            // Iterate through the resources and display the contents to the console.
            foreach (DictionaryEntry d in rsxr)
            {                
                jo[d.Key.ToString()] = d.Value.ToString();
            }

            //Close the reader.
            rsxr.Close();

            return jo;
        }

        public void SaveResxAsTypeScriptFile(string resxFilePath, string outputTSFilePAth)
        {
            var sb = new StringBuilder();
            sb.AppendLine("// This file is auto generated");
            sb.AppendLine("");
            sb.AppendLine("export class PortalResources");
            sb.AppendLine("{");

            ResXResourceReader rsxr = new ResXResourceReader(resxFilePath);
            foreach (DictionaryEntry d in rsxr)
            {
                sb.AppendLine(string.Format("    public static {0}: string = \"{0}\";", d.Key.ToString()));
            }

            sb.AppendLine("}");

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputTSFilePAth))
            {
                file.WriteLine(sb.ToString());
            }                
        }

    }
}<commit_msg>Remove ConvertResxToJObject<commit_after>﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Resources;
using System.Text;

namespace AzureFunctions.ResxConvertor
{
    public class ResxConvertor
    {
        public void SaveResxAsTypeScriptFile(string resxFilePath, string outputTSFilePAth)
        {
            var sb = new StringBuilder();
            sb.AppendLine("// This file is auto generated");
            sb.AppendLine("");
            sb.AppendLine("export class PortalResources");
            sb.AppendLine("{");

            ResXResourceReader rsxr = new ResXResourceReader(resxFilePath);
            foreach (DictionaryEntry d in rsxr)
            {
                sb.AppendLine(string.Format("    public static {0}: string = \"{0}\";", d.Key.ToString()));
            }

            sb.AppendLine("}");

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputTSFilePAth))
            {
                file.WriteLine(sb.ToString());
            }

            //Close the reader.
            rsxr.Close();
        }

    }
}
{'fraction_non_alphanumeric': 0.1010618820944709, 'fraction_numerical': 0.0014646649578908824, 'mean_word_length': 1.8547544409613375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5098302', 'n_tokens_mistral': 717, 'n_tokens_neox': 701, 'n_words': 166}