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.64 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.63 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.62 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.61 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.60 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.59 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.58 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.57 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.56 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.55 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.54 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.53 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.52 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.51 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.50 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.49 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.48 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.47 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.46 tracks/csharp/generators/Input/CanonicalDataParser.cs
trackler-2.2.1.45 tracks/csharp/generators/Input/CanonicalDataParser.cs