static private ConvertStreamStringToGuid ( string streamName ) : System.Guid | ||
streamName | string | String representation of a stream |
return | System.Guid |
/// <summary> /// Converts a collection of stream strings to DataTypeIDs (Guids) /// </summary> /// <param name="streamNames">Collection of strings to convert to Guids</param> /// <returns>Collection of Guids, which includes DataTypeIDs for each stream</returns> internal static HashSet <Guid> ConvertStreamsToGuids(IEnumerable <string> streamNames) { if (streamNames == null) { throw new ArgumentNullException("streamNames"); } if (streamNames.Count <string>() == 0) { throw new InvalidOperationException(Strings.ErrorNoStreams); } HashSet <Guid> streamGuids = new HashSet <Guid>(); foreach (string streamName in streamNames) { streamGuids.Add(StreamSupport.ConvertStreamStringToGuid(streamName)); } return(streamGuids); }
/// <summary> /// Updates (add/edits) stream-level metadata in an event file /// </summary> /// <param name="client">KStudioClient to use for accessing the event file</param> /// <param name="fileName">Path to event file</param> /// <param name="streamName">Name of stream which should contain the metadata</param> /// <param name="type">Type of metadata to update (Public or Personal)</param> /// <param name="key">Key of metadata object to add/edit</param> /// <param name="value">Value of metadata object to add/edit</param> /// <returns>String which contains the updated contents of the target metadata object</returns> public static string UpdateStreamMetadata(KStudioClient client, string fileName, string streamName, KStudioMetadataType type, string key, object value) { if (client == null) { throw new ArgumentNullException("client"); } if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName"); } if (string.IsNullOrEmpty(streamName)) { throw new ArgumentNullException("streamName"); } string metadataText = string.Empty; using (KStudioEventFile file = client.OpenEventFileForEdit(fileName)) { // find the stream in the file and alter its metadata Guid dataTypeId = StreamSupport.ConvertStreamStringToGuid(streamName); if (dataTypeId == KStudioEventStreamDataTypeIds.Null) { throw new InvalidOperationException(Strings.ErrorNullStream); } KStudioEventStream stream = file.EventStreams.FirstOrDefault(s => s.DataTypeId == dataTypeId); if (stream != null) { KStudioMetadata metadata = stream.GetMetadata(type); Metadata.AlterMetadata(metadata, key, value); metadataText = Metadata.GetMetadataAsText(metadata, type, stream.DataTypeName); } } return(metadataText); }