public AccountSettingsViewModel(
			INavigation navigation,
			IAppSettings appSettings)
			: base(navigation)
		{
			this.appSettings = appSettings;
		}
 public EventDetailsViewModel(INavigation navigation, FeaturedEvent e) : base(navigation)
 {
     Event = e;
     Sponsors = new ObservableRangeCollection<Sponsor>();
     if (e.Sponsor != null)
         Sponsors.Add(e.Sponsor);
 }
        public ContactListViewModel(INavigation navigation)
        {
            _navigation = navigation;
            _contactsService = ServiceLocator.ContactsService;

            Contacts = new ObservableCollection<Contact>();
        }
        public MainViewModel(INavigation navigation)

        {

            _navigation = navigation;        
            
        }
        public SearchViewModel(INavigation navigation)
        {
            if (navigation != null)
                _navigation = navigation;
            FindCommand = new Command<String>(searchText =>
            {
                this.SearchPattern = searchText;
                TwitterClient client = TwitterClient.GetInstance();
                IEnumerable<ITweet> tweets = client.SearchTweets(SearchPattern);
                TweetsFoundCollection = new ObservableCollection<ITweet>(tweets);
            }
                );

            ToMainCommand = new Command(async () =>
            {
                if (_navigation != null)
                    await _navigation.PopAsync();
            });

            SignupCommand = new Command<Object>(signup =>
            {
                TwitterClient client = TwitterClient.GetInstance();
                var tweet = signup as ITweet;
                if (tweet != null)
                {
                    Int64 id = tweet.CreatedBy.Id;
                    client.FollowUser(id);
                }
            },
                value => { return TweetsFoundCollection != null; });
        }
 public MainViewModel(INavigation navigation)
 {
     _navigation = navigation;
     _database = new Database();
     Contacts = new ObservableCollection<Contact>(_database.SearchContacts(""));
     AddCommand = new Command(ShowAddWindow);
 }
 public NewsViewModel(INavigation navigation) : base(navigation)
 {
     Items = new ObservableCollection<NewsItem>();
     Items.Add(new NewsItem() { Header = "Leksand till SHL", Text = "Leksand spelar i SHL 16/17! :)" });
     Items.Add(new NewsItem() { Header = "Microsoft köper Xamarin", Text = "Xamarin är nu gratis för alla!!" });
     Items.Add(new NewsItem() { Header = "Sogeti + Xamarin", Text = "Sogeti utbildar nya Xamarinutvecklare!" });
 }
		public PollResultsPageViewModel(
			INavigation navigation,
			IObjectFactory<IPollResults> objectFactory,
			IObjectFactory<IPoll> pollFactory,
			IObjectFactory<IPollComment> pollCommentFactory,
			IMessageBox messageBox
#if NETFX_CORE
			, IShareManager shareManager,
			ISecondaryPinner secondaryPinner
#endif // NETFX_CORE
			)
			: base(navigation)
		{
			this.objectFactory = objectFactory;
			this.pollFactory = pollFactory;
			this.pollCommentFactory = pollCommentFactory;
			this.messageBox = messageBox;

			this.PollComments = new ObservableCollection<PollCommentViewModel>();

#if NETFX_CORE
			this.shareManager = shareManager;
			this.secondaryPinner = secondaryPinner;
#endif // NETFX_CORE
		}
		public ExpenseViewModel(INavigation navigation)
		{
			_navigation = navigation;
			_expenseService = DependencyService.Get<IExpenseService>();

			SelectedDate = DateTime.Now;
			LoadData();

			MessagingCenter.Subscribe<AddViewModel, Expense>(this, "AddExpense", async (sender, arg) =>
				{
					try
					{
						await _expenseService.AddExpenseAsync(arg).ConfigureAwait(false);
					}
					catch (Exception ex)
					{
						Debug.WriteLine("Error occured during insertion : "+ex.Message);
					}
					LoadData();
				});
			MessagingCenter.Subscribe<ExpenseItemViewModel, int>(this, "DeleteExpense", async (sender, arg) =>
				{
					try
					{
						await _expenseService.DeleteExpenseAsync(arg).ConfigureAwait(false);
					}
					catch (Exception ex)
					{
						Debug.WriteLine("Error occured during delete of expense : "+ex.Message);
					}
					LoadData();
				});
		}
Exemple #10
0
        //public static Page GetMainPage()
        //{
        //    return new ContentPage
        //    {
        //        Content = new Label {
        //            Text = "Hello, Forms !",
        //            VerticalOptions = LayoutOptions.CenterAndExpand,
        //            HorizontalOptions = LayoutOptions.CenterAndExpand,
        //        },
        //    };
        //}

        public static Page GetMainPage()
        {
            var profilePage = new View.ProfilePage();

            _navPage = profilePage.Navigation;
            return new NavigationPage(profilePage); ;
        }
		public FundsTransferViewModel (INavigation navigation, Page currentPage)
		{
			Navigation = navigation;
			CancelCommand = new Command(async () => await Navigation.PopAsync());
			TransferCommand = new Command(async () => await currentPage.DisplayAlert("Transfer", "Success", "Ok"));

		}
        public LeadDetailViewModel(INavigation navigation, Account lead = null)
        {
            if (navigation == null)
            {
                throw new ArgumentNullException("navigation", "An instance of INavigation must be passed to the LeadDetailViewModel constructor.");
            }

            Navigation = navigation;

            if (lead == null)
            {
                Lead = new Account();
                this.Title = TextResources.Leads_NewLead;
            }
            else
            {
                Lead = lead;
                this.Title = lead.Company;
            }

            this.Icon = "contact.png";

            _DataClient = DependencyService.Get<IDataClient>();

            _GeoCodingService = DependencyService.Get<IGeoCodingService>();
        }
        public SalesDashboardLeadsViewModel(Command pushTabbedLeadPageCommand, INavigation navigation = null)
            : base(navigation)
        {
            _PushTabbedLeadPageCommand = pushTabbedLeadPageCommand;

            _DataClient = DependencyService.Get<IDataClient>();

            Leads = new ObservableCollection<Account>();

            MessagingCenter.Subscribe<Account>(this, MessagingServiceConstants.SAVE_ACCOUNT, (account) =>
                {
                    var index = Leads.IndexOf(account);
                    if (index >= 0)
                    {
                        Leads[index] = account;
                    }
                    else
                    {
                        Leads.Add(account);
                    }
                    Leads = new ObservableCollection<Account>(Leads.OrderBy(l => l.Company));
                });

            IsInitialized = false;
        }
        public CustomerTabbedPage(INavigation navigation, Account account)
        {
            // since we're modally presented this tabbed view (because Android doesn't natively support nested tabs),
            // this tool bar item provides a way to get back to the Customers list
            ToolbarItems.Add(new ToolbarItem(TextResources.Customers_Orders_CustomerTabbedPage_BackToCustomers, null, async () => await navigation.PopModalAsync()));

            CustomerDetailPage customerDetailPage = new CustomerDetailPage()
            {
                BindingContext = new CustomerDetailViewModel(account) { Navigation = this.Navigation },
                Title = TextResources.Customers_Detail_Tab_Title,
                Icon = new FileImageSource() { File = "CustomersTab" } // only used  on iOS
            };

            CustomerOrdersPage customerOrdersPage = new CustomerOrdersPage()
            {
                BindingContext = new OrdersViewModel(account) { Navigation = this.Navigation },
                Title = TextResources.Customers_Orders_Tab_Title,
                Icon = new FileImageSource() { File = "ProductsTab" } // only used  on iOS
            };

            CustomerSalesPage customerSalesPage = new CustomerSalesPage()
            {
                BindingContext = new CustomerSalesViewModel(account) { Navigation = this.Navigation },
                Title = TextResources.Customers_Sales_Tab_Title,
                Icon = new FileImageSource() { File = "SalesTab" } // only used  on iOS
            };

            Children.Add(customerDetailPage);
            Children.Add(customerOrdersPage);
            Children.Add(customerSalesPage);
        }
        private object TryFindPrincipal(StateManager stateManager, INavigation navigation, object dependentEntity)
        {
            if (navigation.PointsToPrincipal)
            {
                return _getterSource.GetAccessor(navigation).GetClrValue(dependentEntity);
            }

            // TODO: Perf
            foreach (var principalEntry in stateManager.StateEntries
                .Where(e => e.EntityType == navigation.ForeignKey.ReferencedEntityType))
            {
                if (navigation.IsCollection())
                {
                    if (_collectionAccessorSource.GetAccessor(navigation).Contains(principalEntry.Entity, dependentEntity))
                    {
                        return principalEntry.Entity;
                    }
                }
                else if (_getterSource.GetAccessor(navigation).GetClrValue(principalEntry.Entity) == dependentEntity)
                {
                    return principalEntry.Entity;
                }
            }

            return null;
        }
		public FindBleViewModel (INavigation navigation, bool selMeuSkey)
		{
			fim = false;
			this.selMeuSkey = selMeuSkey;
			App.gateSkey = null;  //sKey selecionada se for scan para gateDevice
			keySelecionada = null; //resultado da acao de click em item da lista de sKeys encontrados
			if (selMeuSkey || App.gateSkeys == null)
				devices = new ObservableCollection<BleDevice> ();
			else
				devices = new ObservableCollection<BleDevice> (App.gateSkeys);  //Skeys do ultimo scan

			if (selMeuSkey && MySafetyDll.MySafety.isScanning)
				((App)Application.Current).mysafetyDll.cancelScan ();

			((App)Application.Current).mysafetyDll.Scan += mysafetyDll_Scan;
			_navigation = navigation;

			FindCommand = new Command ((key) => {
				findBleButton = (Button)key;
				scanSkeys ();
			});

			//
			if (devices.Count () == 0)
				scanSkeys ();
		}
 public ContactViewModel(INavigation navigation, Contact contact)
 {
     _navigation = navigation;
     _contactData = new ContactDataService();
     FillingCurrentContact(contact);
     AddContactCommand = new Command(() => NewContact(contact));
 }
Exemple #18
0
	public static Xamarin.Forms.Page GetMainPage()
	{
		var navigationPage = new NavigationPage(new HackerNewsPage());
        Navigation = navigationPage.Navigation;

        return navigationPage;
	}
 public void Init()
 {
     var mock = MockRepository.GenerateMock(typeof(IWebDriver), new[] { typeof(IJavaScriptExecutor) });
     this.webDriver = (IWebDriver)mock;
     this.javaScriptExecutor = (IJavaScriptExecutor)mock;
     this.navigation = MockRepository.GenerateStub<INavigation>();
 }
        public ChooseViewModel(INavigation navi)
        {
            this.navigation = navi;

            this.likeMealCommand = new Command(async () =>
            {
                likedMeals.Add(Meal);
                if (!LoadNewMeal())
                {
					await this.LoadOverviewPage();
				}
            });

            this.dislikeMealCommand = new Command(async () =>
            {
                dislikedMeals.Add(Meal);
                if (!LoadNewMeal())
                {
					await this.LoadOverviewPage();
                }
            });

            this.enoughMealsCommand = new Command(async () =>
            {
				await this.LoadOverviewPage();
            });

            this.likedMeals = new List<Meal>();
            this.dislikedMeals = new List<Meal>();

			this.LoadNewMeal ();
        }
        public BoardsListingModel(INavigation navigation, ISiteAPI api)
        {
            Title = "Boards";
            _navigation = navigation;
            _api = api;

            Boards = new ObservableCollection<Board>();
        }
 public Settings(INavigation navigationService, IStorage storageService, ISettings settingsService, IUxService uxService)
     : base(navigationService, storageService, settingsService, uxService)
 {
     _navigationService = navigationService;
     _storageService = storageService;
     _settingsService = settingsService;
     _uxService = uxService;
 }
 public NewUserViewModel(INavigation nav)
 {
     SendEmail = new Command (async () => {
         if(String.IsNullOrEmpty(Email)) return;
         //send email
         await nav.PopAsync();
     });
 }
		public HomePageViewModel (INavigation navigation)
		{
			Navigation = navigation;
			FundsTranferCommand = new Command (async()=>{
				if(Navigation!=null)
					await Navigation.PushAsync(new FundsTransferPage());
			});
		}
Exemple #25
0
		public PollsPageViewModel(
			INavigation navigation,
			IObjectFactory<IPollSearchResults> objectFactory)
			: base(navigation)
		{
			this.objectFactory = objectFactory;
			this.SearchOptions = new ObservableCollection<PollSearchOptionViewModel>();
		}
		public MainMenu (INavigation navigation)
		{
			InitializeComponent ();

			_navigation = navigation;

			BindingContext = new SamplesViewModel(navigation);
		}
        public LoginViewModel(IAccountService accountService, INavigation navigation, Page page)
        {
            _accountService = accountService;
            _navigation = navigation;
            _page = page;

            Title = "Bloggity Login";
        }
 public ContactListViewModel (INavigation navigation)
 {
     _navigation = navigation;
     _contactData = new ContactDataService();
     OpenContactPageCommand = new Command(OpenContactPage);
     DeleteCommand = new Command<int>(Delete);
     ReloadDataCommand = new Command(ReloadData);
  }
 public void Setup()
 {
     mocks = new Mockery();
     mockDriver = mocks.NewMock<IWebDriver>();
     mockElement = mocks.NewMock<IWebElement>();
     mockNavigation = mocks.NewMock<INavigation>();
     log = new StringBuilder();
 }
Exemple #30
0
 public App()
 {
     // The root page of your application
       var p = new NavigationPage(new PhotoViewerTest.MenuPage());
       App.Navigation = p.Navigation;
       MainPage = p;
       //MainPage = new PhotoViewerTest.SingleImagePage();
 }
        public virtual void NavigationCollectionChanged(
            InternalEntityEntry entry,
            INavigation navigation,
            IEnumerable <object> added,
            IEnumerable <object> removed)
        {
            if (_inFixup)
            {
                return;
            }

            var foreignKey         = navigation.ForeignKey;
            var stateManager       = entry.StateManager;
            var inverse            = navigation.FindInverse();
            var collectionAccessor = navigation.GetCollectionAccessor();

            foreach (var oldValue in removed)
            {
                var oldTargetEntry = stateManager.TryGetEntry(oldValue);

                if (oldTargetEntry != null &&
                    oldTargetEntry.EntityState != EntityState.Detached)
                {
                    try
                    {
                        _inFixup = true;

                        // Null FKs and navigations of dependents that have been removed, unless they
                        // have already been changed.
                        ConditionallyNullForeignKeyProperties(oldTargetEntry, entry, foreignKey);

                        if (inverse != null &&
                            ReferenceEquals(oldTargetEntry[inverse], entry.Entity))
                        {
                            SetNavigation(oldTargetEntry, inverse, null);
                        }

                        entry.RemoveFromCollectionSnapshot(navigation, oldValue);
                    }
                    finally
                    {
                        _inFixup = false;
                    }
                }
            }

            foreach (var newValue in added)
            {
                var newTargetEntry = stateManager.GetOrCreateEntry(newValue);

                if (newTargetEntry.EntityState != EntityState.Detached)
                {
                    try
                    {
                        _inFixup = true;

                        // For a dependent added to the collection, remove it from the collection of
                        // the principal entity that it was previously part of
                        var oldPrincipalEntry = stateManager.GetPrincipal(newTargetEntry, foreignKey);
                        if (oldPrincipalEntry != null)
                        {
                            RemoveFromCollection(oldPrincipalEntry, navigation, collectionAccessor, newValue);
                        }

                        // Set the FK properties on added dependents to match this principal
                        SetForeignKeyProperties(newTargetEntry, entry, foreignKey, setModified: true);

                        // Set the inverse navigation to point to this principal
                        SetNavigation(newTargetEntry, inverse, entry.Entity);

                        entry.AddToCollectionSnapshot(navigation, newValue);
                    }
                    finally
                    {
                        _inFixup = false;
                    }
                }
                else
                {
                    _attacher.AttachGraph(newTargetEntry, EntityState.Added);
                }
            }
        }
Exemple #32
0
 private void GenerateNavigationDataAnnotations(INavigation navigation)
 {
     GenerateForeignKeyAttribute(navigation);
     GenerateInversePropertyAttribute(navigation);
 }
Exemple #33
0
 public DefaultCountryViewModel(INavigation _navigation)
 {
     Navigation = _navigation;
 }
Exemple #34
0
 public BaseViewModel(INavigation navigation = null)
 {
     Navigation = navigation;
 }
 public OTPVerificationViewModel(INavigation _navigation)
 {
     Navigation    = _navigation;
     SubmitCommand = new Command(SubmitClicked);
 }
 public CaptureViewModel(INavigation navigation)
 {
     this.Navigation = navigation;
     database        = ServiceContainer.Resolve <IDatabase>();
 }
 public GameHistoryViewModel(INavigation Navigation)
 {
     GameHistoryDisplayData            = new GameHistoryDisplayData(Navigation);
     RefreshGamesListCommand           = new Command(GameHistoryDisplayData.UpdateGameList);
     OnGameHistoryPageAppearingCommand = new Command(GameHistoryDisplayData.OnGameHistoryPageAppearing);
 }
 public ColorViewModel(INavigation nav)
 {
     _nav        = nav;
     CurrentPage = DependencyInject <MainPage> .Get();
 }
Exemple #39
0
 public TicketCell(INavigation navigation = null)
 {
     Height          = 120;
     View            = new TicketCellView();
     this.navigation = navigation;
 }
 public CateringNavModule(INavigation xamarinFormsNavigation)
 {
     _xfNav = xamarinFormsNavigation;
 }
Exemple #41
0
 public AddCategoryViewModel(INavigation navigation)
 {
     Navigation         = navigation;
     Category           = new Category();
     AddCategoryCommand = new Command(AddCategory);
 }
Exemple #42
0
 public ScanSelectVM(INavigation navigationContext)
 {
     this.navigation = navigationContext;
     this.OpenScaner = new Command(ScanAsync);
     this.EnterCode  = new Command(Enter);
 }
Exemple #43
0
 public CollectionInitializingExpression(
     int collectionId, Expression parent, Expression parentIdentifier, Expression outerIdentifier, INavigation navigation, Type type)
 {
     CollectionId     = collectionId;
     Parent           = parent;
     ParentIdentifier = parentIdentifier;
     OuterIdentifier  = outerIdentifier;
     Navigation       = navigation;
     Type             = type;
 }
Exemple #44
0
 public LoginViewModel(INavigation navigation)
 {
     _navigation = navigation;
     BindCommands();
 }
 public GameHistoryDisplayData(INavigation Navigation)
 {
     this.Navigation  = Navigation;
     GameHistoryModel = new GameHistoryModel();
 }
 public AllTransactionsViewModel(INavigation nav)
 {
     _navigation     = nav;
     ViewTransaction = new Command <Transaction>(vm => TransactionDetail(vm));
     GetAllTransactions();
 }
Exemple #47
0
 public UsuariosViewModel(Evento evento, INavigation Navigation, RegisterPage registerPage)
 {
     this.evento       = evento;
     this.registerPage = registerPage;
     this.Navigation   = Navigation;
 }
Exemple #48
0
 }                                //Command of zero button (أعد)
 public SphaViewModel(INavigation navigation, string Ty) : base(navigation)
 {
     type     = Ty;
     AddSpha  = new Command(Tspeh);
     ZeroSpha = new Command(ZeroTspeh);
 }
        /// <inheritdoc />
        public EntityLoadInfo Create(object document, IEntityType entityType, object owner, INavigation owningNavigation)
        {
            Check.NotNull(document, nameof(document));
            Check.NotNull(entityType, nameof(entityType));

            if (document.GetType() != entityType.ClrType)
            {
                Check.IsInstanceOfType(document, entityType.ClrType, nameof(document));

                entityType = entityType.Model.FindEntityType(document.GetType());
            }

            return(new EntityLoadInfo(
                       new MaterializationContext(
                           _valueBufferFactory.CreateFromInstance(
                               document,
                               entityType,
                               owner,
                               owningNavigation),
                           _currentDbContext.Context),
                       materializationContext => document,
                       null));
        }
Exemple #50
0
 public EmptySpaceViewModel(INavigation navigation) : base(navigation)
 {
     TapCommand = new Command(Tap);
     State = ModelState.Undefined;
 }
Exemple #51
0
 public LoginViewModel(INavigation navigation)
 {
     this.navigation = navigation;
 }
Exemple #52
0
        public ViewModelBase(INavigation navigation = null)
        {
            this.Navigation = navigation;

            this.Resources = new LocalizedResources();
        }
            private static void IncludeCollection <TEntity, TIncludedEntity>(
                QueryContext queryContext,
                DbDataReader dbDataReader,
                TEntity entity,
                Func <QueryContext, DbDataReader, object[]> outerKeySelector,
                Func <QueryContext, DbDataReader, object[]> innerKeySelector,
                Func <QueryContext, DbDataReader, ResultCoordinator, TIncludedEntity> innerShaper,
                INavigation navigation,
                INavigation inverseNavigation,
                Action <TEntity, TIncludedEntity> fixup,
                bool trackingQuery,
                ResultCoordinator resultCoordinator)
            {
                if (entity is null)
                {
                    return;
                }

                if (trackingQuery)
                {
                    queryContext.StateManager.TryGetEntry(entity).SetIsLoaded(navigation);
                }
                else
                {
                    SetIsLoadedNoTracking(entity, navigation);
                }

                var innerKey      = innerKeySelector(queryContext, dbDataReader);
                var outerKey      = outerKeySelector(queryContext, dbDataReader);
                var relatedEntity = innerShaper(queryContext, dbDataReader, resultCoordinator);

                if (ReferenceEquals(relatedEntity, null))
                {
                    navigation.GetCollectionAccessor().GetOrCreate(entity);
                    return;
                }

                if (!trackingQuery)
                {
                    fixup(entity, relatedEntity);
                    if (inverseNavigation != null && !inverseNavigation.IsCollection())
                    {
                        SetIsLoadedNoTracking(relatedEntity, inverseNavigation);
                    }
                }

                var hasNext = resultCoordinator.HasNext ?? dbDataReader.Read();

                while (hasNext)
                {
                    resultCoordinator.HasNext = null;
                    var currentOuterKey = outerKeySelector(queryContext, dbDataReader);
                    if (!StructuralComparisons.StructuralEqualityComparer.Equals(outerKey, currentOuterKey))
                    {
                        resultCoordinator.HasNext = true;
                        break;
                    }

                    var currentInnerKey = innerKeySelector(queryContext, dbDataReader);
                    if (StructuralComparisons.StructuralEqualityComparer.Equals(innerKey, currentInnerKey))
                    {
                        continue;
                    }

                    relatedEntity = innerShaper(queryContext, dbDataReader, resultCoordinator);
                    if (!trackingQuery)
                    {
                        fixup(entity, relatedEntity);
                        if (inverseNavigation != null && !inverseNavigation.IsCollection())
                        {
                            SetIsLoadedNoTracking(relatedEntity, inverseNavigation);
                        }
                    }

                    hasNext = resultCoordinator.HasNext ?? dbDataReader.Read();
                }

                resultCoordinator.HasNext = hasNext;
            }
 public void Navigate(INavigation Navigation)
 {
     Navigation.PushModalAsync(new ShowDetailPage(show));
 }
Exemple #55
0
 public PaiementViewModel(Item item, INavigation navigation)
 {
     Item       = item;
     Navigation = navigation;
     AddItems();
 }
Exemple #56
0
 public VoituresViewModel(INavigation navigation)
 {
     Navigation = navigation;
 }
Exemple #57
0
 public IncidenciaRViewModel(INavigation navigation)
 {
     FriendModel = new Usuario();
     SaveCommand = new Command(async() => await SaveFriend());
     Navigation  = navigation;
 }
        public virtual void NavigationReferenceChanged(InternalEntityEntry entry, INavigation navigation, object oldValue, object newValue)
        {
            if (_inFixup)
            {
                return;
            }

            var foreignKey   = navigation.ForeignKey;
            var stateManager = entry.StateManager;
            var inverse      = navigation.FindInverse();

            var oldTargetEntry = oldValue == null ? null : stateManager.TryGetEntry(oldValue);

            if (oldTargetEntry?.EntityState == EntityState.Detached)
            {
                oldTargetEntry = null;
            }

            var newTargetEntry = newValue == null ? null : stateManager.TryGetEntry(newValue);

            if (newTargetEntry?.EntityState == EntityState.Detached)
            {
                newTargetEntry = null;
            }

            try
            {
                _inFixup = true;

                if (navigation.IsDependentToPrincipal())
                {
                    if (newValue != null)
                    {
                        if (newTargetEntry != null)
                        {
                            if (foreignKey.IsUnique)
                            {
                                // Navigation points to principal. Find the dependent that previously pointed to that principal and
                                // null out its FKs and navigation property. A.k.a. reference stealing.
                                // However, if the FK has already been changed or the reference is already set to point
                                // to something else, then don't change it.
                                var victimDependentEntry = stateManager.GetDependents(newTargetEntry, foreignKey).FirstOrDefault();
                                if (victimDependentEntry != null &&
                                    victimDependentEntry != entry)
                                {
                                    ConditionallyNullForeignKeyProperties(victimDependentEntry, newTargetEntry, foreignKey);

                                    if (ReferenceEquals(victimDependentEntry[navigation], newTargetEntry.Entity))
                                    {
                                        SetNavigation(victimDependentEntry, navigation, null);
                                    }
                                }
                            }

                            // Set the FK properties to reflect the change to the navigation.
                            SetForeignKeyProperties(entry, newTargetEntry, foreignKey, setModified: true);
                        }
                    }
                    else
                    {
                        // Null the FK properties to reflect that the navigation has been nulled out.
                        ConditionallyNullForeignKeyProperties(entry, oldTargetEntry, foreignKey);
                    }

                    if (inverse != null)
                    {
                        var collectionAccessor = inverse.IsCollection() ? inverse.GetCollectionAccessor() : null;

                        // Set the inverse reference or add the entity to the inverse collection
                        if (newTargetEntry != null)
                        {
                            SetReferenceOrAddToCollection(newTargetEntry, inverse, collectionAccessor, entry.Entity);
                        }

                        // Remove the entity from the old collection, or null the old inverse unless it was already
                        // changed to point to something else
                        if (oldTargetEntry != null)
                        {
                            if (collectionAccessor != null)
                            {
                                RemoveFromCollection(oldTargetEntry, inverse, collectionAccessor, entry.Entity);
                            }
                            else if (ReferenceEquals(oldTargetEntry[inverse], entry.Entity))
                            {
                                SetNavigation(oldTargetEntry, inverse, null);
                            }
                        }
                    }
                }
                else
                {
                    Debug.Assert(foreignKey.IsUnique);

                    if (newTargetEntry != null)
                    {
                        // Navigation points to dependent and is 1:1. Find the principal that previously pointed to that
                        // dependent and null out its navigation property. A.k.a. reference stealing.
                        // However, if the reference is already set to point to something else, then don't change it.
                        var victimPrincipalEntry = stateManager.GetPrincipal(newTargetEntry, foreignKey);
                        if (victimPrincipalEntry != null &&
                            victimPrincipalEntry != entry &&
                            ReferenceEquals(victimPrincipalEntry[navigation], newTargetEntry.Entity))
                        {
                            SetNavigation(victimPrincipalEntry, navigation, null);
                        }

                        SetForeignKeyProperties(newTargetEntry, entry, foreignKey, setModified: true);

                        SetNavigation(newTargetEntry, inverse, entry.Entity);
                    }

                    if (oldTargetEntry != null)
                    {
                        // Null the FK properties on the old dependent, unless they have already been changed
                        ConditionallyNullForeignKeyProperties(oldTargetEntry, entry, foreignKey);

                        // Clear the inverse reference, unless it has already been changed
                        if (inverse != null &&
                            ReferenceEquals(oldTargetEntry[inverse], entry.Entity))
                        {
                            SetNavigation(oldTargetEntry, inverse, null);
                        }
                    }
                }
            }
            finally
            {
                _inFixup = false;
            }

            if (newValue != null &&
                newTargetEntry == null)
            {
                _attacher.AttachGraph(stateManager.GetOrCreateEntry(newValue), EntityState.Added);
            }
        }
Exemple #59
0
 public AddEmployeePageViewModel(INavigation navigation)
 {
     Navigation = navigation;
 }
Exemple #60
0
        public static async Task <PKM> ScanQRPKM(SaveFile sav, INavigation nav)
        {
            var scanPage = new ZXingScannerPage
            {
                DefaultOverlayTopText    = "Hold camera up to QR code",
                DefaultOverlayBottomText = "Camera will automatically scan QR code/Barcode \r\n\rPress the 'Back' button to cancel"
            };

            scanPage.AutoFocus();

            PKM  pkm      = null;
            bool finished = false;

            scanPage.OnScanResult += async result =>
            {
                // disable scanning until message is acknowledged; if we get a good result, we're done scanning anyway
                scanPage.IsScanning = false;
                if (result.BarcodeFormat != BarcodeFormat.QR_CODE)
                {
                    await UserDialogs.Instance.AlertAsync("That's not a QR code.").ConfigureAwait(false);

                    scanPage.IsScanning = true;
                    return;
                }

                var pk = QRUtil.GetPKMFromQRMessage(result.Text, sav.Generation);
                if (pk == null)
                {
                    await UserDialogs.Instance.AlertAsync("Please scan a PKM QR code.").ConfigureAwait(false);

                    scanPage.IsScanning = true;
                    return;
                }

                pkm = PKMConverter.ConvertToType(pk, sav.PKMType, out var c);
                if (pkm == null)
                {
                    Console.WriteLine(c);
                    await UserDialogs.Instance.AlertAsync("Please scan a compatible PKM format QR code." + Environment.NewLine + $"Received {pk.GetType().Name}").ConfigureAwait(false);

                    scanPage.IsScanning = true;
                    return;
                }

                finished = true;
            };
            scanPage.Disappearing += (s, e) => finished = true;

            await nav.PushAsync(scanPage).ConfigureAwait(false);

            while (!finished)
            {
                await Task.Delay(100).ConfigureAwait(false);
            }
            if (pkm == null) // canceled
            {
                return(null);
            }
            Device.BeginInvokeOnMainThread(async() => await nav.PopAsync().ConfigureAwait(false));
            return(pkm);
        }