public MetadataInformation(AssetFileMetadata metadata) { InitializeComponent(); this.Icon = Bitmaps.Azure_Explorer_ico; _metadata = metadata; BuildGrid(); }
/// <summary> /// Returns a <see cref="System.Threading.Tasks.Task<AssetFileMetadata>"/> instance to retrieve the <paramref name="assetFile"/> metadata. /// </summary> /// <param name="assetFile">The <see cref="IAssetFile"/> instance from where to get the metadata.</param> /// <param name="sasLocator">The <see cref="ILocator"/> instance.</param> /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> instance used for cancellation.</param> /// <returns>A <see cref="System.Threading.Tasks.Task<AssetFileMetadata>"/> instance to retrieve the <paramref name="assetFile"/> metadata.</returns> public static async Task <AssetFileMetadata> GetMetadataAsync(this IAssetFile assetFile, ILocator sasLocator, CancellationToken cancellationToken) { if (assetFile == null) { throw new ArgumentNullException("assetFile", "The asset file cannot be null."); } if (sasLocator == null) { throw new ArgumentNullException("sasLocator", "The SAS locator cannot be null."); } if (sasLocator.Type != LocatorType.Sas) { throw new ArgumentException("The locator type must be SAS.", "sasLocator"); } if (assetFile.ParentAssetId != sasLocator.AssetId) { throw new ArgumentException("sasLocator", "The SAS locator does not belong to the asset."); } AssetFileMetadata assetFileMetadata = null; if (!assetFile.Name.EndsWith(IAssetExtensions.MetadataFileSuffix, StringComparison.OrdinalIgnoreCase)) { IAsset asset = assetFile.Asset; IEnumerable <AssetFileMetadata> assetMetadata = await asset.GetMetadataAsync(sasLocator, cancellationToken).ConfigureAwait(false); if (assetMetadata != null) { assetFileMetadata = assetMetadata.FirstOrDefault(am => assetFile.Name.Equals(am.Name, StringComparison.OrdinalIgnoreCase)); } } return(assetFileMetadata); }