ReadAll() public method

public ReadAll ( ) : string[]
return string[]
Exemplo n.º 1
0
        public void Init()
        {
            using (IsolatedStorageAccess isoAccess = new IsolatedStorageAccess(FileWithUserPassword))
            {

                string[] credenctial = isoAccess.ReadAll();

                if (credenctial != null && credenctial.Length>1)
                {
                    //odczytujemy w pierwszej lini login
                    var user = credenctial[0].Decrypt().ToInsecureString();
                    //odczytujemy w durgiej lini hasło
                    var pass = credenctial[1].Decrypt().ToInsecureString();

                    _view.UserName = user;
                    _view.Password = pass;

                    _view.RememberCredencial = true;

                    if (Properties.Settings.Default.AutoLogon)
                        ValidateCredential(user, pass);
                }
            }

            #region stara implementacja
            //IsolatedStorageFile isoStore =
            //        IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);

            ////pobieramy nazwy plików do tablicy, powinien być maksymalnie 1
            //string[] fileNames = isoStore.GetFileNames(FileWithUserPassword);
            //foreach (string file in fileNames)
            //{
            //    //metoda GetFileNames zwraca listę plików pasującą do wzorca,
            //    //powinien być tylko 1, lecz na wszelki wypadek stosujemy zabezpieczenie aby
            //    //nic nam niepotrzbnym wyjątkiem nie rzuciło
            //    if (file == FileWithUserPassword)
            //    {
            //        using (
            //            StreamReader sr =
            //                new StreamReader(new IsolatedStorageFileStream(FileWithUserPassword, FileMode.Open, isoStore))
            //            )
            //        {
            //            //odczytujemy w pierwszej lini login
            //            var user = sr.ReadLine().Decrypt().ToInsecureString();
            //            //odczytujemy w durgiej lini hasło
            //            var pass = sr.ReadLine().Decrypt().ToInsecureString();

            //            _view.UserName = user;
            //            _view.Password = pass;
            //        }
            //    }

            //}//end foreach
            #endregion

            //w celu aby wyglądało że się szybciej loguje,
            com.ConnectAsync();

            _view.AutoLogon = Properties.Settings.Default.AutoLogon;
        }
Exemplo n.º 2
0
        private void NotyfiInNewThread()
        {
            try
            {
                Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                Guid blipFaceGuid = Guid.Empty;

                using (IsolatedStorageAccess isoAccess = new IsolatedStorageAccess(FileBlipFaceGuid))
                {
                    string[] credenctial = isoAccess.ReadAll();

                    if (credenctial != null && credenctial.Length > 0)
                    {
                        //odczytujemy Guid danej instancji aplikacji BlipFace
                        var stringGuid = credenctial[0].Decrypt().ToInsecureString();
                        blipFaceGuid = new Guid(stringGuid);
                    }
                }

                //gdy nie ma jeszcze ustawionego Guida aplikacji (np. gdy BlipFace jest uruchamiany poraz pierwszy
                if (blipFaceGuid == Guid.Empty)
                {
                    blipFaceGuid = Guid.NewGuid();

                    SecureString secureGuid = blipFaceGuid.ToString().ToSecureString();

                    using (IsolatedStorageAccess isoAccess = new IsolatedStorageAccess(FileBlipFaceGuid))
                    {
                        string[] credenctial = new[] {secureGuid.Encrypt()};

                        isoAccess.WriteStrings(credenctial);
                    }
                }

                BlipFaceServicesCommunication communication = new BlipFaceServicesCommunication();
                communication.NotifyUseBlipFace(blipFaceGuid, version.ToString());
            }catch(Exception ex)
            {
                string mes = ex.Message;
                if(ex.InnerException!=null)
                {
                    mes += Environment.NewLine + "Inner exp: " + ex.InnerException.Message;
                }
                System.Windows.Forms.MessageBox.Show(mes);
            }
        }