DeltaDizzy
DeltaDizzy
CC#
Created by DeltaDizzy on 3/1/2024 in #help
Using a concrete derived type in place of an interface in a constructor signature
I have a base class whose constructor takes in an instance of a generic interface: public Odometry(IKinematics<TSpeeds, TPositions> kinematics, ... ) in a derived class's constructor, in its place I have a type that fully implements that interface: DifferentialDriveKinematics : IKinematics<DifferentialDriveWheelSpeeds, DifferentialDriveWheelPositions> but the language complains that there is no corresponding argument: There is no argument given that corresponds to the required parameter 'kinematics' of 'Odometry<DifferentialDriveWheelSpeeds, DifferentialDriveWheelPositions>.Odometry(IKinematics<DifferentialDriveWheelSpeeds, DifferentialDriveWheelPositions>, Rotation2d, DifferentialDriveWheelPositions, Pose2d)' is that just not something that can be done (i.e. the interface argument type has to be there all the way down the inheritance chain without any further specialization until something is actually passed in)? The API design is such that I would prefer not to leak the interface to the end user and want the particular concrete type to be part of the constructor signature.
5 replies
CC#
Created by DeltaDizzy on 1/22/2023 in #help
✅ Determine the .NET type of a json object
I have a json generated by another program that i want to deserialize and manipulate the data of (using newtonsoft.json), but I am unsure what the .NET type I am deserializing it into should look like. The json file is attached.
12 replies