/// <summary> /// Extension method to return the file extension description for a <see cref="ICustomDataSource"/>. /// </summary> /// <returns> /// Returns the file extension description; <c>null</c> if not defined. /// </returns> public static string TryGetFileDescription(this ICustomDataSource self) { var dataSource = self.GetType().GetCustomAttribute <DataSourceAttribute>(); var fileDataSource = dataSource as FileDataSourceAttribute; return(fileDataSource?.Description); }
/// <summary> /// Extension method to return the <see cref="Guid"/> for a <see cref="ICustomDataSource"/>. /// </summary> /// <returns> /// Returns the <see cref="Guid"/> of the <see cref="ICustomDataSource"/>; <see cref="Guid.Empty"/> if not defined. /// </returns> public static Guid TryGetGuid(this ICustomDataSource self) { var dataSourceId = self.GetType().GetCustomAttribute <CustomDataSourceAttribute>()?.Guid; return(dataSourceId.HasValue ? dataSourceId.Value : Guid.Empty); }
/// <summary> /// Extension method to return the description for a <see cref="ICustomDataSource"/>. /// </summary> /// <returns> /// Returns the description of the <see cref="ICustomDataSource"/>; <c>null</c> if not defined. /// </returns> public static string TryGetDescription(this ICustomDataSource self) { return(self.GetType().GetCustomAttribute <CustomDataSourceAttribute>()?.Description); }
/// <summary> /// Extension method to return the name for a <see cref="ICustomDataSource"/>. /// </summary> /// <returns> /// Returns the name of the <see cref="ICustomDataSource"/>; <c>null</c> if not defined. /// </returns> public static string TryGetName(this ICustomDataSource self) { return(self.GetType().GetCustomAttribute <CustomDataSourceAttribute>()?.Name); }