Skip to content

Commit 0e03573

Browse files
author
Matthias Radestock
committed
merge bug21271 into default
2 parents dc68266 + 61c4687 commit 0e03573

10 files changed

+629
-41
lines changed

src/apigen/Apigen.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,14 @@ public void EmitClassProperties(AmqpClass c) {
482482
EmitLine(" public "+maybeOverride+"void Clear"+MangleClass(f.Name)+"() { m_"+MangleMethod(f.Name)+"_present = false; }");
483483
}
484484
}
485+
486+
EmitLine("");
487+
foreach (AmqpField f in c.m_Fields)
488+
{
489+
if (!IsBoolean(f))
490+
EmitLine(" public " + maybeOverride + "bool Is" + MangleClass(f.Name) + "Present() { return m_" + MangleMethod(f.Name) + "_present; }");
491+
}
492+
485493
EmitLine("");
486494
EmitLine(" public "+MangleClass(c.Name)+"Properties() {}");
487495
EmitLine(" public override int ProtocolClassId { get { return "+c.Index+"; } }");

src/client/api/IBasicProperties.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,48 @@ public interface IBasicProperties : IContentHeader
162162
///<summary> Clear the ClusterId property. </summary>
163163
void ClearClusterId();
164164

165+
///<summary> Returns true iff the ContentType property is present. </summary>
166+
bool IsContentTypePresent();
167+
168+
///<summary> Returns true iff the ContentEncoding property is present. </summary>
169+
bool IsContentEncodingPresent();
170+
171+
///<summary> Returns true iff the Headers property is present. </summary>
172+
bool IsHeadersPresent();
173+
174+
///<summary> Returns true iff the DeliveryMode property is present. </summary>
175+
bool IsDeliveryModePresent();
176+
177+
///<summary> Returns true iff the Priority property is present. </summary>
178+
bool IsPriorityPresent();
179+
180+
///<summary> Returns true iff the CorrelationId property is present. </summary>
181+
bool IsCorrelationIdPresent();
182+
183+
///<summary> Returns true iff the ReplyTo property is present. </summary>
184+
bool IsReplyToPresent();
185+
186+
///<summary> Returns true iff the Expiration property is present. </summary>
187+
bool IsExpirationPresent();
188+
189+
///<summary> Returns true iff the MessageId property is present. </summary>
190+
bool IsMessageIdPresent();
191+
192+
///<summary> Returns true iff the Timestamp property is present. </summary>
193+
bool IsTimestampPresent();
194+
195+
///<summary> Returns true iff the Type property is present. </summary>
196+
bool IsTypePresent();
197+
198+
///<summary> Returns true iff the UserId property is present. </summary>
199+
bool IsUserIdPresent();
200+
201+
///<summary> Returns true iff the AppId property is present. </summary>
202+
bool IsAppIdPresent();
203+
204+
///<summary> Returns true iff the ClusterId property is present. </summary>
205+
bool IsClusterIdPresent();
206+
165207
///<summary>Convenience property; parses ReplyTo property
166208
///using PublicationAddress.Parse, and serializes it using
167209
///PublicationAddress.ToString. Returns null if ReplyTo property

src/client/api/IContentHeader.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@
5454
// Contributor(s): ______________________________________.
5555
//
5656
//---------------------------------------------------------------------------
57+
using System;
58+
5759
namespace RabbitMQ.Client
5860
{
5961
///<summary>A decoded AMQP content header frame.</summary>
60-
public interface IContentHeader
62+
public interface IContentHeader : ICloneable
6163
{
6264
///<summary>Retrieve the AMQP class ID of this content header.</summary>
6365
int ProtocolClassId { get; }

src/client/api/IFileProperties.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,32 @@ public interface IFileProperties : IContentHeader
131131

132132
///<summary> Clear the ClusterId property. </summary>
133133
void ClearClusterId();
134+
135+
///<summary> Returns true iff the ContentType property is present. </summary>
136+
bool IsContentTypePresent();
137+
138+
///<summary> Returns true iff the ContentEncoding property is present. </summary>
139+
bool IsContentEncodingPresent();
140+
141+
///<summary> Returns true iff the Headers property is present. </summary>
142+
bool IsHeadersPresent();
143+
144+
///<summary> Returns true iff the Priority property is present. </summary>
145+
bool IsPriorityPresent();
146+
147+
///<summary> Returns true iff the ReplyTo property is present. </summary>
148+
bool IsReplyToPresent();
149+
150+
///<summary> Returns true iff the MessageId property is present. </summary>
151+
bool IsMessageIdPresent();
152+
153+
///<summary> Returns true iff the Filename property is present. </summary>
154+
bool IsFilenamePresent();
155+
156+
///<summary> Returns true iff the Timestamp property is present. </summary>
157+
bool IsTimestampPresent();
158+
159+
///<summary> Returns true iff the ClusterId property is present. </summary>
160+
bool IsClusterIdPresent();
134161
}
135162
}

src/client/api/IStreamProperties.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,20 @@ public interface IStreamProperties : IContentHeader
107107

108108
///<summary> Clear the Timestamp property. </summary>
109109
void ClearTimestamp();
110+
111+
///<summary> Returns true iff the ContentType property is present. </summary>
112+
bool IsContentTypePresent();
113+
114+
///<summary> Returns true iff the ContentEncoding property is present. </summary>
115+
bool IsContentEncodingPresent();
116+
117+
///<summary> Returns true iff the Headers property is present. </summary>
118+
bool IsHeadersPresent();
119+
120+
///<summary> Returns true iff the Priority property is present. </summary>
121+
bool IsPriorityPresent();
122+
123+
///<summary> Returns true iff the Timestamp property is present. </summary>
124+
bool IsTimestampPresent();
110125
}
111126
}

src/client/impl/BasicProperties.cs

Lines changed: 73 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -57,53 +57,86 @@
5757
using System;
5858
using System.Collections;
5959

60-
namespace RabbitMQ.Client.Impl {
61-
public abstract class BasicProperties: ContentHeaderBase, IBasicProperties {
62-
public abstract string ContentType { get; set; }
63-
public abstract string ContentEncoding { get; set; }
64-
public abstract IDictionary Headers { get; set; }
65-
public abstract byte DeliveryMode { get; set; }
66-
public abstract byte Priority { get; set; }
67-
public abstract string CorrelationId { get; set; }
68-
public abstract string ReplyTo { get; set; }
69-
public abstract string Expiration { get; set; }
70-
public abstract string MessageId { get; set; }
71-
public abstract AmqpTimestamp Timestamp { get; set; }
72-
public abstract string Type { get; set; }
73-
public abstract string UserId { get; set; }
74-
public abstract string AppId { get; set; }
75-
public abstract string ClusterId { get; set; }
60+
namespace RabbitMQ.Client.Impl
61+
{
62+
public abstract class BasicProperties: ContentHeaderBase, IBasicProperties
63+
{
64+
public abstract string ContentType { get; set; }
65+
public abstract string ContentEncoding { get; set; }
66+
public abstract IDictionary Headers { get; set; }
67+
public abstract byte DeliveryMode { get; set; }
68+
public abstract byte Priority { get; set; }
69+
public abstract string CorrelationId { get; set; }
70+
public abstract string ReplyTo { get; set; }
71+
public abstract string Expiration { get; set; }
72+
public abstract string MessageId { get; set; }
73+
public abstract AmqpTimestamp Timestamp { get; set; }
74+
public abstract string Type { get; set; }
75+
public abstract string UserId { get; set; }
76+
public abstract string AppId { get; set; }
77+
public abstract string ClusterId { get; set; }
7678

77-
public abstract void ClearContentType();
78-
public abstract void ClearContentEncoding();
79-
public abstract void ClearHeaders();
80-
public abstract void ClearDeliveryMode();
81-
public abstract void ClearPriority();
82-
public abstract void ClearCorrelationId();
83-
public abstract void ClearReplyTo();
84-
public abstract void ClearExpiration();
85-
public abstract void ClearMessageId();
86-
public abstract void ClearTimestamp();
87-
public abstract void ClearType();
88-
public abstract void ClearUserId();
89-
public abstract void ClearAppId();
90-
public abstract void ClearClusterId();
79+
public abstract void ClearContentType();
80+
public abstract void ClearContentEncoding();
81+
public abstract void ClearHeaders();
82+
public abstract void ClearDeliveryMode();
83+
public abstract void ClearPriority();
84+
public abstract void ClearCorrelationId();
85+
public abstract void ClearReplyTo();
86+
public abstract void ClearExpiration();
87+
public abstract void ClearMessageId();
88+
public abstract void ClearTimestamp();
89+
public abstract void ClearType();
90+
public abstract void ClearUserId();
91+
public abstract void ClearAppId();
92+
public abstract void ClearClusterId();
9193

92-
public PublicationAddress ReplyToAddress {
93-
get {
94+
public abstract bool IsContentTypePresent();
95+
public abstract bool IsContentEncodingPresent();
96+
public abstract bool IsHeadersPresent();
97+
public abstract bool IsDeliveryModePresent();
98+
public abstract bool IsPriorityPresent();
99+
public abstract bool IsCorrelationIdPresent();
100+
public abstract bool IsReplyToPresent();
101+
public abstract bool IsExpirationPresent();
102+
public abstract bool IsMessageIdPresent();
103+
public abstract bool IsTimestampPresent();
104+
public abstract bool IsTypePresent();
105+
public abstract bool IsUserIdPresent();
106+
public abstract bool IsAppIdPresent();
107+
public abstract bool IsClusterIdPresent();
108+
109+
public PublicationAddress ReplyToAddress
110+
{
111+
get
112+
{
94113
return PublicationAddress.Parse(ReplyTo);
95114
}
96-
set {
115+
set
116+
{
97117
ReplyTo = value.ToString();
98118
}
99119
}
100120

101-
public void SetPersistent(bool persistent) {
102-
if (persistent) {
103-
DeliveryMode = 2;
104-
} else {
105-
DeliveryMode = 1;
106-
}
107-
}
121+
public void SetPersistent(bool persistent)
122+
{
123+
if (persistent)
124+
DeliveryMode = 2;
125+
else
126+
DeliveryMode = 1;
127+
}
128+
129+
public override object Clone()
130+
{
131+
BasicProperties clone = MemberwiseClone() as BasicProperties;
132+
if (IsHeadersPresent())
133+
{
134+
clone.Headers = new Hashtable();
135+
foreach (DictionaryEntry entry in Headers)
136+
clone.Headers[entry.Key] = entry.Value;
137+
}
138+
139+
return clone;
140+
}
108141
}
109142
}

src/client/impl/ContentHeaderBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,10 @@ public void WriteTo(NetworkBinaryWriter writer, ulong bodySize)
9999
writer.Write((ulong)bodySize);
100100
WritePropertiesTo(new ContentHeaderPropertyWriter(writer));
101101
}
102+
103+
public virtual object Clone()
104+
{
105+
throw new NotImplementedException();
106+
}
102107
}
103108
}

src/client/impl/FileProperties.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,28 @@ public abstract class FileProperties : ContentHeaderBase, IFileProperties
8080
public abstract void ClearFilename();
8181
public abstract void ClearTimestamp();
8282
public abstract void ClearClusterId();
83+
84+
public abstract bool IsContentTypePresent();
85+
public abstract bool IsContentEncodingPresent();
86+
public abstract bool IsHeadersPresent();
87+
public abstract bool IsPriorityPresent();
88+
public abstract bool IsReplyToPresent();
89+
public abstract bool IsMessageIdPresent();
90+
public abstract bool IsFilenamePresent();
91+
public abstract bool IsTimestampPresent();
92+
public abstract bool IsClusterIdPresent();
93+
94+
public override object Clone()
95+
{
96+
FileProperties clone = MemberwiseClone() as FileProperties;
97+
if (IsHeadersPresent())
98+
{
99+
clone.Headers = new Hashtable();
100+
foreach (DictionaryEntry entry in Headers)
101+
clone.Headers[entry.Key] = entry.Value;
102+
}
103+
104+
return clone;
105+
}
83106
}
84107
}

src/client/impl/StreamProperties.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,24 @@ public abstract class StreamProperties : ContentHeaderBase, IStreamProperties
7272
public abstract void ClearHeaders();
7373
public abstract void ClearPriority();
7474
public abstract void ClearTimestamp();
75+
76+
public abstract bool IsContentTypePresent();
77+
public abstract bool IsContentEncodingPresent();
78+
public abstract bool IsHeadersPresent();
79+
public abstract bool IsPriorityPresent();
80+
public abstract bool IsTimestampPresent();
81+
82+
public override object Clone()
83+
{
84+
StreamProperties clone = MemberwiseClone() as StreamProperties;
85+
if (IsHeadersPresent())
86+
{
87+
clone.Headers = new Hashtable();
88+
foreach (DictionaryEntry entry in Headers)
89+
clone.Headers[entry.Key] = entry.Value;
90+
}
91+
92+
return clone;
93+
}
7594
}
7695
}

0 commit comments

Comments
 (0)