<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
namespace OMF
{
    public class OMFReader
    {
        public OMFReader()
        {
            LastError = "";
            SurfaceElements = new List<OMFClasses.SurfaceElement>();
            PointSetElements = new List<OMFClasses.PointSetElement>();
            LineSetElements = new List<OMFClasses.LineSetElement>();
            VolumeElements = new List<OMFClasses.VolumeElement>();
        }
        public string LastError { get; private set; }
        public List<OMFClasses.SurfaceElement> SurfaceElements { get; private set; }
        public List<OMFClasses.PointSetElement> PointSetElements { get; private set; }
        public List<OMFClasses.VolumeElement> VolumeElements { get; private set; }
        public List<OMFClasses.LineSetElement> LineSetElements { get; private set; }

        public bool Execute(string file)
        {
            bool returnvalue = true;

            BinaryReader br = new BinaryReader(File.Open(file, FileMode.Open,FileAccess.Read,FileShare.ReadWrite));

            byte[] magic = br.ReadBytes(4);//4 byte magic number: b'\x81\x82\x83\x84'
            byte[] version = br.ReadBytes(32);//32 byte version string: 'OMF-v0.9.0' (other bytes empty)
            byte[] uid = br.ReadBytes(16);//16 byte project uid (in little-endian bytes)

            ulong jsonPosition = br.ReadUInt64();

            long postionofBlob = br.BaseStream.Position;

            br.BaseStream.Seek((long)jsonPosition, SeekOrigin.Begin);
            byte[] jsonbytes = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length - (long)jsonPosition));
            string jsonstring = Encoding.UTF8.GetString(jsonbytes);


            Dictionary<string, object> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonstring);

            //try
            //{
            foreach (string id in jsonDict.Keys)
            {
                string data = jsonDict[id].ToString();
                Dictionary<string, object> thisDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);

                if (thisDict.ContainsKey("__class__"))
                {
                    switch (thisDict["__class__"].ToString().ToUpper())
                    {
                        case "SURFACEELEMENT":
                            {
                                OMFClasses.SurfaceElement obj = (OMFClasses.SurfaceElement)OMFClasses.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    SurfaceElements.Add(obj);
                                }
                            }
                            break;
                        case "POINTSETELEMENT":
                            {
                                OMFClasses.PointSetElement obj = (OMFClasses.PointSetElement)OMFClasses.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    PointSetElements.Add(obj);
                                }
                            }
                            break;
                        case "VOLUMELEMENT":
                            {
                                OMFClasses.VolumeElement obj = (OMFClasses.VolumeElement)OMFClasses.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    VolumeElements.Add(obj);
                                }
                            }
                            break;
                        case "LINESETELEMENT":
                            {
                                OMFClasses.LineSetElement obj = (OMFClasses.LineSetElement)OMFClasses.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    LineSetElements.Add(obj);
                                }
                            }
                            break;

                    }
                }

            }
            //}
            //catch(Exception ex)
            //{
            // LastError=ex.Message;
            //returnvalue=false;
            //}
            //finally
            //{
            br.Close();
            //}

            return returnvalue;

        }

    }
}<commit_msg>Fix build issue<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
namespace OMF
{
    public class OMFReader
    {
        public OMFReader()
        {
            LastError = "";
            SurfaceElements = new List<OMF.Objects.SurfaceElement>();
            PointSetElements = new List<OMF.Objects.PointSetElement>();
            LineSetElements = new List<OMF.Objects.LineSetElement>();
            VolumeElements = new List<OMF.Objects.VolumeElement>();
        }
        public string LastError { get; private set; }
        public List<OMF.Objects.SurfaceElement> SurfaceElements { get; private set; }
        public List<OMF.Objects.PointSetElement> PointSetElements { get; private set; }
        public List<OMF.Objects.VolumeElement> VolumeElements { get; private set; }
        public List<OMF.Objects.LineSetElement> LineSetElements { get; private set; }

        public bool Execute(string file)
        {
            bool returnvalue = true;

            BinaryReader br = new BinaryReader(File.Open(file, FileMode.Open,FileAccess.Read,FileShare.ReadWrite));

            byte[] magic = br.ReadBytes(4);//4 byte magic number: b'\x81\x82\x83\x84'
            byte[] version = br.ReadBytes(32);//32 byte version string: 'OMF-v0.9.0' (other bytes empty)
            byte[] uid = br.ReadBytes(16);//16 byte project uid (in little-endian bytes)

            ulong jsonPosition = br.ReadUInt64();

            long postionofBlob = br.BaseStream.Position;

            br.BaseStream.Seek((long)jsonPosition, SeekOrigin.Begin);
            byte[] jsonbytes = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length - (long)jsonPosition));
            string jsonstring = Encoding.UTF8.GetString(jsonbytes);


            Dictionary<string, object> jsonDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonstring);

            //try
            //{
            foreach (string id in jsonDict.Keys)
            {
                string data = jsonDict[id].ToString();
                Dictionary<string, object> thisDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);

                if (thisDict.ContainsKey("__class__"))
                {
                    switch (thisDict["__class__"].ToString().ToUpper())
                    {
                        case "SURFACEELEMENT":
                            {
                                OMF.Objects.SurfaceElement obj = (OMF.Objects.SurfaceElement)OMF.Objects.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    SurfaceElements.Add(obj);
                                }
                            }
                            break;
                        case "POINTSETELEMENT":
                            {
                                OMF.Objects.PointSetElement obj = (OMF.Objects.PointSetElement)OMF.Objects.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    PointSetElements.Add(obj);
                                }
                            }
                            break;
                        case "VOLUMELEMENT":
                            {
                                OMF.Objects.VolumeElement obj = (OMF.Objects.VolumeElement)OMF.Objects.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    VolumeElements.Add(obj);
                                }
                            }
                            break;
                        case "LINESETELEMENT":
                            {
                                OMF.Objects.LineSetElement obj = (OMF.Objects.LineSetElement)OMF.Objects.ObjectFactory.GetObjectFromData(jsonDict, br, data);
                                if (obj != null)
                                {
                                    LineSetElements.Add(obj);
                                }
                            }
                            break;

                    }
                }

            }
            //}
            //catch(Exception ex)
            //{
            // LastError=ex.Message;
            //returnvalue=false;
            //}
            //finally
            //{
            br.Close();
            //}

            return returnvalue;

        }

    }
}
{'fraction_non_alphanumeric': 0.0900064752859918, 'fraction_numerical': 0.005611914526224908, 'mean_word_length': 1.197533791795115, 'pattern_counts': {'":': 8, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3048574', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2155, 'n_words': 394}