44using NServiceBus . Serialization ;
55using Hyperion ;
66
7- class HyperionMessageSerializer : IMessageSerializer
8- {
9- Serializer serializer ;
7+ class HyperionMessageSerializer : IMessageSerializer
8+ {
9+ Serializer serializer ;
1010
11- public HyperionMessageSerializer ( string contentType , SerializerOptions options )
11+ public HyperionMessageSerializer ( string contentType , SerializerOptions options )
12+ {
13+ if ( options == null )
1214 {
13- if ( options == null )
14- {
15- serializer = new Serializer ( ) ;
16- }
17- else
18- {
19- serializer = new Serializer ( options ) ;
20- }
21-
22- if ( contentType == null )
23- {
24- ContentType = "hyperion" ;
25- }
26- else
27- {
28- ContentType = contentType ;
29- }
15+ serializer = new Serializer ( ) ;
16+ }
17+ else
18+ {
19+ serializer = new Serializer ( options ) ;
3020 }
3121
32- public void Serialize ( object message , Stream stream )
22+ if ( contentType == null )
3323 {
34- var messageType = message . GetType ( ) ;
35- if ( messageType . Name . EndsWith ( "__impl" ) )
36- {
37- throw new Exception ( "Interface based message are not currently supported. Create a class that implements the desired interface." ) ;
38- }
39- serializer . Serialize ( message , stream ) ;
24+ ContentType = "hyperion" ;
4025 }
26+ else
27+ {
28+ ContentType = contentType ;
29+ }
30+ }
4131
42- public object [ ] Deserialize ( Stream stream , IList < Type > messageTypes = null )
32+ public void Serialize ( object message , Stream stream )
33+ {
34+ var messageType = message . GetType ( ) ;
35+ if ( messageType . Name . EndsWith ( "__impl" ) )
4336 {
44- return new [ ] { serializer . Deserialize ( stream ) } ;
37+ throw new Exception ( "Interface based message are not currently supported. Create a class that implements the desired interface." ) ;
4538 }
4639
47- public string ContentType { get ; }
48- }
40+ serializer . Serialize ( message , stream ) ;
41+ }
42+
43+ public object [ ] Deserialize ( Stream stream , IList < Type > messageTypes = null )
44+ {
45+ return new [ ] { serializer . Deserialize ( stream ) } ;
46+ }
47+
48+ public string ContentType { get ; }
49+ }
0 commit comments