Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reuse ProgressBar in Web Cmdlets
  • Loading branch information
iSazonov committed Mar 24, 2017
commit 3e692721879f71265be20c6ef187d90e30a3cf18
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,12 @@ private void Initialize()
{
long totalLength = 0;
byte[] buffer = new byte[StreamHelper.ChunkSize];
ProgressRecord record = new ProgressRecord(StreamHelper.ActivityId, WebCmdletStrings.ReadResponseProgressActivity, StringUtil.Format(WebCmdletStrings.ReadResponseProgressStatus, 0));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringUtil.Format(WebCmdletStrings.ReadResponseProgressStatus, 0)

This is not necessary here. How about just new ProgressRecord(StreamHelper.ActivityId, WebCmdletStrings.ReadResponseProgressActivity, "statusDescriptionPlaceholder"). Then "statusDescriptionPlaceholder" would be a constant.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we cannot use String.Empty - ProgressRecord don't allow. So if we want a const it may be " " (single space). Is it well?
new ProgressRecord(StreamHelper.ActivityId, WebCmdletStrings.ReadResponseProgressActivity, " ")
or
new ProgressRecord(StreamHelper.ActivityId, WebCmdletStrings.ReadResponseProgressActivity, singleSpace) string static singleSpace = " ";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just using the string statusDescriptionPlaceholder as the placeholder?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

for (int read = 1; 0 < read; totalLength += read)
{
if (null != _ownerCmdlet)
{
ProgressRecord record = new ProgressRecord(StreamHelper.ActivityId,
WebCmdletStrings.ReadResponseProgressActivity,
StringUtil.Format(WebCmdletStrings.ReadResponseProgressStatus, totalLength));
record.StatusDescription = StringUtil.Format(WebCmdletStrings.ReadResponseProgressStatus, totalLength);
_ownerCmdlet.WriteProgress(record);

if (_ownerCmdlet.IsStopping)
Expand All @@ -301,9 +300,7 @@ private void Initialize()

if (_ownerCmdlet != null)
{
ProgressRecord record = new ProgressRecord(StreamHelper.ActivityId,
WebCmdletStrings.ReadResponseProgressActivity,
StringUtil.Format(WebCmdletStrings.ReadResponseComplete, totalLength));
record.StatusDescription = StringUtil.Format(WebCmdletStrings.ReadResponseComplete, totalLength);
record.RecordType = ProgressRecordType.Completed;
_ownerCmdlet.WriteProgress(record);
}
Expand Down