本文整理汇总了C#中ITrack.GetValueAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ITrack.GetValueAsync方法的具体用法?C# ITrack.GetValueAsync怎么用?C# ITrack.GetValueAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITrack
的用法示例。
在下文中一共展示了ITrack.GetValueAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getEncoderAsync
private async Task<IEncoder> getEncoderAsync(ITrack track)
{
var encoder = await track.GetValueAsync("Encoder");
if (String.IsNullOrWhiteSpace(encoder))
{
if (log.IsFatalEnabled)
{
log.Fatal("No valid Encoder property found quitting");
}
return null;
}
var encoderSplit = encoder.Value.Split(',');
if (encoderSplit.Length < 2)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("Encoder is in the incorrect formation it should be '<FullTypeName>, <FullAssemblyName>' instead '{0}' was received.", encoder);
}
return null;
}
ObjectHandle encoderBox = null;
try
{
encoderBox = Activator.CreateInstance(encoderSplit[1], encoderSplit[0]);
}
catch (Exception ex)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("An exception was thrown while trying to create an encoder of type '{0}'. Exception: {1}", encoder, ex);
}
return null;
}
if (encoderBox == null)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("Unable to create an encoder of type '{0}'.", encoder);
}
return null;
}
IEncoder e = encoderBox.Unwrap() as IEncoder;
if (e == null)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("Type of {0} does not implement IEncoder.", encoderBox.Unwrap().GetType());
}
return null;
}
return e;
}
示例2: getMetaDataAsync
private async Task<IMetaData> getMetaDataAsync(ITrack track)
{
var metaDataType = await track.GetValueAsync("MetaData");
if (String.IsNullOrWhiteSpace(metaDataType))
{
if (log.IsFatalEnabled)
{
log.Fatal("No valid MetaData property found quitting");
}
return null;
}
var metaDataSplit = metaDataType.Value.Split(',');
if (metaDataSplit.Length < 2)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("MetaData is in the incorrect formation it should be '<FullTypeName>, <FullAssemblyName>' instead '{0}' was received.", metaDataType);
}
return null;
}
ObjectHandle metaDataBox = null;
try
{
metaDataBox = Activator.CreateInstance(metaDataSplit[1], metaDataSplit[0]);
}
catch (Exception ex)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("An exception was thrown while trying to create an IMetaData of type '{0}'. Exception: {1}", metaDataType, ex);
}
return null;
}
if (metaDataBox == null)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("Unable to create an IMetaData of type '{0}'.", metaDataType);
}
return null;
}
IMetaData md = metaDataBox.Unwrap() as IMetaData;
if (md == null)
{
if (log.IsFatalEnabled)
{
log.FatalFormat("Type of {0} does not implement IMetaData.", metaDataBox.Unwrap().GetType());
}
return null;
}
return md;
}
示例3: GetArgumentsAsync
protected virtual async Task<String> GetArgumentsAsync(ITrack track, String sourceFile, String destinationFile)
{
if (track == null)
{
throw new ArgumentNullException("track");
}
if (sourceFile == null)
{
throw new ArgumentNullException("sourceFile");
}
if (destinationFile == null)
{
throw new ArgumentNullException("destinationFile");
}
StringBuilder arguments = new StringBuilder();
arguments.AppendFormat("\"{0}\" --output \"{1}\" ", Methods.FixString(Methods.ChangeDirectorySeparator(sourceFile, '/')), Methods.FixString(Methods.ChangeDirectorySeparator(destinationFile, '/')));
PropertyMetaData value = await track.GetValueAsync("ShowName");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--TVShowName \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("MediaKind");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--stik \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("Genre");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--genre \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("Image");
if (!String.IsNullOrWhiteSpace(value))
{
String imagePath = value.Value;
if (!Path.IsPathRooted(value.Value))
{
imagePath = Path.GetFullPath(Path.Combine(value.FullPath, value.Value));
}
arguments.AppendFormat("--artwork \"{0}\" ", Methods.FixString(Methods.ChangeDirectorySeparator(imagePath, '/')));
}
value = await track.GetValueAsync("Title");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--title \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("Description");
if (!String.IsNullOrWhiteSpace(value))
{
if (value.Value.Length > 255)
{
value = value.Value.Substring(0, 252) + "...";
}
arguments.AppendFormat("--description \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("Album");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--album \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("TrackNumber");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--tracknum \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("DiskNumber");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--disk \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("EID");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--TVEpisode \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("Episode");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--TVEpisodeNum \"{0}\" ", Methods.FixString(value));
}
value = await track.GetValueAsync("Season");
if (!String.IsNullOrWhiteSpace(value))
{
arguments.AppendFormat("--TVSeasonNum \"{0}\" ", Methods.FixString(value));
}
//.........这里部分代码省略.........