public override int GetHashCode() { int hash = 1; if (LeaseDuration != 0) { hash ^= LeaseDuration.GetHashCode(); } if (AnnouncementPeriod != 0) { hash ^= AnnouncementPeriod.GetHashCode(); } if (DomainIdGain != 0) { hash ^= DomainIdGain.GetHashCode(); } if (PortBase != 0) { hash ^= PortBase.GetHashCode(); } return(hash); }
/// <summary> /// Returns the hash code for this object. /// </summary> /// <returns>A 32-bit signed integer hash code.</returns> public override int GetHashCode() { return(Key.GetHashCode() ^ Queue.GetHashCode() ^ EnqueueTime.GetHashCode() ^ LeasedUntil.GetHashCode() ^ LeaseDuration.GetHashCode() ^ ExpirationTime.GetHashCode() ^ DequeueCount.GetHashCode() ^ Item.GetHashCode()); }
/// <summary> /// Checks the lease status of a container, both from its attributes and from a container listing. /// </summary> /// <param name="container">The container to test.</param> /// <param name="expectedStatus">The expected lease status.</param> /// <param name="expectedState">The expected lease state.</param> /// <param name="expectedDuration">The expected lease duration.</param> /// <param name="description">A description of the circumstances that lead to the expected status.</param> private async Task CheckLeaseStatusAsync( CloudBlobContainer container, LeaseStatus expectedStatus, LeaseState expectedState, LeaseDuration expectedDuration, string description) { await container.FetchAttributesAsync(); Assert.AreEqual(expectedStatus, container.Properties.LeaseStatus, "LeaseStatus mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedState, container.Properties.LeaseState, "LeaseState mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedDuration, container.Properties.LeaseDuration, "LeaseDuration mismatch: " + description + " (from FetchAttributes)"); ContainerResultSegment containers = await this.blobClient.ListContainersSegmentedAsync(container.Name, ContainerListingDetails.None, null, null, null, null); BlobContainerProperties propertiesInListing = (from CloudBlobContainer c in containers.Results where c.Name == container.Name select c.Properties).Single(); Assert.AreEqual(expectedStatus, propertiesInListing.LeaseStatus, "LeaseStatus mismatch: " + description + " (from ListContainers)"); Assert.AreEqual(expectedState, propertiesInListing.LeaseState, "LeaseState mismatch: " + description + " (from ListContainers)"); Assert.AreEqual(expectedDuration, propertiesInListing.LeaseDuration, "LeaseDuration mismatch: " + description + " (from ListContainers)"); }
/// <summary> /// Checks the lease status of a blob, both from its attributes and from a blob listing. /// </summary> /// <param name="blob">The blob to test.</param> /// <param name="expectedStatus">The expected lease status.</param> /// <param name="expectedState">The expected lease state.</param> /// <param name="expectedDuration">The expected lease duration.</param> /// <param name="description">A description of the circumstances that lead to the expected status.</param> private async Task CheckLeaseStatusAsync( CloudBlob blob, LeaseStatus expectedStatus, LeaseState expectedState, LeaseDuration expectedDuration, string description) { await blob.FetchAttributesAsync(); Assert.AreEqual(expectedStatus, blob.Properties.LeaseStatus, "LeaseStatus mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedState, blob.Properties.LeaseState, "LeaseState mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedDuration, blob.Properties.LeaseDuration, "LeaseDuration mismatch: " + description + " (from FetchAttributes)"); BlobResultSegment blobs = await blob.Container.ListBlobsSegmentedAsync(blob.Name, true, BlobListingDetails.None, null, null, null, null); BlobProperties propertiesInListing = (from CloudBlob b in blobs.Results where b.Name == blob.Name select b.Properties).Single(); Assert.AreEqual(expectedStatus, propertiesInListing.LeaseStatus, "LeaseStatus mismatch: " + description + " (from ListBlobs)"); Assert.AreEqual(expectedState, propertiesInListing.LeaseState, "LeaseState mismatch: " + description + " (from ListBlobs)"); Assert.AreEqual(expectedDuration, propertiesInListing.LeaseDuration, "LeaseDuration mismatch: " + description + " (from ListBlobs)"); }
internal static FileShareData DeserializeFileShareData(JsonElement element) { Optional <string> etag = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <DateTimeOffset> lastModifiedTime = default; Optional <IDictionary <string, string> > metadata = default; Optional <int> shareQuota = default; Optional <EnabledProtocols> enabledProtocols = default; Optional <RootSquashType> rootSquash = default; Optional <string> version = default; Optional <bool> deleted = default; Optional <DateTimeOffset> deletedTime = default; Optional <int> remainingRetentionDays = default; Optional <ShareAccessTier> accessTier = default; Optional <DateTimeOffset> accessTierChangeTime = default; Optional <string> accessTierStatus = default; Optional <long> shareUsageBytes = default; Optional <LeaseStatus> leaseStatus = default; Optional <LeaseState> leaseState = default; Optional <LeaseDuration> leaseDuration = default; Optional <IList <SignedIdentifier> > signedIdentifiers = default; Optional <DateTimeOffset> snapshotTime = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("lastModifiedTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } lastModifiedTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("metadata")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property1 in property0.Value.EnumerateObject()) { dictionary.Add(property1.Name, property1.Value.GetString()); } metadata = dictionary; continue; } if (property0.NameEquals("shareQuota")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } shareQuota = property0.Value.GetInt32(); continue; } if (property0.NameEquals("enabledProtocols")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enabledProtocols = new EnabledProtocols(property0.Value.GetString()); continue; } if (property0.NameEquals("rootSquash")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } rootSquash = new RootSquashType(property0.Value.GetString()); continue; } if (property0.NameEquals("version")) { version = property0.Value.GetString(); continue; } if (property0.NameEquals("deleted")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } deleted = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("deletedTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } deletedTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("remainingRetentionDays")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } remainingRetentionDays = property0.Value.GetInt32(); continue; } if (property0.NameEquals("accessTier")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } accessTier = new ShareAccessTier(property0.Value.GetString()); continue; } if (property0.NameEquals("accessTierChangeTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } accessTierChangeTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("accessTierStatus")) { accessTierStatus = property0.Value.GetString(); continue; } if (property0.NameEquals("shareUsageBytes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } shareUsageBytes = property0.Value.GetInt64(); continue; } if (property0.NameEquals("leaseStatus")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } leaseStatus = new LeaseStatus(property0.Value.GetString()); continue; } if (property0.NameEquals("leaseState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } leaseState = new LeaseState(property0.Value.GetString()); continue; } if (property0.NameEquals("leaseDuration")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } leaseDuration = new LeaseDuration(property0.Value.GetString()); continue; } if (property0.NameEquals("signedIdentifiers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <SignedIdentifier> array = new List <SignedIdentifier>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(SignedIdentifier.DeserializeSignedIdentifier(item)); } signedIdentifiers = array; continue; } if (property0.NameEquals("snapshotTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } snapshotTime = property0.Value.GetDateTimeOffset("O"); continue; } } continue; } } return(new FileShareData(id, name, type, systemData, etag.Value, Optional.ToNullable(lastModifiedTime), Optional.ToDictionary(metadata), Optional.ToNullable(shareQuota), Optional.ToNullable(enabledProtocols), Optional.ToNullable(rootSquash), version.Value, Optional.ToNullable(deleted), Optional.ToNullable(deletedTime), Optional.ToNullable(remainingRetentionDays), Optional.ToNullable(accessTier), Optional.ToNullable(accessTierChangeTime), accessTierStatus.Value, Optional.ToNullable(shareUsageBytes), Optional.ToNullable(leaseStatus), Optional.ToNullable(leaseState), Optional.ToNullable(leaseDuration), Optional.ToList(signedIdentifiers), Optional.ToNullable(snapshotTime))); }
/// <summary> /// Checks the lease status of a container, both from its attributes and from a container listing. /// </summary> /// <param name="container">The container to test.</param> /// <param name="expectedStatus">The expected lease status.</param> /// <param name="expectedState">The expected lease state.</param> /// <param name="expectedDuration">The expected lease duration.</param> /// <param name="description">A description of the circumstances that lead to the expected status.</param> private void CheckLeaseStatus( CloudBlobContainer container, LeaseStatus expectedStatus, LeaseState expectedState, LeaseDuration expectedDuration, string description) { container.FetchAttributes(); Assert.AreEqual(expectedStatus, container.Properties.LeaseStatus, "LeaseStatus mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedState, container.Properties.LeaseState, "LeaseState mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedDuration, container.Properties.LeaseDuration, "LeaseDuration mismatch: " + description + " (from FetchAttributes)"); BlobContainerProperties propertiesInListing = (from CloudBlobContainer c in this.blobClient.ListContainers( container.Name, ContainerListingDetails.None) where c.Name == container.Name select c.Properties).Single(); Assert.AreEqual(expectedStatus, propertiesInListing.LeaseStatus, "LeaseStatus mismatch: " + description + " (from ListContainers)"); Assert.AreEqual(expectedState, propertiesInListing.LeaseState, "LeaseState mismatch: " + description + " (from ListContainers)"); Assert.AreEqual(expectedDuration, propertiesInListing.LeaseDuration, "LeaseDuration mismatch: " + description + " (from ListContainers)"); }
/// <summary> /// Checks the lease status of a blob, both from its attributes and from a blob listing. /// </summary> /// <param name="blob">The blob to test.</param> /// <param name="expectedStatus">The expected lease status.</param> /// <param name="expectedState">The expected lease state.</param> /// <param name="expectedDuration">The expected lease duration.</param> /// <param name="description">A description of the circumstances that lead to the expected status.</param> private void CheckLeaseStatus( CloudBlob blob, LeaseStatus expectedStatus, LeaseState expectedState, LeaseDuration expectedDuration, string description) { blob.FetchAttributes(); Assert.AreEqual(expectedStatus, blob.Properties.LeaseStatus, "LeaseStatus mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedState, blob.Properties.LeaseState, "LeaseState mismatch: " + description + " (from FetchAttributes)"); Assert.AreEqual(expectedDuration, blob.Properties.LeaseDuration, "LeaseDuration mismatch: " + description + " (from FetchAttributes)"); BlobProperties propertiesInListing = (from CloudBlob b in blob.Container.ListBlobs( blob.Name, true /* use flat blob listing */, BlobListingDetails.None, null /* options */) where b.Name == blob.Name select b.Properties).Single(); Assert.AreEqual(expectedStatus, propertiesInListing.LeaseStatus, "LeaseStatus mismatch: " + description + " (from ListBlobs)"); Assert.AreEqual(expectedState, propertiesInListing.LeaseState, "LeaseState mismatch: " + description + " (from ListBlobs)"); Assert.AreEqual(expectedDuration, propertiesInListing.LeaseDuration, "LeaseDuration mismatch: " + description + " (from ListBlobs)"); }
internal static BlobContainerData DeserializeBlobContainerData(JsonElement element) { Optional <string> etag = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <string> version = default; Optional <bool> deleted = default; Optional <DateTimeOffset> deletedTime = default; Optional <int> remainingRetentionDays = default; Optional <string> defaultEncryptionScope = default; Optional <bool> denyEncryptionScopeOverride = default; Optional <PublicAccess> publicAccess = default; Optional <DateTimeOffset> lastModifiedTime = default; Optional <LeaseStatus> leaseStatus = default; Optional <LeaseState> leaseState = default; Optional <LeaseDuration> leaseDuration = default; Optional <IDictionary <string, string> > metadata = default; Optional <ImmutabilityPolicyProperties> immutabilityPolicy = default; Optional <LegalHoldProperties> legalHold = default; Optional <bool> hasLegalHold = default; Optional <bool> hasImmutabilityPolicy = default; Optional <ImmutableStorageWithVersioning> immutableStorageWithVersioning = default; Optional <bool> enableNfsV3RootSquash = default; Optional <bool> enableNfsV3AllSquash = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("version")) { version = property0.Value.GetString(); continue; } if (property0.NameEquals("deleted")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } deleted = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("deletedTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } deletedTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("remainingRetentionDays")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } remainingRetentionDays = property0.Value.GetInt32(); continue; } if (property0.NameEquals("defaultEncryptionScope")) { defaultEncryptionScope = property0.Value.GetString(); continue; } if (property0.NameEquals("denyEncryptionScopeOverride")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } denyEncryptionScopeOverride = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("publicAccess")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } publicAccess = property0.Value.GetString().ToPublicAccess(); continue; } if (property0.NameEquals("lastModifiedTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } lastModifiedTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("leaseStatus")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } leaseStatus = new LeaseStatus(property0.Value.GetString()); continue; } if (property0.NameEquals("leaseState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } leaseState = new LeaseState(property0.Value.GetString()); continue; } if (property0.NameEquals("leaseDuration")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } leaseDuration = new LeaseDuration(property0.Value.GetString()); continue; } if (property0.NameEquals("metadata")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property1 in property0.Value.EnumerateObject()) { dictionary.Add(property1.Name, property1.Value.GetString()); } metadata = dictionary; continue; } if (property0.NameEquals("immutabilityPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } immutabilityPolicy = ImmutabilityPolicyProperties.DeserializeImmutabilityPolicyProperties(property0.Value); continue; } if (property0.NameEquals("legalHold")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } legalHold = LegalHoldProperties.DeserializeLegalHoldProperties(property0.Value); continue; } if (property0.NameEquals("hasLegalHold")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } hasLegalHold = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("hasImmutabilityPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } hasImmutabilityPolicy = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("immutableStorageWithVersioning")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } immutableStorageWithVersioning = ImmutableStorageWithVersioning.DeserializeImmutableStorageWithVersioning(property0.Value); continue; } if (property0.NameEquals("enableNfsV3RootSquash")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableNfsV3RootSquash = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("enableNfsV3AllSquash")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enableNfsV3AllSquash = property0.Value.GetBoolean(); continue; } } continue; } } return(new BlobContainerData(id, name, type, systemData, etag.Value, version.Value, Optional.ToNullable(deleted), Optional.ToNullable(deletedTime), Optional.ToNullable(remainingRetentionDays), defaultEncryptionScope.Value, Optional.ToNullable(denyEncryptionScopeOverride), Optional.ToNullable(publicAccess), Optional.ToNullable(lastModifiedTime), Optional.ToNullable(leaseStatus), Optional.ToNullable(leaseState), Optional.ToNullable(leaseDuration), Optional.ToDictionary(metadata), immutabilityPolicy.Value, legalHold.Value, Optional.ToNullable(hasLegalHold), Optional.ToNullable(hasImmutabilityPolicy), immutableStorageWithVersioning.Value, Optional.ToNullable(enableNfsV3RootSquash), Optional.ToNullable(enableNfsV3AllSquash))); }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="LeaseDuration" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => LeaseDuration.CreateFrom(sourceValue);