public static ConvertMetadataValueToString ( object metadataValue ) : string | ||
metadataValue | object | Value to convert |
Результат | string |
/// <summary> /// Returns all key/value pairs in a metadata object as a single string /// </summary> /// <param name="metadata">Collection of metadata items</param> /// <param name="isStreamMetadata">True for stream-level metadata; false for file-level metadata</param> /// <returns>A string which contains all key/value pairs in the metadata object</returns> private string GetMetadataAsText(IEnumerable <KeyValuePair <string, object> > metadata, bool isStreamMetadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } StringBuilder metadataString = new StringBuilder(); foreach (KeyValuePair <string, object> pair in metadata) { metadataString.Append(Environment.NewLine); if (isStreamMetadata) { metadataString.Append("\t"); } else { metadataString.Append(" "); } metadataString.Append(pair.Key); metadataString.Append(" = "); metadataString.Append(Metadata.ConvertMetadataValueToString(pair.Value)); } return(metadataString.ToString()); }
/// <summary> /// Compares two metadata collections together /// </summary> /// <param name="leftMetadata">Metadata list from the first file to use in comparison</param> /// <param name="rightMetadata">Metadata list from the second file to use in comparison</param> /// <param name="same">True if the metadata keys and values were identical between both files, false otherwise</param> /// <returns>A list which contains the combined metadata from both files used in comparison</returns> internal static ObservableCollection <CompareData> CompareMetadata(IEnumerable <KeyValuePair <string, object> > leftMetadata, IEnumerable <KeyValuePair <string, object> > rightMetadata, out bool same) { ObservableCollection <CompareData> compareMetadata = new ObservableCollection <CompareData>(); same = true; // populate the comparison list with all key/value pairs found in the leftMetadata list if (leftMetadata != null) { foreach (KeyValuePair <string, object> pair in leftMetadata) { string key = pair.Key; string leftValue = Metadata.ConvertMetadataValueToString(pair.Value); string rightValue = " "; compareMetadata.Add(new CompareData(key, leftValue, rightValue)); } } // populate the comparison list with any new values found in the rightMetadata list if (rightMetadata != null) { foreach (KeyValuePair <string, object> pair in rightMetadata) { bool found = false; for (int i = 0; i < compareMetadata.Count; i++) { if (compareMetadata[i].Key == pair.Key) { // update existing CompareData object compareMetadata[i].RightValue = Metadata.ConvertMetadataValueToString(pair.Value); compareMetadata[i].Same = compareMetadata[i].LeftValue.Equals(compareMetadata[i].RightValue); found = true; break; } } if (!found) { // add new CompareData object string key = pair.Key; string leftValue = " "; string rightValue = Metadata.ConvertMetadataValueToString(pair.Value); compareMetadata.Add(new CompareData(key, leftValue, rightValue)); } } } foreach (CompareData data in compareMetadata) { if (!data.Same) { same = false; break; } } return(compareMetadata); }
/// <summary> /// Converts a metadata value to a string for display in the UI /// </summary> /// <param name="value">The item to convert</param> /// <param name="targetType">targetType is not used</param> /// <param name="parameter">parameter is not used</param> /// <param name="culture">culture is not used</param> /// <returns>A string representing the value provided</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { throw new ArgumentNullException("value"); } return(Metadata.ConvertMetadataValueToString(value)); }
/// <summary> /// Returns all key/value pairs in a metadata object as a single string /// </summary> /// <param name="metadata">Collection of metadata items</param> /// <param name="type">Public or PersonallyIdentifiableInformation</param> /// <param name="streamName">Name of stream which metadata belongs to, empty if file-level metadata</param> /// <returns>A string which contains all key/value pairs in the metadata object</returns> private static string GetMetadataAsText(KStudioMetadata metadata, KStudioMetadataType type, string streamName) { if (metadata == null) { throw new ArgumentNullException("metadata"); } StringBuilder metadataString = new StringBuilder(); metadataString.Append(Environment.NewLine); if (string.IsNullOrEmpty(streamName)) { metadataString.Append(Strings.File); } else { metadataString.Append(streamName); } metadataString.Append(" "); if (type == KStudioMetadataType.Public) { metadataString.Append(string.Format(Strings.PublicMetadataHeader, metadata.Count)); } else { metadataString.Append(string.Format(Strings.PersonalMetadataHeader, metadata.Count)); } foreach (KeyValuePair <string, object> pair in metadata) { metadataString.Append(Environment.NewLine); metadataString.Append(" "); metadataString.Append(pair.Key); metadataString.Append(" = "); metadataString.Append(Metadata.ConvertMetadataValueToString(pair.Value)); } metadataString.Append(Environment.NewLine); return(metadataString.ToString()); }