Skip to content
This repository was archived by the owner on Nov 10, 2017. It is now read-only.

Commit e8eb00c

Browse files
committed
Applied C# 6.0 feature.
Such as string Interpolation and nameof operator.
1 parent 1ecb2c1 commit e8eb00c

File tree

5 files changed

+24
-25
lines changed

5 files changed

+24
-25
lines changed

src/Sitecore.Azure.Diagnostics.UI/sitecore/Shell/Applications/Reports/LogViewer/LogViewerForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Delete([NotNull] ClientPipelineArgs args)
7878
var blob = LogStorageManager.GetBlob(blobName);
7979
blob.DeleteAsync();
8080

81-
Log.Audit(string.Format("Delete the '{0}' cloud blob.", blob.Name), this);
81+
Log.Audit($"Delete the '{blob.Name}' cloud blob.", this);
8282
this.SetBlob(string.Empty);
8383
}
8484
catch (Exception ex)

src/Sitecore.Azure.Diagnostics/Appenders/AzureBlobStorageAppender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public AzureBlobStorageAppender()
105105
/// <param name="loggingEvents">The logging events.</param>
106106
protected override void SendBuffer(LoggingEvent[] loggingEvents)
107107
{
108-
Sitecore.Diagnostics.Assert.ArgumentNotNull(loggingEvents, "loggingEvents");
108+
Sitecore.Diagnostics.Assert.ArgumentNotNull(loggingEvents, nameof(loggingEvents));
109109

110110
var content = new StringBuilder();
111111

src/Sitecore.Azure.Diagnostics/Storage/AzureBlobStorageProvider.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ protected string Encoding
209209
/// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
210210
public override void Initialize(string name, NameValueCollection config)
211211
{
212-
Assert.ArgumentNotNullOrEmpty(name, "name");
213-
Assert.ArgumentNotNull(config, "config");
212+
Assert.ArgumentNotNullOrEmpty(name, nameof(name));
213+
Assert.ArgumentNotNull(config, nameof(config));
214214

215215
base.Initialize(name, config);
216216

@@ -226,7 +226,7 @@ public override void Initialize(string name, NameValueCollection config)
226226
/// <returns>The cloud BLOB container.</returns>
227227
public virtual CloudBlobContainer GetContainer(string containerName)
228228
{
229-
Assert.ArgumentNotNull(containerName, "containerName");
229+
Assert.ArgumentNotNull(containerName, nameof(containerName));
230230

231231
var container = this.CloudBlobClient.GetContainerReference(containerName);
232232

@@ -247,12 +247,12 @@ public virtual CloudBlobContainer GetContainer(string containerName)
247247
/// <returns>The specified cloud blob.</returns>
248248
public virtual ICloudBlob CreateBlob(string blobName)
249249
{
250-
Assert.ArgumentNotNull(blobName, "blobName");
250+
Assert.ArgumentNotNull(blobName, nameof(blobName));
251251

252252
string webRoleRelativeAddress = this.GetWebsiteRelativeAddress();
253253

254254
// Build blob name for a Role Environment using the following format: {DeploymentId}/{RoleInstanceId}/{BlobName}.
255-
blobName = string.IsNullOrEmpty(webRoleRelativeAddress) ? blobName : string.Format("{0}/{1}", webRoleRelativeAddress, blobName);
255+
blobName = string.IsNullOrEmpty(webRoleRelativeAddress) ? blobName : $"{webRoleRelativeAddress}/{blobName}";
256256

257257
var blob = this.CloudBlobContainer.Exists() ?
258258
this.CloudBlobContainer.GetAppendBlobReference(blobName) :
@@ -269,7 +269,7 @@ public virtual ICloudBlob CreateBlob(string blobName)
269269
/// <exception cref="System.NotImplementedException"></exception>
270270
public virtual ICloudBlob GetBlob(string blobName)
271271
{
272-
Assert.ArgumentNotNull(blobName, "blobName");
272+
Assert.ArgumentNotNull(blobName, nameof(blobName));
273273

274274
ICloudBlob blob = this.CloudBlobContainer.Exists() ?
275275
this.CloudBlobContainer.GetBlobReferenceFromServer(blobName) :
@@ -287,8 +287,8 @@ public virtual ICloudBlob GetBlob(string blobName)
287287
/// <exception cref="System.NotImplementedException"></exception>
288288
public virtual ICloudBlob GetBlob(string containerName, string blobName)
289289
{
290-
Assert.ArgumentNotNull(containerName, "containerName");
291-
Assert.ArgumentNotNull(blobName, "blobName");
290+
Assert.ArgumentNotNull(containerName, nameof(containerName));
291+
Assert.ArgumentNotNull(blobName, nameof(blobName));
292292

293293
return this.GetContainer(containerName).GetBlobReferenceFromServer(blobName);
294294
}
@@ -300,7 +300,7 @@ public virtual ICloudBlob GetBlob(string containerName, string blobName)
300300
/// <returns>The collection of cloud blobs.</returns>
301301
public virtual ICollection<ICloudBlob> ListBlobs(string searchPattern)
302302
{
303-
Assert.ArgumentNotNull(searchPattern, "searchPattern");
303+
Assert.ArgumentNotNull(searchPattern, nameof(searchPattern));
304304

305305
return this.ListBlobs(this.CloudBlobContainer, searchPattern);
306306
}
@@ -313,8 +313,8 @@ public virtual ICollection<ICloudBlob> ListBlobs(string searchPattern)
313313
/// <returns>The collection of cloud blobs.</returns>
314314
public virtual ICollection<ICloudBlob> ListBlobs(string containerName, string searchPattern)
315315
{
316-
Assert.ArgumentNotNull(containerName, "containerName");
317-
Assert.ArgumentNotNull(searchPattern, "searchPattern");
316+
Assert.ArgumentNotNull(containerName, nameof(containerName));
317+
Assert.ArgumentNotNull(searchPattern, nameof(searchPattern));
318318

319319
var container = this.GetContainer(containerName);
320320
return this.ListBlobs(container, searchPattern);
@@ -328,8 +328,8 @@ public virtual ICollection<ICloudBlob> ListBlobs(string containerName, string se
328328
/// <returns>The collection of cloud blobs.</returns>
329329
public virtual ICollection<ICloudBlob> ListBlobs(CloudBlobContainer container, string searchPattern)
330330
{
331-
Assert.ArgumentNotNull(container, "container");
332-
Assert.ArgumentNotNull(searchPattern, "searchPattern");
331+
Assert.ArgumentNotNull(container, nameof(container));
332+
Assert.ArgumentNotNull(searchPattern, nameof(searchPattern));
333333

334334
string webRoleRelativeAddress = this.GetWebsiteRelativeAddress();
335335
var blobList = container.ListBlobs(webRoleRelativeAddress, true).Cast<ICloudBlob>().ToList();

src/Sitecore.Azure.Diagnostics/Tasks/BlobCleaner.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class BlobCleaner : IBlobCleaner
3737
/// <param name="configNode">The config node.</param>
3838
public BlobCleaner(XmlNode configNode)
3939
{
40-
Assert.ArgumentNotNull(configNode, "configNode");
40+
Assert.ArgumentNotNull(configNode, nameof(configNode));
4141

4242
NameValueCollection configSettings = XmlUtil.GetAttributes(configNode);
4343

@@ -51,7 +51,7 @@ public BlobCleaner(XmlNode configNode)
5151
this.maxAge = DateUtil.ParseTimeSpan(configSettings["maxAge"], TimeSpan.FromDays(7));
5252
if (this.maxAge == TimeSpan.Zero)
5353
{
54-
Log.Warn(string.Format("Scheduling.BlobsCleanupAgent: The 'maxAge' attribute equals to '{0:dd\\.hh\\:mm\\:ss}'. All blobs will be deleted imitatively.", TimeSpan.Zero), this);
54+
Log.Warn($"Scheduling.BlobsCleanupAgent: The 'maxAge' attribute equals to '{TimeSpan.Zero:dd\\.hh\\:mm\\:ss}'. All blobs will be deleted imitatively.", this);
5555
}
5656
}
5757

@@ -87,7 +87,7 @@ public virtual void Execute()
8787
}
8888
else
8989
{
90-
Log.Warn(string.Format("Scheduling.BlobsCleanupAgent: The '{0}' cloud blob container has not been found.", container.Name), this);
90+
Log.Warn($"Scheduling.BlobsCleanupAgent: The '{container.Name}' cloud blob container has not been found.", this);
9191
}
9292
}
9393

@@ -108,7 +108,7 @@ protected void Cleanup(CloudBlobContainer container)
108108
}
109109
else
110110
{
111-
Log.Info(string.Format("Scheduling.BlobsCleanupAgent: The '{0}' cloud blob container does not have any out-to-date blobs that match the '{1}' search pattern.", container.Name, this.BlobSearchPattern), this);
111+
Log.Info($"Scheduling.BlobsCleanupAgent: The '{container.Name}' cloud blob container does not have any out-to-date blobs that match the '{this.BlobSearchPattern}' search pattern.", this);
112112
}
113113
}
114114

@@ -124,7 +124,7 @@ protected ICollection<ICloudBlob> GetCandidateBlobs(CloudBlobContainer container
124124
Assert.ArgumentNotNull(searchPattern, "searchPattern");
125125

126126
var blobList = LogStorageManager.ListBlobs(container, searchPattern);
127-
Log.Info(string.Format("Scheduling.BlobsCleanupAgent: The '{0}' cloud blob container includes '{1}' blobs that match the '{2}' search pattern.", container.Name, blobList.Count(), searchPattern), this);
127+
Log.Info($"Scheduling.BlobsCleanupAgent: The '{container.Name}' cloud blob container includes '{blobList.Count()}' blobs that match the '{searchPattern}' search pattern.", this);
128128

129129
var candidateBlobList = new List<ICloudBlob>();
130130

@@ -143,7 +143,7 @@ protected ICollection<ICloudBlob> GetCandidateBlobs(CloudBlobContainer container
143143

144144
if (candidateBlobList.Any())
145145
{
146-
Log.Info(string.Format("Scheduling.BlobsCleanupAgent: The '{0}' cloud blob container includes '{1}' out-to-date blobs that match the '{2}' search pattern.", container.Name, candidateBlobList.Count(), searchPattern), this);
146+
Log.Info($"Scheduling.BlobsCleanupAgent: The '{container.Name}' cloud blob container includes '{candidateBlobList.Count()}' out-to-date blobs that match the '{searchPattern}' search pattern.", this);
147147
}
148148

149149
return candidateBlobList;
@@ -187,8 +187,7 @@ protected void DeleteBlobs(IEnumerable<ICloudBlob> blobsList)
187187

188188
TimeSpan age = this.GetBlobAge(blob);
189189

190-
Log.Info(string.Format("Scheduling.BlobsCleanupAgent: The '{0}' cloud blob is being deleted by cleanup task (Last Modified UTC Date: '{1}', Age: '{2:dd\\.hh\\:mm\\:ss}', Max allowed age: '{3}'.",
191-
blob.Name, this.GetBlobLastModifiedDate(blob), age, this.maxAge), this);
190+
Log.Info($"Scheduling.BlobsCleanupAgent: The '{blob.Name}' cloud blob is being deleted by cleanup task (Last Modified UTC Date: '{this.GetBlobLastModifiedDate(blob)}', Age: '{age:dd\\.hh\\:mm\\:ss}', Max allowed age: '{this.maxAge}'.", this);
192191
}
193192
}
194193

src/Sitecore.Azure.Diagnostics/Tasks/BlobsCleanupAgent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public BlobsCleanupAgent()
4040
/// </summary>
4141
public virtual void Run()
4242
{
43-
this.LogInfo(string.Format("Scheduling.BlobsCleanupAgent: Started. The BlobCleaner count is '{0}'.", this.blobsCleaners.Count));
43+
this.LogInfo($"Scheduling.BlobsCleanupAgent: Started. The BlobCleaner count is '{this.blobsCleaners.Count}'.");
4444

4545
foreach (IBlobCleaner cleaner in this.blobsCleaners)
4646
{
@@ -50,7 +50,7 @@ public virtual void Run()
5050
}
5151
catch (Exception exception)
5252
{
53-
Log.Error(string.Format("Scheduling.BlobsCleanupAgent: Exception occurred while cleaning the '{0}' cloud blob container.", cleaner.ContainerName), exception, this);
53+
Log.Error($"Scheduling.BlobsCleanupAgent: Exception occurred while cleaning the '{cleaner.ContainerName}' cloud blob container.", exception, this);
5454
}
5555
}
5656

0 commit comments

Comments
 (0)