コード例 #1
0
        public static UserStruct?isPasswordExist(String Email, String Password)
        {
            UserStruct tempUser = new UserStruct();

            String[] arr      = Email.Split('@');
            String   username = arr[0];

            for (int i = 0; i < users.Count; i++)
            {
                tempUser = users[i];
                if (tempUser.getUserName().Equals(username))
                {
                    String tempPass = tempUser.getUser()[username].ToString();
                    if (tempPass.Equals(Password))
                    {
                        return(tempUser);
                    }
                }
            }
            return(null);

            /*
             * if (!File.Exists(UsersFile)) // file exist check
             * {
             *  File.Create(UsersFile);
             * }
             *
             * Stream stream = File.OpenRead(UsersFile);
             * BinaryFormatter formatter = new BinaryFormatter();
             * stream.Position = 0;
             * try
             * {
             *  while (stream.Position < stream.Length)
             *  { // pass on the data in the file
             *      UserStruct UserDetails = (UserStruct)formatter.Deserialize(stream);
             *      String passtry = UserDetails.getUser()[Email].ToString();
             *      if (passtry.Equals(Password))
             *      { // check if the password match to the email
             *          stream.Close();
             *          return UserDetails;
             *      }
             *  }
             * }
             * catch (Exception e)
             * {
             *  MileStone4.DataAcces_Layer.Logger.Log.Fatal("while check if email "+Email+" and password "+Password+" match, an error accord - "+e.Message);
             * }
             * stream.Close();
             * return null;
             */
        }