BlobItemInternal
class BlobItemInternal
An Azure Storage blob.
using Azure.Storage.Common;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Azure.Storage.Blobs.Models
{
internal class BlobItemInternal
{
public BlobName Name { get; }
public bool Deleted { get; }
public string Snapshot { get; }
public string VersionId { get; }
public bool? IsCurrentVersion { get; }
public BlobPropertiesInternal Properties { get; }
public IReadOnlyDictionary<string, string> Metadata { get; }
public BlobTags BlobTags { get; }
public bool? HasVersionsOnly { get; }
public IReadOnlyDictionary<string, string> OrMetadata { get; }
internal BlobItemInternal(BlobName name, bool deleted, string snapshot, BlobPropertiesInternal properties)
{
Argument.AssertNotNull(name, "name");
Argument.AssertNotNull(snapshot, "snapshot");
Argument.AssertNotNull(properties, "properties");
Name = name;
Deleted = deleted;
Snapshot = snapshot;
Properties = properties;
Metadata = new ChangeTrackingDictionary<string, string>();
OrMetadata = new ChangeTrackingDictionary<string, string>();
}
internal BlobItemInternal(BlobName name, bool deleted, string snapshot, string versionId, bool? isCurrentVersion, BlobPropertiesInternal properties, IReadOnlyDictionary<string, string> metadata, BlobTags blobTags, bool? hasVersionsOnly, IReadOnlyDictionary<string, string> orMetadata)
{
Name = name;
Deleted = deleted;
Snapshot = snapshot;
VersionId = versionId;
IsCurrentVersion = isCurrentVersion;
Properties = properties;
Metadata = metadata;
BlobTags = blobTags;
HasVersionsOnly = hasVersionsOnly;
OrMetadata = orMetadata;
}
internal static BlobItemInternal DeserializeBlobItemInternal(XElement element)
{
BlobName name = null;
bool deleted = false;
string snapshot = null;
string versionId = null;
bool? isCurrentVersion = null;
BlobPropertiesInternal properties = null;
IReadOnlyDictionary<string, string> metadata = null;
BlobTags blobTags = null;
bool? hasVersionsOnly = null;
IReadOnlyDictionary<string, string> orMetadata = null;
XElement xElement = element.Element("Name");
if (xElement != null)
name = BlobName.DeserializeBlobName(xElement);
XElement xElement2 = element.Element("Deleted");
if (xElement2 != null)
deleted = (bool)xElement2;
XElement xElement3 = element.Element("Snapshot");
if (xElement3 != null)
snapshot = (string)xElement3;
XElement xElement4 = element.Element("VersionId");
if (xElement4 != null)
versionId = (string)xElement4;
XElement xElement5 = element.Element("IsCurrentVersion");
if (xElement5 != null)
isCurrentVersion = (bool?)xElement5;
XElement xElement6 = element.Element("Properties");
if (xElement6 != null)
properties = BlobPropertiesInternal.DeserializeBlobPropertiesInternal(xElement6);
XElement xElement7 = element.Element("Metadata");
if (xElement7 != null) {
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (XElement item in xElement7.Elements()) {
dictionary.Add(item.Name.LocalName, (string)item);
}
metadata = dictionary;
}
XElement xElement8 = element.Element("Tags");
if (xElement8 != null)
blobTags = BlobTags.DeserializeBlobTags(xElement8);
XElement xElement9 = element.Element("HasVersionsOnly");
if (xElement9 != null)
hasVersionsOnly = (bool?)xElement9;
XElement xElement10 = element.Element("OrMetadata");
if (xElement10 != null) {
Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
foreach (XElement item2 in xElement10.Elements()) {
dictionary2.Add(item2.Name.LocalName, (string)item2);
}
orMetadata = dictionary2;
}
return new BlobItemInternal(name, deleted, snapshot, versionId, isCurrentVersion, properties, metadata, blobTags, hasVersionsOnly, orMetadata);
}
}
}