using RobotNet.ScriptManager.Helpers;

namespace RobotNet.ScriptManager.Models;

public class ScriptVariableSyntax(string name, Type type, object? defaultValue, bool publicRead, bool publicWrite)
{
    public string Name { get; } = name;
    public Type Type { get; } = type;
    public string TypeName { get; } = CSharpSyntaxHelper.ToTypeString(type);
    public object? DefaultValue { get; } = defaultValue;
    public bool PublicRead { get; } = publicRead;
    public bool PublicWrite { get; } = publicWrite;

    public override bool Equals(object? obj)
    {
        if (obj == null) return false;
        if(obj is not ScriptVariableSyntax variable) return false;
        if (variable.Name != Name) return false;
        return true;
    }

    public override int GetHashCode() => Name.GetHashCode();
}
