Sha256: c6cfd59d44b266d1211a183e20f7da97f00d7d85502fb3ae189f4b8dc9e78623

Contents?: true

Size: 1.15 KB

Versions: 86

Compression:

Stored size: 1.15 KB

Contents

using Generators.Input;
using Generators.Output;

namespace Generators.Exercises
{
    public class Minesweeper : GeneratorExercise
    {
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var canonicalDataCase in canonicalData.Cases)
            {
                canonicalDataCase.UseVariablesForInput = true;
                canonicalDataCase.UseVariableForExpected = true;

                canonicalDataCase.Properties["input"] = ToMultiLineString(canonicalDataCase.Properties["input"]);
                canonicalDataCase.Properties["expected"] = ToMultiLineString(canonicalDataCase.Properties["expected"]);
            }
        }

        private UnescapedValue ToMultiLineString(string[] input)
        {
            const string template = 
@"new string[] 
{ 
    {% if input.size > 0 %}{% for item in {{input}} %}{% if forloop.length == 1 %}""{{item}}""{% break %}{% endif %}""{{item}}""{% if forloop.last == false %},{% else %}{{string.Empty}}{% endif %}
    {% endfor %}{% endif %} 
}";

            return new UnescapedValue(TemplateRenderer.RenderInline(template, new { input }));
        }
    }
}

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
trackler-2.2.1.151 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.150 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.149 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.148 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.147 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.146 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.145 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.144 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.143 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.142 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.141 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.140 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.139 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.138 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.137 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.136 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.135 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.134 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.133 tracks/csharp/generators/Exercises/Minesweeper.cs
trackler-2.2.1.132 tracks/csharp/generators/Exercises/Minesweeper.cs