@@ -165,8 +165,10 @@ public static string MangleMethodClass(AmqpClass c, AmqpMethod m) {
165
165
public bool m_versionOverridden = false ;
166
166
public int m_majorVersion ;
167
167
public int m_minorVersion ;
168
+ public int ? m_revision ;
168
169
public string m_apiName ;
169
170
public bool m_emitComments = false ;
171
+ public bool m_supportsRedirect ;
170
172
171
173
public Type m_modelType = typeof ( RabbitMQ . Client . Impl . IFullModel ) ;
172
174
public ArrayList m_modelTypes = new ArrayList ( ) ;
@@ -281,6 +283,11 @@ public void ParseSpec() {
281
283
if ( ! m_versionOverridden ) {
282
284
m_majorVersion = GetInt ( m_spec , "/amqp/@major" ) ;
283
285
m_minorVersion = GetInt ( m_spec , "/amqp/@minor" ) ;
286
+ if ( m_spec . SelectSingleNode ( "/amqp/@revision" ) != null )
287
+ {
288
+ m_revision = GetInt ( m_spec , "/amqp/@revision" ) ;
289
+ }
290
+
284
291
}
285
292
foreach ( XmlNode n in m_spec . SelectNodes ( "/amqp/constant" ) ) {
286
293
m_constants . Add ( new DictionaryEntry ( GetString ( n , "@name" ) , GetInt ( n , "@value" ) ) ) ;
@@ -290,7 +297,10 @@ public void ParseSpec() {
290
297
}
291
298
foreach ( XmlNode n in m_spec . SelectNodes ( "/amqp/domain" ) ) {
292
299
m_domains [ GetString ( n , "@name" ) ] = GetString ( n , "@type" ) ;
293
- }
300
+ }
301
+ m_supportsRedirect =
302
+ m_spec . SelectSingleNode (
303
+ "/amqp/class[@name='connection']/method[@name='redirect']" ) != null ;
294
304
}
295
305
296
306
public void ReflectModel ( ) {
@@ -416,11 +426,18 @@ public void EmitPublic() {
416
426
EmitLine ( " public override int MajorVersion { get { return " + m_majorVersion + "; } }" ) ;
417
427
EmitLine ( " ///<summary>Protocol minor version (= " + m_minorVersion + ")</summary>" ) ;
418
428
EmitLine ( " public override int MinorVersion { get { return " + m_minorVersion + "; } }" ) ;
429
+ EmitLine ( " ///<summary>Protocol revision (= " +
430
+ ( m_revision . HasValue ? m_revision . ToString ( ) : "not specified" ) + ")</summary>" ) ;
431
+ EmitLine ( " public override int? Revision { get { return " +
432
+ ( m_revision . HasValue ? m_revision . ToString ( ) : "null" ) + "; } }" ) ;
419
433
EmitLine ( " ///<summary>Protocol API name (= " + m_apiName + ")</summary>" ) ;
420
434
EmitLine ( " public override string ApiName { get { return \" " + m_apiName + "\" ; } }" ) ;
421
435
int port = GetInt ( m_spec , "/amqp/@port" ) ;
422
436
EmitLine ( " ///<summary>Default TCP port (= " + port + ")</summary>" ) ;
423
437
EmitLine ( " public override int DefaultPort { get { return " + port + "; } }" ) ;
438
+ EmitLine ( " ///<summary>Whether redirect is supported</summary>" ) ;
439
+ EmitLine ( " public override bool SupportsRedirect { get { return "
440
+ + m_supportsRedirect . ToString ( ) . ToLower ( ) + "; } }" ) ;
424
441
EmitLine ( "" ) ;
425
442
EmitMethodArgumentReader ( ) ;
426
443
EmitLine ( "" ) ;
@@ -811,7 +828,10 @@ public void EmitModelImplementation() {
811
828
if ( method . Name . StartsWith ( "Handle" ) ||
812
829
( Attribute ( method , typeof ( AmqpAsynchronousHandlerAttribute ) ) != null ) )
813
830
{
814
- asynchronousHandlers . Add ( method ) ;
831
+ if ( ( Attribute ( method , typeof ( AmqpMethodDoNotImplementAttribute ) ) == null ) )
832
+ {
833
+ asynchronousHandlers . Add ( method ) ;
834
+ }
815
835
} else {
816
836
MaybeEmitModelMethod ( method ) ;
817
837
}
@@ -828,7 +848,14 @@ public void EmitContentHeaderFactory(MethodInfo method) {
828
848
string contentClass = factoryAnnotation . m_contentClass ;
829
849
EmitModelMethodPreamble ( method ) ;
830
850
EmitLine ( " {" ) ;
831
- EmitLine ( " return new " + MangleClass ( contentClass ) + "Properties();" ) ;
851
+ if ( Attribute ( method , typeof ( AmqpUnsupportedAttribute ) ) != null )
852
+ {
853
+ EmitLine ( String . Format ( " return default({0});" , method . ReturnType ) ) ;
854
+ }
855
+ else
856
+ {
857
+ EmitLine ( " return new " + MangleClass ( contentClass ) + "Properties();" ) ;
858
+ }
832
859
EmitLine ( " }" ) ;
833
860
}
834
861
@@ -1100,26 +1127,35 @@ public void EmitAsynchronousHandlers(ArrayList asynchronousHandlers) {
1100
1127
string implClass = MangleMethodClass ( amqpClass , amqpMethod ) ;
1101
1128
1102
1129
EmitLine ( " case " + ( ( amqpClass . Index << 16 ) | amqpMethod . Index ) + ": {" ) ;
1103
- ParameterInfo [ ] parameters = method . GetParameters ( ) ;
1130
+ ParameterInfo [ ] parameters = method . GetParameters ( ) ;
1104
1131
if ( parameters . Length > 0 ) {
1105
- EmitLine ( " " + implClass + " __impl = (" + implClass + ") __method;" ) ;
1132
+ EmitLine ( " " + implClass + " __impl = (" + implClass + ") __method;" ) ;
1106
1133
EmitLine ( " " + method . Name + "(" ) ;
1107
1134
int remaining = parameters . Length ;
1108
1135
foreach ( ParameterInfo pi in parameters ) {
1109
- if ( Attribute ( pi , typeof ( AmqpContentHeaderMappingAttribute ) ) != null ) {
1110
- Emit ( " (" + pi . ParameterType + ") cmd.Header" ) ;
1111
- } else if ( Attribute ( pi , typeof ( AmqpContentBodyMappingAttribute ) ) != null ) {
1112
- Emit ( " cmd.Body" ) ;
1113
- } else {
1114
- AmqpFieldMappingAttribute fieldMapping =
1115
- Attribute ( pi , typeof ( AmqpFieldMappingAttribute ) ) as AmqpFieldMappingAttribute ;
1116
- Emit ( " __impl.m_" + ( fieldMapping == null
1117
- ? pi . Name
1118
- : fieldMapping . m_fieldName ) ) ;
1119
- }
1120
1136
remaining -- ;
1121
- if ( remaining > 0 ) {
1122
- EmitLine ( "," ) ;
1137
+ if ( Attribute ( pi , typeof ( AmqpUnsupportedAttribute ) ) == null )
1138
+ {
1139
+ if ( Attribute ( pi , typeof ( AmqpContentHeaderMappingAttribute ) ) != null )
1140
+ {
1141
+ Emit ( " (" + pi . ParameterType + ") cmd.Header" ) ;
1142
+ }
1143
+ else if ( Attribute ( pi , typeof ( AmqpContentBodyMappingAttribute ) ) != null )
1144
+ {
1145
+ Emit ( " cmd.Body" ) ;
1146
+ }
1147
+ else
1148
+ {
1149
+ AmqpFieldMappingAttribute fieldMapping =
1150
+ Attribute ( pi , typeof ( AmqpFieldMappingAttribute ) ) as AmqpFieldMappingAttribute ;
1151
+ Emit ( " __impl.m_" + ( fieldMapping == null
1152
+ ? pi . Name
1153
+ : fieldMapping . m_fieldName ) ) ;
1154
+ }
1155
+ if ( remaining > 0 )
1156
+ {
1157
+ EmitLine ( "," ) ;
1158
+ }
1123
1159
}
1124
1160
}
1125
1161
EmitLine ( ");" ) ;
0 commit comments