<commit_before>﻿using System;
using System.IO;
using Windows.ApplicationModel;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage;
using Windows.System.Profile;
using Newtonsoft.Json;

namespace FHSDK.Services.Device
{
    /// <summary>
    ///     Device info service for windows phone
    /// </summary>
    internal class DeviceService : IDeviceService
    {
        private const string LocalConfigFileName = "fhconfig.local.json";

        public string GetDeviceId()
        {
            var token = HardwareIdentification.GetPackageSpecificToken(null);
            var hardwareId = token.Id;

            var hasher = HashAlgorithmProvider.OpenAlgorithm("MD5");
            var hashed = hasher.HashData(hardwareId);

            var hashedString = CryptographicBuffer.EncodeToHexString(hashed);
            return hashedString;
        }

        public AppProps ReadAppProps()
        {
            AppProps appProps;
            var isLocalDev = false;
            var file = GetFile(Constants.LocalConfigFileName);
            if (null != file)
            {
                isLocalDev = true;
            }
            else
            {
                file = GetFile(Constants.ConfigFileName);
            }
            if (null != file)
            {
                var json = FileIO.ReadTextAsync(file).AsTask().Result;
                appProps = JsonConvert.DeserializeObject<AppProps>(json);
                appProps.IsLocalDevelopment = isLocalDev;
            }
            else
            {
                throw new IOException("Can not find resource " + Constants.ConfigFileName);
            }
            return appProps;
        }

        public string GetDeviceDestination()
        {
            return "windowsphone8";
        }

        private static StorageFile GetFile(string fileName)
        {
            StorageFile file = null;
            try
            {
                var folder = Package.Current.InstalledLocation;
                file = folder.GetFileAsync(fileName).AsTask().Result;
            }<commit_msg>fix tests?<commit_after>﻿using System;
using System.IO;
using Windows.ApplicationModel;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage;
using Windows.System.Profile;
using Newtonsoft.Json;

namespace FHSDK.Services.Device
{
    /// <summary>
    ///     Device info service for windows phone
    /// </summary>
    internal class DeviceService : IDeviceService
    {
        private const string LocalConfigFileName = "fhconfig.local.json";

        public string GetDeviceId()
        {
            var token = HardwareIdentification.GetPackageSpecificToken(null);
            var hardwareId = token.Id;

            var hasher = HashAlgorithmProvider.OpenAlgorithm("MD5");
            var hashed = hasher.HashData(hardwareId);

            var hashedString = CryptographicBuffer.EncodeToHexString(hashed);
            return hashedString;
        }

        public AppProps ReadAppProps()
        {
            AppProps appProps;
            var isLocalDev = false;
            var file = GetFile(Constants.LocalConfigFileName);
            if (null != file)
            {
                isLocalDev = true;
            }
            else
            {
                file = GetFile(Constants.ConfigFileName);
            }
            if (null != file)
            {
                var json = FileIO.ReadTextAsync(file).AsTask().Result;
                appProps = JsonConvert.DeserializeObject<AppProps>(json);
                appProps.IsLocalDevelopment = isLocalDev;
            }
            else
            {
                throw new IOException("Can not find resource " + Constants.ConfigFileName);
            }
            return appProps;
        }

        public string GetDeviceDestination()
        {
            return "windowsphone8";
        }

        private static StorageFile GetFile(string fileName)
        {
            StorageFile file = null;
            try
            {
                var folder = StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///" + fileName));
                file = folder.AsTask().Result;
            }
{'fraction_non_alphanumeric': 0.08122786304604486, 'fraction_numerical': 0.0009445100354191264, 'mean_word_length': 1.7136450992953236, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6638033', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1009, 'n_words': 229}