-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom types? #131
Comments
Thank you for the kind compliments. You can use any types in Expressive but you will have limited support within the existing functions/operators. As an example you could add in a What are you hoping to achieve with this custom type? |
Thanks for getting back to me. Time codes are used extensively in film, television, and digital media in place of regular time stamps. The primary purpose is to have alignment with individual video pictures called "frames" as the sub-second unit of measure in video files and streams. I am planning to open-source a pure C# time code library that my company has been using for quite a while now in production. If you could help me understand how to integrate it into Expressive properly, I think it could benefit many people in the industry. For reference, time code is standardized by the SMPTE organization and is often referred to as SMPTE time code: https://en.wikipedia.org/wiki/SMPTE_timecode. For anyone using Expressive in this space, they would probably find immense value in having built-in support for time codes. |
@bijington Do you think you could describe what it would take to add native support for our Time Code library? we would be interested in taking on the work ourselves. We've gotten things to work partially through registering custom functions but it's pretty limited. |
@jheliker I will have a think on this and try to come back with an approach as quickly as I can. I have always wanted to consider being able to add in new types such as It would also be really nice to move away from the helper classes that do a lot of the logic around operator support. Just to clarify what exactly do you need to support these Time Codes with? operators ( If you would be able to clarify what you need that may help my understanding of how we can achieve this |
Thanks, @bijington ! For our Time Code class, we have full operator overloads already implemented including IComparable and IEquatable and would love to be able to leverage all of it with Expressive if possible... |
Would you be willing to share your class? If not that's totally fine. I've just been thinking on whether I can expose certain interfaces if there aren't underlying ones to solve this |
Hey @bijington - we've open-sourced our time code library as of this morning, please take a look! |
Hey @bijington any feedback on the Time Code library? If you've got a direction we can work in, would be glad to take on the effort of getting native time code support in Expressive. Thank you! |
Hey @jheliker sorry things have got in the way of getting around to coming up with a design for this. My initial thinking is to follow a similar concept to the generic maths additions to C#. I like the idea of having interfaces like With your TimeCode type, do you expect to be able to add other types to it e.g. |
@jheliker what version of .NET are you building against? I would love to be able to achieve something like this: https://learn.microsoft.com/en-us/dotnet/api/system.numerics.iadditionoperators-3?view=net-7.0 but it would require jumping all the way up to .NET 7.0 |
This is far from working but it proves a general concept I think could work: public interface IAdditionOperator
{
object Add(object right);
}
public class TimeCode : IAdditionOperator
{
public object Add(object right)
{
if (right is TimeCode2 timeCode2)
{
return this + timeCode2;
}
// TODO: What to do here?
}
public static TimeCode operator +(TimeCode tc1, TimeCode tc2)
{
if (tc1 is null)
{
throw new ArgumentNullException(nameof(tc1));
}
return tc1.Add(tc2);
}
public TimeCode Add(TimeCode timeCode)
{
// Actual magic from TimeCode class.
}
}
public class Numbers
{
public object Add(object lhs, object rhs)
{
if (lhs is IAdditionOperator additionOperator)
{
return additionOperator.Add(rhs);
}
// Remaining add code...
}
}
What do you think? |
First of all - thanks for the fantastic library!
Question: how can we support custom variable types? For example in addition to DateTime my code often refers to TimeCode variables (for broadcast TV work). It is my understanding that these types with various properties cannot be utilized in Expressive?
If custom is not possible, perhaps we can get involved in contributing to support some additional types.
Thank you!
The text was updated successfully, but these errors were encountered: