| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.ComponentModel; |
| | 6 | |
|
| | 7 | | namespace Azure.Storage.Files.DataLake.Models |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Provides the version state of a successfully released path or file system. |
| | 11 | | /// object. |
| | 12 | | /// </summary> |
| | 13 | | public readonly struct ReleasedObjectInfo : IEquatable<ReleasedObjectInfo> |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// The ETag contains a value that you can use to perform operations |
| | 17 | | /// conditionally. If the request version is 2011-08-18 or newer, the |
| | 18 | | /// ETag value will be in quotes. |
| | 19 | | /// </summary> |
| 0 | 20 | | public ETag ETag { get; } |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Returns the date and time the object was last modified. Any |
| | 24 | | /// operation that modifies the path or file system, including an update |
| | 25 | | /// of the object's metadata or properties, changes the last-modified |
| | 26 | | /// time of the object. |
| | 27 | | /// </summary> |
| 0 | 28 | | public DateTimeOffset LastModified { get; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Creates a new <see cref="ReleasedObjectInfo"/>. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="eTag"> |
| | 34 | | /// The <see cref="ETag"/> contains a value that you can use to perform |
| | 35 | | /// operations conditionally. |
| | 36 | | /// </param> |
| | 37 | | /// <param name="lastModified"> |
| | 38 | | /// The date and time the object was last modified. |
| | 39 | | /// </param> |
| | 40 | | public ReleasedObjectInfo(ETag eTag, DateTimeOffset lastModified) |
| | 41 | | { |
| 68 | 42 | | ETag = eTag; |
| 68 | 43 | | LastModified = lastModified; |
| 68 | 44 | | } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Creates a new <see cref="ReleasedObjectInfo"/>. |
| | 48 | | /// </summary> |
| | 49 | | /// <param name="info">A released <see cref="PathInfo"/>.</param> |
| | 50 | | internal ReleasedObjectInfo(PathInfo info) |
| 0 | 51 | | : this(info.ETag, info.LastModified) |
| | 52 | | { |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Creates a new <see cref="ReleasedObjectInfo"/>. |
| | 57 | | /// </summary> |
| | 58 | | /// <param name="info">A released <see cref="FileSystemInfo"/>.</param> |
| | 59 | | internal ReleasedObjectInfo(FileSystemInfo info) |
| 0 | 60 | | : this(info.ETag, info.LastModified) |
| | 61 | | { |
| 0 | 62 | | } |
| | 63 | |
|
| | 64 | | /// <summary> |
| | 65 | | /// Creates a string representation of a |
| | 66 | | /// <see cref="ReleasedObjectInfo"/>. |
| | 67 | | /// </summary> |
| | 68 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 69 | | public override string ToString() => base.ToString(); |
| | 70 | |
|
| | 71 | | /// <summary> |
| | 72 | | /// Check if two <see cref="ReleasedObjectInfo"/> instances are equal. |
| | 73 | | /// </summary> |
| | 74 | | /// <param name="obj">The instance to compare to.</param> |
| | 75 | | /// <returns>True if they're equal, false otherwise.</returns> |
| | 76 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 77 | | public override bool Equals(object obj) => |
| 0 | 78 | | obj is ReleasedObjectInfo other && Equals(other); |
| | 79 | |
|
| | 80 | | /// <summary> |
| | 81 | | /// Check if two <see cref="ReleasedObjectInfo"/> instances are equal. |
| | 82 | | /// </summary> |
| | 83 | | /// <param name="other">The instance to compare to.</param> |
| | 84 | | /// <returns>True if they're equal, false otherwise.</returns> |
| | 85 | | public bool Equals(ReleasedObjectInfo other) => |
| 0 | 86 | | ETag == other.ETag && |
| 0 | 87 | | LastModified == other.LastModified; |
| | 88 | |
|
| | 89 | | /// <summary> |
| | 90 | | /// Get a hash code for the <see cref="ReleasedObjectInfo"/>. |
| | 91 | | /// </summary> |
| | 92 | | /// <returns>Hash code for the <see cref="ReleasedObjectInfo"/>.</returns> |
| | 93 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 94 | | public override int GetHashCode() => |
| 0 | 95 | | ETag.GetHashCode() ^ |
| 0 | 96 | | LastModified.GetHashCode(); |
| | 97 | |
|
| | 98 | | /// <summary> |
| | 99 | | /// Check if two <see cref="ReleasedObjectInfo"/> instances are equal. |
| | 100 | | /// </summary> |
| | 101 | | /// <param name="left">The first instance to compare.</param> |
| | 102 | | /// <param name="right">The second instance to compare.</param> |
| | 103 | | /// <returns>True if they're equal, false otherwise.</returns> |
| | 104 | | public static bool operator ==(ReleasedObjectInfo left, ReleasedObjectInfo right) => |
| 0 | 105 | | left.Equals(right); |
| | 106 | |
|
| | 107 | | /// <summary> |
| | 108 | | /// Check if two <see cref="ReleasedObjectInfo"/> instances are not equal. |
| | 109 | | /// </summary> |
| | 110 | | /// <param name="left">The first instance to compare.</param> |
| | 111 | | /// <param name="right">The second instance to compare.</param> |
| | 112 | | /// <returns>True if they're not equal, false otherwise.</returns> |
| | 113 | | public static bool operator !=(ReleasedObjectInfo left, ReleasedObjectInfo right) => |
| 0 | 114 | | !(left == right); |
| | 115 | | } |
| | 116 | | } |