private async void Login(string password)
        {
            if (!_connectedToDb)
            {
                return;
            }

            try
            {
                var waiter = _model.Login(password);
                if (waiter != null)
                {
                    ParametersLoader.SetParameter(AppParameters.WaiterId, waiter.Id.ToString());
                    ParametersLoader.SaveParameters();
                    await Navigation.PushAsync(App.Container.Resolve <MainPage>());

                    if (!_model.RememberUser)
                    {
                        PasswordEntry.Text = string.Empty;
                    }
                }
                else
                {
                    await DisplayAlert("Login error", "Wrong credentials, please retry", "OK");
                }
            }
            catch (WifiConnectionException ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
            }
        }
 protected override void OnDisappearing()
 {
     if (!_model.RememberUser)
     {
         ParametersLoader.SetParameter(AppParameters.Remember, _model.RememberUser.ToString());
         ParametersLoader.SaveParameters();
     }
 }
예제 #3
0
        public App()
        {
            InitializeComponent();

            ParametersLoader.InitParameters();
            ParametersLoader.LoadParameters();

            Container = new TinyIoCContainer();
            Container.RegisterApp();
            Container.Resolve <IContextConnectionStringSetter>().SetConnectionString();
            MainPage = new NavigationPage(Container.Resolve <LoginPage>());
        }
 private void OnLoginButtonClick(object sender, EventArgs e)
 {
     if (_model.RememberUser)
     {
         ParametersLoader.SetParameter(AppParameters.Remember, true.ToString());
         ParametersLoader.SetParameter(AppParameters.Username, _model.Username);
         ParametersLoader.SetParameter(AppParameters.Password, PasswordEntry.Text);
     }
     else
     {
         ParametersLoader.SetParameter(AppParameters.Remember, false.ToString());
         ParametersLoader.SetParameter(AppParameters.Username, string.Empty);
         ParametersLoader.SetParameter(AppParameters.Password, string.Empty);
     }
     Login(PasswordEntry.Text);
 }
예제 #5
0
        public void LoadParameters_FileWithParametes_ParametersShouldBeLoaded()
        {
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            string parametersFile = Path.Combine(baseDirectory, "ParametersFile.xml");

            this.WriteToFile(parametersFile, ParametersFileContent);

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            ParametersLoader.LoadParameters(parametersFile, parameters);

            Assert.AreEqual(3, parameters.Count);
            Assert.AreEqual("disneyland", parameters["ServerName"]);
            Assert.AreEqual("D:\\Disneyland", parameters["RootDirectory"]);
            Assert.AreEqual("MickeyMouse", parameters["DefaultUser"]);
        }
예제 #6
0
 /// <summary>
 /// Creates a new instance of <see cref="OverloadsBuilder"/>.
 /// </summary>
 /// <param name="debug">
 /// Whether the emitted code is to be debuggable.
 /// </param>
 /// <param name="stack">
 /// Place where the <see cref="PhpStack"/> instance can be loaded from.
 /// </param>
 /// <param name="loadValueParam">
 /// Delegate called when value parameter is to be loaded on evaluation stack.
 /// The target method should guarantee that a value is loaded on evaluation stack.
 /// </param>
 /// <param name="loadReferenceParam">
 /// Delegate called when PHP reference parameter is to be loaded on evaluation stack.
 /// The target method should guarantee that the object reference of type <see cref="PhpReference"/>
 /// is loaded on the evaluation stack. This object reference should not be a <B>null</B>.
 /// </param>
 /// <param name="loadOptParams">
 /// Delegate called when an array of optional arguments is to be loaded on evaluation stack.
 /// The target method should load that array on the evaluation stack.
 /// </param>
 public OverloadsBuilder(bool debug, IPlace stack,
                         ParameterLoader loadValueParam, ParameterLoader loadReferenceParam, ParametersLoader loadOptParams)
 {
     this.loadValueParam     = loadValueParam;
     this.loadReferenceParam = loadReferenceParam;
     this.loadOptParams      = loadOptParams;
     this.stack = stack;
     this.debug = debug;
 }
예제 #7
0
		/// <summary>
		/// Creates a new instance of <see cref="OverloadsBuilder"/>.
		/// </summary>
		/// <param name="debug">
		/// Whether the emitted code is to be debuggable.
		/// </param>
		/// <param name="stack">
		/// Place where the <see cref="PhpStack"/> instance can be loaded from.
		/// </param>
		/// <param name="loadValueParam">
		/// Delegate called when value parameter is to be loaded on evaluation stack.
		/// The target method should guarantee that a value is loaded on evaluation stack.
		/// </param>
		/// <param name="loadReferenceParam">
		/// Delegate called when PHP reference parameter is to be loaded on evaluation stack.
		/// The target method should guarantee that the object reference of type <see cref="PhpReference"/> 
		/// is loaded on the evaluation stack. This object reference should not be a <B>null</B>.
		/// </param>
		/// <param name="loadOptParams">
		/// Delegate called when an array of optional arguments is to be loaded on evaluation stack.
		/// The target method should load that array on the evaluation stack.
		/// </param>
		public OverloadsBuilder(bool debug, IPlace stack,
			ParameterLoader loadValueParam, ParameterLoader loadReferenceParam, ParametersLoader loadOptParams)
		{
			this.loadValueParam = loadValueParam;
			this.loadReferenceParam = loadReferenceParam;
			this.loadOptParams = loadOptParams;
			this.stack = stack;
			this.debug = debug;
		}