// influenced by NodaTime.Serialization.Protobuf/NodaExtensions.cs ToProtobufDuration etc
        // and NodaTime.Serialization.Protobuf/ProtobufExtensions.cs ToNodaDuration etc

        /// <summary>
        /// Registers protobuf-net serialization surrogates for all supported NodaTime primitives.
        /// </summary>
        /// <param name="model">The model to extend (<see cref="RuntimeTypeModel.Default"/> is assumed if it is <c>null</c>)</param>.
        /// <returns>The model instance.</returns>
        public static RuntimeTypeModel AddNodaTime(this RuntimeTypeModel model)
        {
            model ??= RuntimeTypeModel.Default;
            // use surrogates for Duration and Instant - we already have good support for these
            model.SetSurrogate <NodaTime.Duration, WellKnownTypes.Duration>(ToProtoBufDuration, ToNodaTimeDuration)
            .SetSurrogate <NodaTime.Instant, WellKnownTypes.Timestamp>(ToProtoBufTimestamp, ToNodaTimeInstant);

            // the enum has matching values; can just configure the names
            Add(model, typeof(NodaTime.IsoDayOfWeek), ".google.type.DayOfWeek", "google/type/dayofweek.proto", null);

            // use custom serializer for LocalTime/LocalDate
            Add(model, typeof(NodaTime.LocalDate), ".google.type.Date", "google/type/date.proto", typeof(NodaTimeSerializers));
            Add(model, typeof(NodaTime.LocalTime), ".google.type.TimeOfDay", "google/type/timeofday.proto", typeof(NodaTimeSerializers));
            return(model);