Skip to content

Commit 7fbb021

Browse files
committed
Add interface select and expand methods and clean base methods slightly.
1 parent a6ed68a commit 7fbb021

File tree

2 files changed

+55
-11
lines changed

2 files changed

+55
-11
lines changed

Templates/CSharp/Base/EntityRequest.Base.template.tt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,32 +486,34 @@ public string GetExpandMethod(string requestType)
486486
public string GetEntityExpandMethods(OdcmClass odcmClass)
487487
{
488488
string entityName = this.GetEntityNameString(odcmClass);
489-
return this.GetExpandMethod(this.GetRequestString(this.GetEntityNameString(odcmClass))) +
489+
return this.GetExpandMethod(this.GetRequestString(entityName)) +
490490
Environment.NewLine + Environment.NewLine + " " +
491491
this.GetExpandExpressionMethod(this.GetRequestString(entityName), entityName);
492492
}
493493

494494
public string GetEntitySelectMethods(OdcmClass odcmClass)
495495
{
496496
string entityName = this.GetEntityNameString(odcmClass);
497-
return this.GetSelectMethod(this.GetRequestString(this.GetEntityNameString(odcmClass))) +
497+
return this.GetSelectMethod(this.GetRequestString(entityName)) +
498498
Environment.NewLine + Environment.NewLine + " " +
499499
this.GetSelectExpressionMethod(this.GetRequestString(entityName), entityName);
500500
}
501501

502502
// Entity with references
503503
public string GetEntityWithReferenceExpandMethods(OdcmClass odcmClass)
504504
{
505-
return this.GetExpandMethod(this.GetEntityWithReferenceRequestName(odcmClass)) +
505+
string entityWithReferenceRequestName = this.GetEntityWithReferenceRequestName(odcmClass);
506+
return this.GetExpandMethod(entityWithReferenceRequestName) +
506507
Environment.NewLine + Environment.NewLine + " " +
507-
this.GetExpandExpressionMethod(this.GetEntityWithReferenceRequestName(odcmClass), this.GetEntityNameString(odcmClass));
508+
this.GetExpandExpressionMethod(entityWithReferenceRequestName, this.GetEntityNameString(odcmClass));
508509
}
509510

510511
public string GetEntityWithReferenceSelectMethods(OdcmClass odcmClass)
511512
{
513+
string entityWithReferenceRequestName = this.GetEntityWithReferenceRequestName(odcmClass);
512514
return this.GetSelectMethod(this.GetEntityWithReferenceRequestName(odcmClass)) +
513515
Environment.NewLine + Environment.NewLine + " " +
514-
this.GetSelectExpressionMethod(this.GetEntityWithReferenceRequestName(odcmClass), this.GetEntityNameString(odcmClass));
516+
this.GetSelectExpressionMethod(entityWithReferenceRequestName, this.GetEntityNameString(odcmClass));
515517
}
516518

517519
#>

Templates/CSharp/Base/IEntityRequest.Base.template.tt

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,22 @@ public string GetEntityUpdateAsyncMethod(OdcmClass odcmClass)
262262
// Build select and expand methods
263263
// -------------------------------------------------------------
264264

265+
public string GetExpandExpressionMethod(string requestType, string underlyingType)
266+
{
267+
var stringBuilder = new StringBuilder();
268+
269+
stringBuilder.Append(
270+
@"/// <summary>
271+
/// Adds the specified expand value to the request.
272+
/// </summary>
273+
/// <param name=""expandExpression"">The expression from which to calculate the expand value.</param>
274+
/// <returns>The request object to send.</returns>");
275+
stringBuilder.Append(Environment.NewLine);
276+
stringBuilder.AppendFormat(" I{0} Expand(Expression<Func<{1}, object>> expandExpression);", requestType, underlyingType);
277+
278+
return stringBuilder.ToString();
279+
}
280+
265281
public string GetExpandMethod(string entityRequest)
266282
{
267283
var stringBuilder = new StringBuilder();
@@ -274,7 +290,22 @@ public string GetExpandMethod(string entityRequest)
274290
/// <returns>The request object to send.</returns>");
275291
stringBuilder.Append(Environment.NewLine);
276292
stringBuilder.AppendFormat(" I{0} Expand(string value);", entityRequest);
277-
stringBuilder.Append("TODO ExpandExpression");
293+
294+
return stringBuilder.ToString();
295+
}
296+
297+
public string GetSelectExpressionMethod(string requestType, string underlyingType)
298+
{
299+
var stringBuilder = new StringBuilder();
300+
301+
stringBuilder.Append(
302+
@"/// <summary>
303+
/// Adds the specified select value to the request.
304+
/// </summary>
305+
/// <param name=""selectExpression"">The expression from which to calculate the select value.</param>
306+
/// <returns>The request object to send.</returns>");
307+
stringBuilder.Append(Environment.NewLine);
308+
stringBuilder.AppendFormat(" I{0} Select(Expression<Func<{1}, object>> selectExpression);", requestType, underlyingType);
278309

279310
return stringBuilder.ToString();
280311
}
@@ -291,31 +322,42 @@ public string GetSelectMethod(string entityRequest)
291322
/// <returns>The request object to send.</returns>");
292323
stringBuilder.Append(Environment.NewLine);
293324
stringBuilder.AppendFormat(" I{0} Select(string value);", entityRequest);
294-
stringBuilder.Append("TODO SelectExpression");
295325

296326
return stringBuilder.ToString();
297327
}
298328

299329
// Standard entity
300330
public string GetEntityExpandMethods(OdcmClass odcmClass)
301331
{
302-
return this.GetExpandMethod(this.GetRequestString(this.GetEntityNameString(odcmClass)));
332+
string entityName = this.GetEntityNameString(odcmClass);
333+
return this.GetExpandMethod(this.GetRequestString(entityName)) +
334+
Environment.NewLine + Environment.NewLine + " " +
335+
this.GetExpandExpressionMethod(this.GetRequestString(entityName), entityName);
303336
}
304337

305338
public string GetEntitySelectMethods(OdcmClass odcmClass)
306339
{
307-
return this.GetSelectMethod(this.GetRequestString(this.GetEntityNameString(odcmClass)));
340+
string entityName = this.GetEntityNameString(odcmClass);
341+
return this.GetSelectMethod(this.GetRequestString(entityName)) +
342+
Environment.NewLine + Environment.NewLine + " " +
343+
this.GetSelectExpressionMethod(this.GetRequestString(entityName), entityName);
308344
}
309345

310346
// Entity with references
311347
public string GetEntityWithReferenceExpandMethods(OdcmClass odcmClass)
312348
{
313-
return this.GetExpandMethod(this.GetEntityWithReferenceRequestName(odcmClass));
349+
string entityWithReferenceRequestName = this.GetEntityWithReferenceRequestName(odcmClass);
350+
return this.GetExpandMethod(entityWithReferenceRequestName) +
351+
Environment.NewLine + Environment.NewLine + " " +
352+
this.GetExpandExpressionMethod(entityWithReferenceRequestName, this.GetEntityNameString(odcmClass)););
314353
}
315354

316355
public string GetEntityWithReferenceSelectMethods(OdcmClass odcmClass)
317356
{
318-
return this.GetSelectMethod(this.GetEntityWithReferenceRequestName(odcmClass));
357+
string entityWithReferenceRequestName = this.GetEntityWithReferenceRequestName(odcmClass);
358+
return this.GetSelectMethod(entityWithReferenceRequestName) +
359+
Environment.NewLine + Environment.NewLine + " " +
360+
this.GetSelectExpressionMethod(entityWithReferenceRequestName, this.GetEntityNameString(odcmClass)););}
319361
}
320362

321363
#>

0 commit comments

Comments
 (0)