public static LocationMessage ToLocationMessage(this ILocationMessage self) { if (self.Title == null) { throw new InvalidOperationException("The title cannot be null."); } if (self.Address == null) { throw new InvalidOperationException("The address cannot be null."); } if (self is LocationMessage locationMessage) { return(locationMessage); } return(new LocationMessage() { Title = self.Title, Address = self.Address, Latitude = self.Latitude, Longitude = self.Longitude }); }
internal static LocationMessage Convert(ILocationMessage message) { if (message.Title == null) { throw new InvalidOperationException("The title cannot be null."); } if (message.Address == null) { throw new InvalidOperationException("The address cannot be null."); } if (message is LocationMessage locationMessage) { return(locationMessage); } return(new LocationMessage() { Title = message.Title, Address = message.Address, Latitude = message.Latitude, Longitude = message.Longitude }); }