public virtual void Save(string filename) { if (ViewPersistence == null || String.IsNullOrWhiteSpace(filename)) { return; } var doc = CreateSearchDocument(); if (doc.Parts.Count == 0 && doc.Outputs.Count == 0) { throw new ArgumentException("Saving a search requires at least one parameter or output field."); } else { ViewPersistence.Save(filename, doc); } }
protected virtual SearchDocument Load(string filename, bool reset) { if (ViewPersistence == null || String.IsNullOrWhiteSpace(filename)) { return(null); } // may throw a load exception SearchDocument doc = ViewPersistence.Load(filename); SelectedSubject = doc.Subject; if (!_views.ContainsKey(doc.SearchType)) { throw new ArgumentException(String.Format("Could not determine the appropriate view to display (View requested: {0}).", doc.SearchType)); } CurrentView = _views[doc.SearchType]; if (reset) { CurrentView.Reset(); } CurrentView.SetParts(doc.Parts); return(doc); }