Sha256: 60011930765f8764dd71e1d8c0260ae3336ede94a16ea316e91c804e99b11218

Contents?: true

Size: 803 Bytes

Versions: 52

Compression:

Stored size: 803 Bytes

Contents

using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;

namespace Generators.Input
{
    public class CanonicalDataParser
    {
        private readonly CanonicalDataFile _canonicalDataFile;

        public CanonicalDataParser(CanonicalDataOptions options)
        {
            _canonicalDataFile = new CanonicalDataFile(options);
            _canonicalDataFile.DownloadData();
        }

        public CanonicalData Parse(Exercise exercise)
        {
            var canonicalDataJson = _canonicalDataFile.Contents(exercise.Name);
            var canonicalData = JsonConvert.DeserializeObject<CanonicalData>(canonicalDataJson);
            
            Validator.ValidateObject(canonicalData, new ValidationContext(canonicalData));

            return canonicalData;
        }
    }
}

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
trackler-2.2.1.24 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.23 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.22 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.21 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.20 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.19 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.18 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.17 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.16 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.15 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.14 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.13 tracks/csharp/generators/Input/CanonicalDataParser.cs