// initializes a playlist item using a corresponding STON value private static void InitializeFromSton(IPlaylistItem item, IStonDocument document, IStonComplexEntity entity, IDictionary <IStonValuedEntity, object> builtObjects) { item.Name = FromSton <string>(document, GetValue(document, document.GetMember(entity, new StonBindingName("Name"))), builtObjects) ?? item.GetType().Name; // playlist never declares its path explicitly // in general, it should be based on the playlist location instead if (!(item is Playlist)) { item.Path = FromSton <string>(document, GetValue(document, document.GetMember(entity, new StonBindingName("Path"))), builtObjects) ?? ""; } // loading subitems of a container if (item is IPlaylistContainer) { var container = item as IPlaylistContainer; foreach (var subitemData in entity.CollectionInit.Elements) { var subitem = FromSton <IPlaylistItem>(document, GetValue(document, subitemData), builtObjects); container.Add(subitem); } } // loading the loop provider of a playlist if (item is Track) { (item as Track).StreamProvider = FromSton <IStreamProvider>(document, GetValue(document, document.GetMember(entity, new StonBindingName("Stream"))), builtObjects); } }
// initializes a stream provider using a corresponding STON value private static void InitializeFromSton(IStreamProvider provider, IStonDocument document, IStonComplexEntity entity, IDictionary <IStonValuedEntity, object> builtObjects) { if (provider is LoopStreamProvider) { var loop = provider as LoopStreamProvider; loop.TrackStart = FromSton <long?>(document, GetValue(document, document.GetMember(entity, new StonBindingName("TrackStart"))), builtObjects) ?? -1; loop.StreamLoopStart = FromSton <long?>(document, GetValue(document, document.GetMember(entity, new StonBindingName("LoopStart"))), builtObjects) ?? -1; loop.StreamLoopEnd = FromSton <long?>(document, GetValue(document, document.GetMember(entity, new StonBindingName("LoopEnd"))), builtObjects) ?? -1; loop.TrackEnd = FromSton <long?>(document, GetValue(document, document.GetMember(entity, new StonBindingName("TrackEnd"))), builtObjects) ?? -1; loop.Loops = FromSton <int?>(document, GetValue(document, document.GetMember(entity, new StonBindingName("Loops"))), builtObjects) ?? -1; } }