Sha256: ccd359c2299d7dba83cb5e44eb6f67daf9b41e4c28bd8a1be010e55a9dbc8037

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

using System.Collections;
using Generators.Input;
using Generators.Output;
namespace Generators.Exercises
{
    public class Triangle : GeneratorExercise
    {
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var data in canonicalData.Cases)
            {
                if (data.Property == "equilateral")
                    data.Property = "IsEquilateral";
                else if (data.Property == "isosceles")
                    data.Property = "IsIsosceles";
                else if (data.Property == "scalene")
                    data.Property = "IsScalene";

                data.Input["sides"] = SplitArrayToValues(data.Input["sides"]);
                data.SetInputParameters("sides");
                data.UseFullDescriptionPath = true;

            }
        }

        private UnescapedValue SplitArrayToValues(IEnumerable input)
        {
            const string template = "{% for item in {{input}} %}{{item}}{% if forloop.last == false %}, {% endif %}{% endfor %}";

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

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.158 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.157 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.156 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.155 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.154 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.153 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.152 tracks/csharp/generators/Exercises/Triangle.cs