Code/Dependencies/DotNetGraph/Attributes/DotEdgeArrowTypeAttribute.cs
using System.Threading.Tasks;
using Nodebox.Dependencies.DotNetGraph.Compilation;
using Nodebox.Dependencies.DotNetGraph.Core;

namespace Nodebox.Dependencies.DotNetGraph.Attributes {
    public class DotEdgeArrowTypeAttribute : IDotAttribute {
        public string Value { get; set; }

        public DotEdgeArrowTypeAttribute(string value) {
            Value = value;
        }

        public DotEdgeArrowTypeAttribute(DotEdgeArrowType type) {
            Value = type.ToString().ToLowerInvariant();
        }

        public async Task CompileAsync(CompilationContext context) {
            await context.WriteAsync($"\"{Value}\"");
        }

        public static implicit operator DotEdgeArrowTypeAttribute(DotEdgeArrowType value) => new DotEdgeArrowTypeAttribute(value);
        public static implicit operator DotEdgeArrowTypeAttribute(string value) => new DotEdgeArrowTypeAttribute(value);
    }
}