public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Theme.Apply(); // // Create the service // // Local CSV file service = MemoryDirectoryService.FromCsv("Data/XamarinDirectory.csv"); // LDAP service - uncomment to try it out. //service = new LdapDirectoryService { // Host = "ldap.mit.edu", // SearchBase = "dc=mit,dc=edu", //}; // // Load the favorites // var favoritesRepository = XmlFavoritesRepository.OpenIsolatedStorage("Favorites.xml"); if (favoritesRepository.GetAll().Count() == 0) { favoritesRepository = XmlFavoritesRepository.OpenFile("Data/XamarinFavorites.xml"); favoritesRepository.IsolatedStorageName = "Favorites.xml"; } // // Load the last search // Search search = null; try { search = Search.Open("Search.xml"); } catch (Exception) { search = new Search("Search.xml"); } // // Build the UI // favoritesViewController = new FavoritesViewController(favoritesRepository, service, search); window = new UIWindow(UIScreen.MainScreen.Bounds); window.RootViewController = new UINavigationController(favoritesViewController); window.MakeKeyAndVisible(); // // Show the login screen at startup // var login = new LoginViewController(service); favoritesViewController.PresentViewController(login, false, null); return(true); }
public override void OnCreate() { base.OnCreate (); using (var reader = new System.IO.StreamReader (Assets.Open ("XamarinDirectory.csv"))) Service = new MemoryDirectoryService (new CsvReader<Person> (reader).ReadAll ()); var filePath = Path.Combine (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal), "XamarinFavorites.xml"); using (var stream = Assets.Open ("XamarinFavorites.xml")) using (var filestream = File.Open (filePath, FileMode.Create)) stream.CopyTo (filestream); repo = XmlFavoritesRepository.OpenFile (filePath); }
public App() { System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); _mainMenu = new MainMenu(); MainPage = new NavigationPage(_mainMenu); var task = Task.Run(async() => { Service = await MemoryDirectoryService.FromXls(new string[] { "Departments.xlsx", "People.xlsx" }); Service.ExtensionCallback += ExtensionCallback; }); task.Wait(); }
public override void OnCreate() { base.OnCreate(); using (var reader = new System.IO.StreamReader(Assets.Open("XamarinDirectory.csv"))) Service = new MemoryDirectoryService(new CsvReader <Person> (reader).ReadAll()); var filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "XamarinFavorites.xml"); using (var stream = Assets.Open("XamarinFavorites.xml")) using (var filestream = File.Open(filePath, FileMode.Create)) stream.CopyTo(filestream); repo = XmlFavoritesRepository.OpenFile(filePath); }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { // Load the directory var dataUri = new Uri("EmployeeDirectory.WinPhone;component/Data/XamarinDirectory.csv", UriKind.Relative); var dataInfo = GetResourceStream(dataUri); using (var reader = new System.IO.StreamReader(dataInfo.Stream)) { DirectoryService = new MemoryDirectoryService(new CsvReader <Person> (reader).ReadAll()); } // Load the favorites FavoritesRepository = XmlFavoritesRepository.OpenFile("EmployeeDirectory.WinPhone;component/Data/XamarinFavorites.xml"); // Load the search try { SavedSearch = Search.Open("SavedSearch.xml"); } catch (Exception) { SavedSearch = new Search("SavedSearch.xml"); } }
public static Page GetMainPage() { var task = Task.Run(async() => { Service = await MemoryDirectoryService.FromCsv("XamarinDirectory.csv"); }); task.Wait(); var employeeList = new ContentPage(); if (uiImplementation == UIImplementation.CSharp) { employeeList = new EmployeeListView(); } else if (uiImplementation == UIImplementation.Xaml) { employeeList = new EmployeeListXaml(); } return(new NavigationPage(employeeList)); }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching (object sender, LaunchingEventArgs e) { // Load the directory var dataUri = new Uri ("EmployeeDirectory.WinPhone;component/Data/XamarinDirectory.csv", UriKind.Relative); var dataInfo = GetResourceStream (dataUri); using (var reader = new System.IO.StreamReader (dataInfo.Stream)) { DirectoryService = new MemoryDirectoryService (new CsvReader<Person> (reader).ReadAll ()); } // Load the favorites FavoritesRepository = XmlFavoritesRepository.OpenFile ("EmployeeDirectory.WinPhone;component/Data/XamarinFavorites.xml"); // Load the search try { SavedSearch = Search.Open ("SavedSearch.xml"); } catch (Exception) { SavedSearch = new Search ("SavedSearch.xml"); } }