Skip to content

Commit 9034c85

Browse files
committed
Migrated to string interpolation
Replaced string concactenation with string interpolation.
1 parent 08e3ed5 commit 9034c85

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

Ignia.Topics/Collections/AttributeValueCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ private bool EnforceBusinessLogic(AttributeValue originalAttribute, out Attribut
558558
_setCounter++;
559559
if (_setCounter > 3) {
560560
throw new Exception(
561-
"An infinite loop has occurred when setting `" + originalAttribute.Key +
562-
"`; be sure to call `Topic.SetAttributeValue()` when setting attributes from `Topic` properties."
561+
$"An infinite loop has occurred when setting '{originalAttribute.Key}'; be sure that you are referencing " +
562+
$"`Topic.SetAttributeValue()` when setting attributes from `Topic` properties."
563563
);
564564
}
565565
_typeCache.SetPropertyValue(_associatedTopic, originalAttribute.Key, originalAttribute.Value);

Ignia.Topics/Mapping/CachedTopicMappingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private object CacheViewModel(string contentType, object viewModel, (int, Type,
190190
if (cacheKey.Item2 != null) {
191191
cacheKey = (cacheKey.Item1, null, cacheKey.Item3);
192192
}
193-
if (cacheKey.Item1 > 0 && viewModel.GetType().Name.Equals(contentType + "TopicViewModel")) {
193+
if (cacheKey.Item1 > 0 && viewModel.GetType().Name.Equals($"{contentType}TopicViewModel")) {
194194
_cache.TryAdd(cacheKey, viewModel);
195195
}
196196
return viewModel;

Ignia.Topics/Mapping/TopicMappingService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private async Task<object> MapAsync(Topic topic, Relationships relationships, Co
116116
/*----------------------------------------------------------------------------------------------------------------------
117117
| Instantiate object
118118
\---------------------------------------------------------------------------------------------------------------------*/
119-
var viewModelType = _typeLookupService.GetType(topic.ContentType + "TopicViewModel");
119+
var viewModelType = _typeLookupService.GetType($"{topic.ContentType}TopicViewModel");
120120
var target = Activator.CreateInstance(viewModelType);
121121

122122
/*----------------------------------------------------------------------------------------------------------------------
@@ -251,7 +251,7 @@ ConcurrentDictionary<int, object> cache
251251
| Establish per-property variables
252252
\-----------------------------------------------------------------------------------------------------------------------*/
253253
var configuration = new PropertyConfiguration(property);
254-
var topicReferenceId = source.Attributes.GetInteger(property.Name + "Id", 0);
254+
var topicReferenceId = source.Attributes.GetInteger($"{property.Name}Id", 0);
255255

256256
/*------------------------------------------------------------------------------------------------------------------------
257257
| Assign default value
@@ -315,7 +315,7 @@ protected static void SetScalarValue(Topic source, object target, PropertyConfig
315315
/*------------------------------------------------------------------------------------------------------------------------
316316
| Attempt to retrieve value from topic.Get{Property}()
317317
\-----------------------------------------------------------------------------------------------------------------------*/
318-
var attributeValue = _typeCache.GetMethodValue(source, "Get" + configuration.AttributeKey)?.ToString();
318+
var attributeValue = _typeCache.GetMethodValue(source, $"Get{configuration.AttributeKey}")?.ToString();
319319

320320
/*------------------------------------------------------------------------------------------------------------------------
321321
| Attempt to retrieve value from topic.{Property}
@@ -473,7 +473,7 @@ protected IList<Topic> GetSourceCollection(Topic source, Relationships relations
473473
| Handle Metadata relationship
474474
\-----------------------------------------------------------------------------------------------------------------------*/
475475
if (listSource.Count == 0 && !String.IsNullOrWhiteSpace(configuration.MetadataKey)) {
476-
var metadataKey = "Root:Configuration:Metadata:" + configuration.MetadataKey + ":LookupList";
476+
var metadataKey = $"Root:Configuration:Metadata:{configuration.MetadataKey}:LookupList";
477477
listSource = _topicRepository.Load(metadataKey)?.Children.ToList();
478478
}
479479

Ignia.Topics/Topic.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public Topic(string key, string contentType, Topic parent, int id = -1) {
9797
/// The unique identifier for the <see cref="Topic"/>.
9898
/// </value>
9999
/// <exception cref="ArgumentException">
100-
/// The value of this topic has already been set to " + _id + "; it cannot be changed.
100+
/// The value of this topic has already been set to {_id}; it cannot be changed.
101101
/// </exception>
102102
/// <requires description="The id is expected to be a positive value." exception="T:System.ArgumentException">
103103
/// value &gt; 0
@@ -107,7 +107,7 @@ public int Id {
107107
set {
108108
Contract.Requires<ArgumentOutOfRangeException>(value > 0, "The id is expected to be a positive value.");
109109
if (_id > 0 && !_id.Equals(value)) {
110-
throw new ArgumentException("The value of this topic has already been set to " + _id + "; it cannot be changed.");
110+
throw new ArgumentException($"The value of this topic has already been set to {_id}; it cannot be changed.");
111111
}
112112
_id = value;
113113
}
@@ -405,8 +405,8 @@ public DateTime LastModified {
405405
/// <param name="sibling">The <see cref="Topic" /> to move this <see cref="Topic" /> to the right of.</param>
406406
/// <exception cref="ArgumentOutOfRangeException">parent - A descendant cannot be its own parent.</exception>
407407
/// <exception cref="InvalidKeyException">
408-
/// Duplicate key when setting Parent property: the topic with the name '" + Key + "' already exists in the '" +
409-
/// parent.Key + "' topic.
408+
/// Duplicate key when setting Parent property: the topic with the name '{Key}' already exists in the '{parent.Key}'
409+
/// topic.
410410
/// </exception>
411411
public void SetParent(Topic parent, Topic sibling = null) {
412412

@@ -428,9 +428,9 @@ public void SetParent(Topic parent, Topic sibling = null) {
428428
\-----------------------------------------------------------------------------------------------------------------------*/
429429
if (parent != _parent && parent.Children.Contains(Key)) {
430430
throw new InvalidKeyException(
431-
"Duplicate key when setting Parent property: the topic with the name '" + Key +
432-
"' already exists in the '" + parent.Key + "' topic."
433-
);
431+
$"Duplicate key when setting Parent property: the topic with the name '{Key}' already exists in the '{parent.Key}' " +
432+
$"topic."
433+
);
434434
}
435435

436436
/*------------------------------------------------------------------------------------------------------------------------
@@ -478,7 +478,7 @@ public string GetUniqueKey() {
478478
var topic = this;
479479

480480
for (var i = 0; i < 100; i++) {
481-
if (uniqueKey.Length > 0) uniqueKey = ":" + uniqueKey;
481+
if (uniqueKey.Length > 0) uniqueKey = $":{uniqueKey}";
482482
uniqueKey = topic.Key + uniqueKey;
483483
topic = topic.Parent;
484484
if (topic == null) break;
@@ -507,7 +507,7 @@ public string GetWebPath() {
507507
Contract.Ensures(Contract.Result<string>() != null);
508508
var uniqueKey = GetUniqueKey().Replace("Root:", "/").Replace(":", "/") + "/";
509509
if (!uniqueKey.StartsWith("/")) {
510-
uniqueKey = "/" + uniqueKey;
510+
uniqueKey = $"/{uniqueKey}";
511511
}
512512
return uniqueKey;
513513
}

0 commit comments

Comments
 (0)