Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

I have a programming exam this weekend. It is only one question that is asking to build an application. The final application must be based upon strategy pattern. I can provide an example of the...

1 answer below »
I have a programming exam this weekend. It is only one question that is asking to build an application. The final application must be based upon strategy pattern. I can provide an example of the question and what the answer should look like. Additionally, what my notes are regarding strategy pattern. It is a smaller scope application, so it shouldn’t be too difficult. Please reach out if you have any more questions.
Answered 1 days After Feb 21, 2021

Solution

Pulkit answered on Feb 22 2021
141 Votes
Strategy/CloudDirectory.cspublic class CloudDirectory: IDirectory
{
public void CreateDirectory(string path)
{
string cloudPath = CloudStorageUtility.GetCloudPath(path);
if (cloudPath.IndexOf("/") != -1)
{

create a placeholder as path
CloudBlob blob = CloudStorageUtility.Client.GetBlobReference
(cloudPath + "/:SpaceBlockPlaceholder:");
blob.UploadText("");
}
else
{
CloudBlobContainer container =
CloudStorageUtility.Client.GetContainerReference(cloudPath);
container.CreateIfNotExist();
}
}
public void Delete(string path)
{
string cloudPath = CloudStorageUtility.GetCloudPath(path);
if (cloudPath.IndexOf("/") != -1)
{
CloudBlobDirectory dir =
CloudStorageUtility.Client.GetBlobDirectoryReference(cloudPath + "/");
IEnumerable items = dir.ListBlobs();
foreach (IListBlobItem item in items)
{
if (item.GetType() == typeof(CloudBlobDirectory))
{
Delete(item.Uri.PathAndQuery);
}
else if (item.GetType() == typeof(CloudBlob) ||
item.GetType().BaseType == typeof(CloudBlob))
{
((CloudBlob)item).DeleteIfExists();
}
}
}
else
{
CloudBlobContainer container =
CloudStorageUtility.Client.GetContainerReference(cloudPath);
container.Delete();
}
}
public bool Exists(string path)
{
string cloudPath = CloudStorageUtility.GetCloudPath(path);
CloudBlobContainer container =
CloudStorageUtility.Client.GetContainerReference(cloudPath);
try
{
container.FetchAttributes();
return true;
}
catch
{
return false;
}
}
}
ilistblobitem
Strategy/CloudFile.cspublic class CloudFile: IFile
{
public void...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here