本文整理汇总了C#中System.Collections.ArrayList.ToJsArray方法的典型用法代码示例。如果您正苦于以下问题:C# ArrayList.ToJsArray方法的具体用法?C# ArrayList.ToJsArray怎么用?C# ArrayList.ToJsArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了ArrayList.ToJsArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeSongMetadata
public bool ChangeSongMetadata(IEnumerable<string> track_ids, IEnumerable<Dictionary<MetaKey, object>> changes)
{
if (track_ids == null) throw new ArgumentNullException("Argument 'track_ids' in ChangeSongMetadata must not be NULL!");
if (changes == null) throw new ArgumentNullException("Argument 'changes' in ChangeSongMetadata must not be NULL!");
if (track_ids.Count() != changes.Count()) throw new ArgumentException("Inconsistent data count of arguments 'track_ids' and 'changes'!");
bool success = false;
ArrayList tracks = new ArrayList();
using (var changesEnumerator = changes.GetEnumerator())
{
foreach (string track_id in track_ids)
{
if (!changesEnumerator.MoveNext()) break;
Dictionary<MetaKey, object> metadata = changesEnumerator.Current;
ArrayList track = new ArrayList();
foreach (string property in trackProperties)
{
if (property == "id")
track.Add(track_id);
else
{
try
{
MetaKey key = (MetaKey)Enum.Parse(typeof(MetaKey), property);
if (metadata.Keys.Contains(key) && Type.GetTypeCode(metadata[key].GetType()) == (TypeCode)(Convert.ToInt32(key) % 0x100))
{
track.Add(metadata[key]);
}
else
track.Add(null);
}
catch (ArgumentException)
{
track.Add(null);
}
}
}
track.Add(new ArrayList());
tracks.Add(track);
}
}
ArrayList array = new ArrayList { new ArrayList { _sessionId, 1 } };
array.Add(new ArrayList { tracks });
string data = array.ToJsArray();
string response = GoogleMusicService(Service.modifytracks, data);
if (response != null) success = true;
return success;
}