public PropertyFinderPersistentState LoadState()
        {
            PropertyFinderPersistentState state = null;

              try
              {
            // load from isolated storage
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            using (var stream = new IsolatedStorageFileStream("data.txt",
                                  FileMode.OpenOrCreate, FileAccess.Read, store))
            using (var reader = new StreamReader(stream))
            {
              if (!reader.EndOfStream)
              {
            var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState));
            state = (PropertyFinderPersistentState)serializer.Deserialize(reader);

            // set the persistence service for the newly loaded state
            state.PersistenceService = this;
              }
            }
              }
              catch
              {
              }

              // if we cannot retrieve the state, create a new state object
              if (state == null)
              {
            state = new PropertyFinderPersistentState(this);
              }

              return state;
        }
 public PropertyViewModel(ViewModelBase parent, PropertyFinderPersistentState state, Property property)
 {
     _state = state;
       _property = property;
       _isFavourited = state.IsPropertyFavourited(property);
       Parent = parent;
 }
 public void SaveState(PropertyFinderPersistentState state)
 {
     // persist the data using isolated storage
       using (var store = IsolatedStorageFile.GetUserStoreForApplication())
       using (var stream = new IsolatedStorageFileStream("data.txt",
                           FileMode.Create, FileAccess.Write, store))
       {
     var serializer = new XmlSerializer(typeof(PropertyFinderPersistentState));
     serializer.Serialize(stream, state);
       }
 }
   public SearchResultsViewModel(INavigationService navigationService, PropertyFinderPersistentState state,
 PropertyListingsResult results, SearchItemBase searchItem, PropertyDataSource dataSource)
   {
       _state = state;
         _navigationService = navigationService;
         _searchItem = searchItem;
         _dataSource = dataSource;
         var propertyViewModels = results.Data.Select(p => new PropertyViewModel(this, state, p)).ToList();
         _properties = new ObservableCollection<PropertyViewModel>(propertyViewModels);
         _totalResult = results.TotalResult;
         _totalPages = results.TotalPages;
   }
        public SearchResultsViewModel(INavigationService navigationService, PropertyFinderPersistentState state,
                                      PropertyListingsResult results, SearchItemBase searchItem, PropertyDataSource dataSource)
        {
            _state             = state;
            _navigationService = navigationService;
            _searchItem        = searchItem;
            _dataSource        = dataSource;
            var propertyViewModels = results.Data.Select(p => new PropertyViewModel(this, state, p)).ToList();

            _properties  = new ObservableCollection <PropertyViewModel>(propertyViewModels);
            _totalResult = results.TotalResult;
            _totalPages  = results.TotalPages;
            UpdateLoadMoreVisible();
        }
        public PropertyFinderViewModel(PropertyFinderPersistentState state,
                                       PropertyDataSource dataSource, INavigationService navigationService, IGeoLocationService geolocationService)
        {
            _propertyDataSource = dataSource;
            _navigationService  = navigationService;
            _state = state;
            _geolocationService = geolocationService;
            _recentSearches     = state.RecentSearches;

            foreach (var search in _recentSearches)
            {
                search.Parent = this;
            }
        }
        public PropertyFinderViewModel(PropertyFinderPersistentState state,
      PropertyDataSource dataSource, INavigationService navigationService, IGeoLocationService geolocationService)
        {
            _propertyDataSource = dataSource;
              _navigationService = navigationService;
              _state = state;
              _geolocationService = geolocationService;
              _recentSearches = state.RecentSearches;

              foreach (var search in _recentSearches)
              {
            search.Parent = this;
              }
        }
Beispiel #8
0
 public FavouritesViewModel(INavigationService navigationService, PropertyFinderPersistentState state)
 {
     _state             = state;
     _navigationService = navigationService;
     _properties        = state.Favourites.Select(p => new PropertyViewModel(this, state, p)).ToList();
 }
 public FavouritesViewModel(INavigationService navigationService, PropertyFinderPersistentState state)
 {
     _state = state;
       _navigationService = navigationService;
       _properties = state.Favourites.Select(p => new PropertyViewModel(this, state, p)).ToList();
 }