//Delegate f_login; internal FormRoot(Model.Root ctx) { f_refresh = new MethodInvoker(RefreshControls); f_close = new MethodInvoker(Close); f_call = new MethodInvoker(Launch); f_data = new MethodInvoker(InitControls); //f_login = new MethodInvoker( LoginComplete ); this.ctx = ctx; InitializeComponent(); }
private Model.ModelBase GetItemFromID(string id) { if (string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)) { return(new Model.Root(CurrentUser)); } if (_ItemMap.ContainsKey(id)) { IEnumerable <string> parentList; //the order by length is a trick to make sure we avoid using the All Videos All Music folder if possible parentList = _ItemMap[id].OrderByDescending(i => i.Length); Model.ModelBase result = null; foreach (var parentID in parentList) { var parentItem = GetItemFromID(parentID); if (parentItem != null) { result = parentItem.Children.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase)); if (result != null) { break; } } } //this shouldn't happen, if the item is in the map, it should exist if (result == null) { Logger.Debug("GetItemFromID couldn't find parent for item: {0}", id); } return(result); } else { //find it the slow way by recursing through the object model var result = new Model.Root(CurrentUser).GetChildRecursive(id); //add it to the map so next time we don't have to find it this way AddItemToMap(result); return(result); } }
private Model.ModelBase GetItemFromID(string id) { if (string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)) { return new Model.Root(CurrentUser); } if (_ItemMap.ContainsKey(id)) { IEnumerable<string> parentList; //the order by length is a trick to make sure we avoid using the All Videos All Music folder if possible parentList = _ItemMap[id].OrderByDescending(i => i.Length); Model.ModelBase result = null; foreach (var parentID in parentList) { var parentItem = GetItemFromID(parentID); if (parentItem != null) { result = parentItem.Children.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase)); if (result != null) break; } } //this shouldn't happen, if the item is in the map, it should exist if (result == null) Logger.Debug("GetItemFromID couldn't find parent for item: {0}", id); return result; } else { //find it the slow way by recursing through the object model var result = new Model.Root(CurrentUser).GetChildRecursive(id); //add it to the map so next time we don't have to find it this way AddItemToMap(result); return result; } }