libplctag / libplctag.NET

A .NET wrapper for libplctag.

Home Page:https://libplctag.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose more TagOfT properties to ITag interface

Devqon opened this issue · comments

We use this driver with a generic wrapper to expose the tag functionality. We therefore have a method that looks like this:

public static ITag MapToLibPlcTag(Type type)
{
    return type switch
    {
        Type _ when type == typeof(bool) => new TagBool(),
        Type _ when type == typeof(int) => new TagDint(),
        // .. etc.
        _ => throw new NotSupportedException();
    };
}

This exposes the ITag to our wrapper, but we do need some of the functionality that is 'hidden' in the TagOfT<> for polling mechanisms, like the AutoSyncReadInterval and all of the events (ReadStarted, ReadCompleted etc.).

There is no way to expose a TagOfT<> instead of the ITag, because that needs a compile-time generic where we only have a runtime System.Type.

Is there a reason that these properties aren't exposed through the ITag interface?

EDIT
It seems that at the time the ITag interface was introduced (#77), these properties did not exist yet. Is my conclusion correct that when the new properties were introduced they should have been added to the ITag?