I need to make an adapter class.
trip.Resource is an enum named ModalityResource.
transportOrderTrip.ModalityResource is a string.
if(Enum.IsDefined(typeof(ModalityResource), transportOrderTrip.ModalityResource))
trip.Resource = Enum.Parse(typeof(ModalityResource), transportOrderTrip.ModalityResource, true);
Possible values for ModalityResource here:
public enum ModalityResource { NONE, CHASSIS, TRAILER }
The error i get is this one: Cannot implicitly convert type 'object' to 'ModalityResource'. Anyone might know what is wrong?
Edit: Never mind, was bit confused.
trip.Resource = (ModalityResource) Enum.Parse(typeof (Shared.Interfaces.ModalityResource), transportOrderTrip.ModalityResource, true);