// Return a collection of key-value pairs to store in the application state. public List <KeyValuePair <string, object> > SaveState() { if (App.ViewModel.IsDataLoaded) { List <KeyValuePair <string, object> > stateList = new List <KeyValuePair <string, object> >(); // Create a new dictionary to store binding collections. var collections = new Dictionary <string, object>(); // Add the current Titles binding collection. collections["Titles"] = App.ViewModel.Titles; // Store the current context and binding collections in the view model state. stateList.Add(new KeyValuePair <string, object>( "DataServiceState", DataServiceState.Serialize(_context, collections))); stateList.Add(new KeyValuePair <string, object>("CurrentPage", CurrentPage)); stateList.Add(new KeyValuePair <string, object>("TotalCount", TotalCount)); return(stateList); } else { return(null); } }
string Serialize() { if (!IsDataLoaded) { return(null); } var collections = new Dictionary <string, object>(); collections["announcements"] = Announcements; collections["sessions"] = Sessions; collections["tracks"] = Tracks; collections["speakers"] = Speakers; collections["sponsors"] = Sponsors; collections["timeslots"] = Timeslots; return(DataServiceState.Serialize(context, collections)); }
// Return a string serialization of the application state. public string SaveState() { if (App.ViewModel.IsDataLoaded) { // Create a new dictionary to store binding collections. var collections = new Dictionary <string, object>(); // Add the current Customers binding collection. collections["Customers"] = Customers; // Return the serialized context and binding collections. return(DataServiceState.Serialize(_context, collections)); } else { return(string.Empty); } }
public List <KeyValuePair <string, object> > SaveState() { Uri storageUri; List <KeyValuePair <string, object> > stateList = new List <KeyValuePair <string, object> >(); Dictionary <string, object> collections = new Dictionary <string, object>(); if (this.Events != null) { collections.Add("Events", this.Events); if (this.Sessions != null) { collections.Add("Sessions", this.Sessions); if (this.Speakers != null) { collections.Add("Speakers", this.Speakers); } if (this.SessionFiles != null) { collections.Add("SessionFiles", this.SessionFiles); } } } // Add the DataServiceState to the collection. stateList.Add(new KeyValuePair <string, object>("DataServiceState", DataServiceState.Serialize(_context, collections))); // We can't store entities directly, so store the URI instead. if (CurrentSession != null && _context.TryGetUri(CurrentSession, out storageUri)) { // Store the URI of the CurrentSession. stateList.Add(new KeyValuePair <string, object>("CurrentSession", storageUri)); } if (CurrentEvent != null && _context.TryGetUri(CurrentEvent, out storageUri)) { // Store the URI of the CurrentEvent. stateList.Add(new KeyValuePair <string, object>("CurrentEvent", storageUri)); } if (SingleSpeaker != null && _context.TryGetUri(SingleSpeaker, out storageUri)) { // Store the URI of the Speaker. stateList.Add(new KeyValuePair <string, object>("SingleSpeaker", storageUri)); } // Add other non-entity binding properties to the collection. stateList.Add(new KeyValuePair <string, object>("TotalSessionCount", TotalSessionCount)); stateList.Add(new KeyValuePair <string, object>("Message", Message)); stateList.Add(new KeyValuePair <string, object>("CountMessage", CountMessage)); stateList.Add(new KeyValuePair <string, object>("QueryInfo", QueryInfo)); stateList.Add(new KeyValuePair <string, object>("SessionCategories", SessionCategories)); stateList.Add(new KeyValuePair <string, object>("SessionDates", SessionDates)); stateList.Add(new KeyValuePair <string, object>("SessionLevels", SessionLevels)); stateList.Add(new KeyValuePair <string, object>("SessionTracks", SessionTracks)); return(stateList); }