示例#1
0
        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 bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			if(!UIDevice.CurrentDevice.CheckSystemVersion(7,0))
				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;
		}