public void CheckPrettyErrors() { var convention = new CustomTypeNameConventionBuilder().GetConvention(); Console.WriteLine( Assert.Throws <ArgumentException>(() => convention.GetTypeName(typeof(string))) ); Console.WriteLine( Assert.Throws <ArgumentException>(() => convention.GetType("string")) ); }
/// <summary> /// Installs a message type name convention that can be customized by making further calls to the builder returned from this method. /// This can be used to improve interoperability of messages, as e.g. /// <code> /// Configure.With(...) /// .(...) /// .Serialization(s => { /// s.UseCustomMessageTypeNames() /// .AddWithCustomName<SomeType>("SomeType"); /// }) /// .Start(); /// </code> /// This will make Rebus put the type name "SomeType" in the <see cref="Headers.Type"/> header, thus removing all of the .NET-specific /// stuff like namespace and assembly information. /// </summary> public static CustomTypeNameConventionBuilder UseCustomMessageTypeNames(this StandardConfigurer <ISerializer> configurer) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } var builder = new CustomTypeNameConventionBuilder(); configurer .OtherService <IMessageTypeNameConvention>() .Register(_ => builder.GetConvention()); return(builder); }