@@ -109,6 +109,29 @@ public Consumer(string applicationKey, string instanceId = null, string userToke
109109 registrationService = new RegistrationService ( SettingsManager . ConsumerSettings , SessionsManager . ConsumerSessionService ) ;
110110 }
111111
112+ /// <summary>
113+ /// Build up a string of Matrix Parameters based upon the passed parameters.
114+ /// </summary>
115+ /// <param name="zone">Zone associated with a request.</param>
116+ /// <param name="context">Zone context.</param>
117+ /// <returns>String of Matrix Parameters.</returns>
118+ private string MatrixParameters ( string zone = null , string context = null )
119+ {
120+ string matrixParameters = "" ;
121+
122+ if ( ! string . IsNullOrWhiteSpace ( zone ) )
123+ {
124+ matrixParameters += ";zone=" + zone . Trim ( ) ;
125+ }
126+
127+ if ( ! string . IsNullOrWhiteSpace ( context ) )
128+ {
129+ matrixParameters += ";context=" + context . Trim ( ) ;
130+ }
131+
132+ return matrixParameters ;
133+ }
134+
112135 /// <summary>
113136 /// <see cref="IPayloadSerialisable{TSingle,TMultiple}.SerialiseSingle(TSingle)">SerialiseSingle</see>
114137 /// </summary>
@@ -158,17 +181,17 @@ public void Unregister(bool? deleteOnUnregister = null)
158181 }
159182
160183 /// <summary>
161- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TSingle)">Create</see>
184+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TSingle, string, string )">Create</see>
162185 /// </summary>
163- public virtual TSingle Create ( TSingle obj )
186+ public virtual TSingle Create ( TSingle obj , string zone = null , string context = null )
164187 {
165188
166189 if ( ! RegistrationService . Registered )
167190 {
168191 throw new InvalidOperationException ( "Consumer has not registered." ) ;
169192 }
170193
171- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + TypeName ;
194+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + TypeName + MatrixParameters ( zone , context ) ;
172195 string body = SerialiseSingle ( obj ) ;
173196 string xml = HttpUtils . PostRequest ( url , RegistrationService . AuthorisationToken , body ) ;
174197 if ( log . IsDebugEnabled ) log . Debug ( "XML from POST request ..." ) ;
@@ -180,15 +203,15 @@ public virtual TSingle Create(TSingle obj)
180203 /// <summary>
181204 /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TMultiple)">Create</see>
182205 /// </summary>
183- public virtual MultipleCreateResponse Create ( TMultiple obj )
206+ public virtual MultipleCreateResponse Create ( TMultiple obj , string zone = null , string context = null )
184207 {
185208
186209 if ( ! RegistrationService . Registered )
187210 {
188211 throw new InvalidOperationException ( "Consumer has not registered." ) ;
189212 }
190213
191- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" ;
214+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + MatrixParameters ( zone , context ) ;
192215 string body = SerialiseMultiple ( obj ) ;
193216 string xml = HttpUtils . PostRequest ( url , RegistrationService . AuthorisationToken , body ) ;
194217 if ( log . IsDebugEnabled ) log . Debug ( "XML from POST request ..." ) ;
@@ -200,9 +223,9 @@ public virtual MultipleCreateResponse Create(TMultiple obj)
200223 }
201224
202225 /// <summary>
203- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(TPrimaryKey)">Query</see>
226+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(TPrimaryKey, string, string )">Query</see>
204227 /// </summary>
205- public virtual TSingle Query ( TPrimaryKey refId )
228+ public virtual TSingle Query ( TPrimaryKey refId , string zone = null , string context = null )
206229 {
207230
208231 if ( ! RegistrationService . Registered )
@@ -214,7 +237,7 @@ public virtual TSingle Query(TPrimaryKey refId)
214237
215238 try
216239 {
217- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + refId ;
240+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + refId + MatrixParameters ( zone , context ) ;
218241 string xml = HttpUtils . GetRequest ( url , RegistrationService . AuthorisationToken ) ;
219242 if ( log . IsDebugEnabled ) log . Debug ( "XML from GET request ..." ) ;
220243 if ( log . IsDebugEnabled ) log . Debug ( xml ) ;
@@ -248,17 +271,17 @@ public virtual TSingle Query(TPrimaryKey refId)
248271 }
249272
250273 /// <summary>
251- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(uint?, uint?)">Query</see>
274+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(uint?, uint?, string, string )">Query</see>
252275 /// </summary>
253- public virtual TMultiple Query ( uint ? navigationPage = null , uint ? navigationPageSize = null )
276+ public virtual TMultiple Query ( uint ? navigationPage = null , uint ? navigationPageSize = null , string zone = null , string context = null )
254277 {
255278
256279 if ( ! RegistrationService . Registered )
257280 {
258281 throw new InvalidOperationException ( "Consumer has not registered." ) ;
259282 }
260283
261- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" ;
284+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + MatrixParameters ( zone , context ) ;
262285 string xml ;
263286
264287 if ( navigationPage . HasValue && navigationPageSize . HasValue )
@@ -274,17 +297,17 @@ public virtual TMultiple Query(uint? navigationPage = null, uint? navigationPage
274297 }
275298
276299 /// <summary>
277- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByExample(TSingle, uint?, uint?)">Query</see>
300+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByExample(TSingle, uint?, uint?, string, string )">Query</see>
278301 /// </summary>
279- public virtual TMultiple QueryByExample ( TSingle obj , uint ? navigationPage = null , uint ? navigationPageSize = null )
302+ public virtual TMultiple QueryByExample ( TSingle obj , uint ? navigationPage = null , uint ? navigationPageSize = null , string zone = null , string context = null )
280303 {
281304
282305 if ( ! RegistrationService . Registered )
283306 {
284307 throw new InvalidOperationException ( "Consumer has not registered." ) ;
285308 }
286309
287- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" ;
310+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + MatrixParameters ( zone , context ) ;
288311 string body = SerialiseSingle ( obj ) ;
289312 // TODO: Update PostRequest to accept paging parameters.
290313 string xml = HttpUtils . PostRequest ( url , RegistrationService . AuthorisationToken , body , "GET" ) ;
@@ -295,9 +318,9 @@ public virtual TMultiple QueryByExample(TSingle obj, uint? navigationPage = null
295318 }
296319
297320 /// <summary>
298- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByServicePath(IEnumerable{EqualCondition}, uint?, uint?)">Query</see>
321+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByServicePath(IEnumerable{EqualCondition}, uint?, uint?, string, string )">Query</see>
299322 /// </summary>
300- public virtual TMultiple QueryByServicePath ( IEnumerable < EqualCondition > conditions , uint ? navigationPage = null , uint ? navigationPageSize = null )
323+ public virtual TMultiple QueryByServicePath ( IEnumerable < EqualCondition > conditions , uint ? navigationPage = null , uint ? navigationPageSize = null , string zone = null , string context = null )
301324 {
302325
303326 if ( ! RegistrationService . Registered )
@@ -317,7 +340,7 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio
317340
318341 }
319342
320- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + servicePath + "/" + TypeName + "s" ;
343+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + servicePath + "/" + TypeName + "s" + MatrixParameters ( zone , context ) ;
321344 if ( log . IsDebugEnabled ) log . Debug ( "Service Path URL is " + url ) ;
322345 string xml ;
323346
@@ -334,35 +357,35 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio
334357 }
335358
336359 /// <summary>
337- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Update(TSingle)">Update</see>
360+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Update(TSingle, string, string )">Update</see>
338361 /// </summary>
339- public virtual void Update ( TSingle obj )
362+ public virtual void Update ( TSingle obj , string zone = null , string context = null )
340363 {
341364
342365 if ( ! RegistrationService . Registered )
343366 {
344367 throw new InvalidOperationException ( "Consumer has not registered." ) ;
345368 }
346369
347- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + obj . RefId ;
370+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + obj . RefId + MatrixParameters ( zone , context ) ;
348371 string body = SerialiseSingle ( obj ) ;
349372 string xml = HttpUtils . PutRequest ( url , RegistrationService . AuthorisationToken , body ) ;
350373 if ( log . IsDebugEnabled ) log . Debug ( "XML from PUT request ..." ) ;
351374 if ( log . IsDebugEnabled ) log . Debug ( xml ) ;
352375 }
353376
354377 /// <summary>
355- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKeyPK}.Update(TMultiple)">Update</see>
378+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKeyPK}.Update(TMultiple, string, string )">Update</see>
356379 /// </summary>
357- public virtual MultipleUpdateResponse Update ( TMultiple obj )
380+ public virtual MultipleUpdateResponse Update ( TMultiple obj , string zone = null , string context = null )
358381 {
359382
360383 if ( ! RegistrationService . Registered )
361384 {
362385 throw new InvalidOperationException ( "Consumer has not registered." ) ;
363386 }
364387
365- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" ;
388+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + MatrixParameters ( zone , context ) ;
366389 string body = SerialiseMultiple ( obj ) ;
367390 string xml = HttpUtils . PutRequest ( url , RegistrationService . AuthorisationToken , body ) ;
368391 if ( log . IsDebugEnabled ) log . Debug ( "XML from PUT request ..." ) ;
@@ -374,26 +397,26 @@ public virtual MultipleUpdateResponse Update(TMultiple obj)
374397 }
375398
376399 /// <summary>
377- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(TPrimaryKey)">Delete</see>
400+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(TPrimaryKey, string, string )">Delete</see>
378401 /// </summary>
379- public virtual void Delete ( TPrimaryKey refId )
402+ public virtual void Delete ( TPrimaryKey refId , string zone = null , string context = null )
380403 {
381404
382405 if ( ! RegistrationService . Registered )
383406 {
384407 throw new InvalidOperationException ( "Consumer has not registered." ) ;
385408 }
386409
387- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + refId ;
410+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + "/" + refId + MatrixParameters ( zone , context ) ;
388411 string xml = HttpUtils . DeleteRequest ( url , RegistrationService . AuthorisationToken ) ;
389412 if ( log . IsDebugEnabled ) log . Debug ( "XML from DELETE request ..." ) ;
390413 if ( log . IsDebugEnabled ) log . Debug ( xml ) ;
391414 }
392415
393416 /// <summary>
394- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(IEnumerable{TPrimaryKey})">Delete</see>
417+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(IEnumerable{TPrimaryKey}, string, string )">Delete</see>
395418 /// </summary>
396- public virtual MultipleDeleteResponse Delete ( IEnumerable < TPrimaryKey > refIds )
419+ public virtual MultipleDeleteResponse Delete ( IEnumerable < TPrimaryKey > refIds , string zone = null , string context = null )
397420 {
398421
399422 if ( ! RegistrationService . Registered )
@@ -410,7 +433,7 @@ public virtual MultipleDeleteResponse Delete(IEnumerable<TPrimaryKey> refIds)
410433 }
411434
412435 deleteRequestType request = new deleteRequestType { deletes = deleteIds . ToArray ( ) } ;
413- string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" ;
436+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + MatrixParameters ( zone , context ) ;
414437 string body = SerialiserFactory . GetXmlSerialiser < deleteRequestType > ( ) . Serialise ( request ) ;
415438 string xml = HttpUtils . PutRequest ( url , RegistrationService . AuthorisationToken , body , "DELETE" ) ;
416439 if ( log . IsDebugEnabled ) log . Debug ( "XML from PUT (DELETE) request ..." ) ;
0 commit comments