-
Notifications
You must be signed in to change notification settings - Fork 343
TrackingCollectionChangedEventArgs Generics #664
Comments
How would you register a handler for any kind of collection change? If it was generic you could only register to a specific type. So you would need to know in advance which types will be used in collections and have one handler per type, hardly a workable solution. |
Here are a bunch of cases where
^Not an issue, because TrackingCollection is a generic class.. xenko/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/EnableDynamicNavigation.cs Line 30 in 6fca455
^Not an issue either, because the programmer clearly knows which types he is expecting. .
^Not an issue, since TrackingHashSet is a generic class..
^ TrackingDictionary is generic. And this is probably not an issue either.. xenko/sources/engine/SiliconStudio.Xenko.Input/VirtualButton/VirtualButtonConfig.cs Line 23 in 6fca455
^ VirtualButtonConfig : TrackingCollection<VirtualButtonBinding> The type is known.
^The type is also known here .
^The type is known . xenko/sources/common/core/SiliconStudio.Core/Collections/ITrackingCollectionChanged.cs Line 7 in 6fca455
^The interface ITrackingCollectionChanged can easily be turned into a generic one. .
^This might be an issue. However, if I'm not mistaken, all of those cases can be worked around by having some code that ensures backwards compatibility: class TrackingCollectionChangedEventArgs<T>
{
public static implicit operator TrackingCollectionChangedEventArgs(TrackingCollectionChangedEventArgs<T> stuff)
{
return (X<object>)stuff;
}
}
class TrackingCollectionChangedEventArgs : TrackingCollectionChangedEventArgs<object>
{
} Let me know if you find a case that wouldn't work. Or if I made a mistake somewhere. |
Is there a reason why
TrackingCollectionChangedEventArgs
isn't a generic class?TrackingHashSet<T>
and other classes are generic, so, it seems like it would make sense to make the events generic as well.As in:
The text was updated successfully, but these errors were encountered: