Esempio n. 1
0
 private void BaseForm_Load(object sender, EventArgs e)
 {
     ResizeForm();
     ResetTitulo();
     ChecaPermissao();
     AfterLoad?.Invoke(this, e);
 }
Esempio n. 2
0
 public void invoke_AfterLoad(object sender, EventArgs args)
 {
     if (AfterLoad != null)
     {
         AfterLoad.Invoke(sender, args);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes Load process
 /// </summary>
 public void Load()
 {
     BeforeLoad?.Invoke();
     currentData = Serializer.DeserializeData(fileName, folderName);
     Debug.Log(debugPrefix + "Loaded " + currentData.Count + " entries from " + Path.Combine(Application.persistentDataPath, folderName) + " from " + fileName);
     AfterLoad?.Invoke();
 }
Esempio n. 4
0
        public void Load()
        {
            if (IsLoaded)
            {
                if (!_managedDomain)
                {
                    throw new InvalidOperationException("This shim is attached to an app domain it does not manage.  Call Unload to detach the shim before calling Load");
                }
                Unload();
            }

            _managedDomain = true;
            AppDomainSetup ads = new AppDomainSetup();

            //FIXME: ApplicationBase must include the referring assembly for _domain.AssemblyResolve to work,
            // but must be pointed at the referred assembly to load dependencies...I think this is ok. -- JR 03/21/17
            ads.ApplicationBase          = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // AppDomain.CurrentDomain.BaseDirectory;
            ads.DisallowBindingRedirects = false;
            ads.DisallowCodeDownload     = true;
            ads.ConfigurationFile        = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            ads.ShadowCopyFiles          = "true";

            Evidence securityInfo = new Evidence();

            _domain = AppDomain.CreateDomain(_domainName, securityInfo, ads);
            _domain.AssemblyResolve += AssemblyResolver;

            AfterLoad?.Invoke(this);
        }
Esempio n. 5
0
 private void BackgroundWorkerOnRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Result != null)
     {
         if (e.Error != null)
         {
             _logText.AppendText(e.Error.Message + "\n" + e.Error.StackTrace);
             _statusLabel.Text      = "ERROR!";
             _statusLabel.ForeColor = Color.Red;
         }
         else
         {
             AfterLoad?.Invoke(this, new EventArgs <World>(e.Result as World));
         }
     }
     else
     {
         _logText.AppendText("Repair of corrupt XML cancelled!");
         _statusLabel.Text      = "ERROR!";
         _statusLabel.ForeColor = Color.Red;
     }
     foreach (string delete in _extractedFiles)
     {
         File.Delete(delete);
     }
     _extractedFiles.Clear();
 }
Esempio n. 6
0
 public void Attach(AppDomain domain)
 {
     _domain                  = domain;
     _managedDomain           = false;
     _domain.AssemblyResolve += AssemblyResolver;
     AfterLoad?.Invoke(this);
 }
 static void Init()
 {
     m_DataManager   = new MyPlayerPrefsDataManager <string[]>("troll", "face");
     m_EventsManager = new MyPlayerPrefsApplicationEventsManager();
     m_EventsManager.OnFocusEvent += OnFocus;
     m_EventsManager.OnPauseEvent += OnPause;
     m_EventsManager.OnQuitEvent  += OnQuit;
     AfterLoad?.Invoke();
 }
Esempio n. 8
0
        /// <summary>
        /// Loads the highest priority extension for the given key.
        /// </summary>
        /// <typeparam name="TExtensionType">The extension type to load.</typeparam>
        /// <param name="key">The named key of the descendant of ExtensionAttribute you wish to load.</param>
        /// <param name="args">Arguments to be passed to the extended type's constructor.</param>
        /// <returns>A instance of an extension type's subclass.</returns>
        public TExtensionType Load <TExtensionType>(String key, params Object[] args)
            where TExtensionType : class
        {
            var record = EnsureArgTypes <TExtensionType>(args);

            var ctor = FindConstructor <TExtensionType>(key);
            var obj  = (TExtensionType)ctor.Invoke(args);

            AfterLoad?.Invoke(record, obj);

            return(obj);
        }
Esempio n. 9
0
 /// <summary>
 /// Copies data from other serializer if it loaded data (executes load if not)
 /// </summary>
 /// <param name="source"></param>
 public void CopyLoadedDataFrom(SaveData source)
 {
     BeforeLoad?.Invoke();
     if (source.currentData == null)
     {
         source.Load();
     }
     currentData = new Dictionary <string, object>(source.currentData);
     folderName  = source.folderName;
     fileName    = source.fileName;
     AfterLoad?.Invoke();
     Debug.Log(debugPrefix + "Copied " + currentData.Count + " entries from " + source.name);
 }
Esempio n. 10
0
 public R <PlayResource, LocalStr> Load(AudioResource resource)
 {
     try {
         if (ShouldFailLoad)
         {
             return(new LocalStr(LoadFailedMessage));
         }
         return(new PlayResource(MakeResourceURI(resource.ResourceId, LoadedResources), resource));
     } finally {
         LoadedResources++;
         AfterLoad?.Invoke(this, EventArgs.Empty);
     }
 }
Esempio n. 11
0
        public IReadOnlyDictionary <String, TExtensionType> LoadAll <TExtensionType>(params Object[] args)
            where TExtensionType : class
        {
            var record = EnsureArgTypes <TExtensionType>(args);

            var ctors = FindAllConstructors <TExtensionType>();

            return(ctors.ToDictionary(kvp => kvp.Key, kvp =>
            {
                var obj = (TExtensionType)kvp.Value.Invoke(args);
                AfterLoad?.Invoke(record, obj);
                return obj;
            }));
        }
Esempio n. 12
0
        /// <summary>
        /// Lazily loads all extensions for the given key.
        /// </summary>
        /// <typeparam name="TExtensionType">The extension type to load.</typeparam>
        /// <param name="key">The named key of the descendant of ExtensionAttribute you wish to load.</param>
        /// <param name="args">Arguments to be passed to the extended type's constructor.</param>
        /// <returns>A lazy enumerable of instances of the specified type/key's extensions.</returns>
        public IEnumerable <TExtensionType> DeepLoad <TExtensionType>(String key, params Object[] args)
            where TExtensionType : class
        {
            var record = EnsureArgTypes <TExtensionType>(args);

            var ctors = DeepFindConstructor <TExtensionType>(key);

            return(ctors.Select(ctor =>
            {
                var obj = (TExtensionType)ctor.Invoke(args);
                AfterLoad?.Invoke(record, obj);
                return obj;
            }));
        }
Esempio n. 13
0
 /// <summary>
 /// Raises the <see cref="AfterLoad" /> event.
 /// </summary>
 /// <param name="args">The <see cref="LoadStateEventArgs"/> instance containing the event data.</param>
 protected virtual void OnAfterLoad(LoadStateEventArgs args) => AfterLoad?.Invoke(this, args);
Esempio n. 14
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            _keepPasswordInOnResume = true;
            Kp2aLog.Log("PasswordActivity.OnActivityResult "+resultCode+"/"+requestCode);

            AppTask.TryGetFromActivityResult(data, ref AppTask);

            //NOTE: original code from k eepassdroid used switch ((Android.App.Result)requestCode) { (but doesn't work here, although k eepassdroid works)
            switch(resultCode) {

                case KeePass.ExitNormal: // Returned to this screen using the Back key
                    if (PreferenceManager.GetDefaultSharedPreferences(this)
                                         .GetBoolean(GetString(Resource.String.LockWhenNavigateBack_key), false))
                    {
                        App.Kp2a.LockDatabase();
                    }
                    //by leaving the app with the back button, the user probably wants to cancel the task
                    //The activity might be resumed (through Android's recent tasks list), then use a NullTask:
                    AppTask = new NullTask();
                    Finish();
                    break;
                case KeePass.ExitLock:
                    // The database has already been locked, and the quick unlock screen will be shown if appropriate

                    _rememberKeyfile = _prefs.GetBoolean(GetString(Resource.String.keyfile_key), Resources.GetBoolean(Resource.Boolean.keyfile_default)); //update value
                    if ((KeyProviderType == KeyProviders.KeyFile) && (_rememberKeyfile))
                    {
                        //check if the keyfile was changed (by importing to internal directory)
                        var newKeyFile = GetKeyFile(_ioConnection.Path);
                        if (newKeyFile != _keyFileOrProvider)
                        {
                            _keyFileOrProvider = newKeyFile;
                            UpdateKeyfileIocView();
                        }
                    }
                    break;
                case KeePass.ExitCloseAfterTaskComplete:
                    // Do not lock the database
                    SetResult(KeePass.ExitCloseAfterTaskComplete);
                    Finish();
                    break;
                case KeePass.ExitClose:
                    SetResult(KeePass.ExitClose);
                    Finish();
                    break;
                case KeePass.ExitReloadDb:

                    if (App.Kp2a.GetDb().Loaded)
                    {
                        //remember the composite key for reloading:
                        var compositeKey = App.Kp2a.GetDb().KpDatabase.MasterKey;

                        //lock the database:
                        App.Kp2a.LockDatabase(false);

                        //reload the database (without most other stuff performed in PerformLoadDatabase.
                        // We're assuming that the db file (and if appropriate also the key file) are still available
                        // and there's no need to re-init the file storage. if it is, loading will fail and the user has
                        // to retry with typing the full password, but that's intended to avoid showing the password to a
                        // a potentially unauthorized user (feature request https://keepass2android.codeplex.com/workitem/274)
                        Handler handler = new Handler();
                        OnFinish onFinish = new AfterLoad(handler, this);
                        _performingLoad = true;
                        LoadDb task = new LoadDb(App.Kp2a, _ioConnection, _loadDbTask, compositeKey, _keyFileOrProvider, onFinish);
                        _loadDbTask = null; // prevent accidental re-use
                        new ProgressTask(App.Kp2a, this, task).Run();
                    }

                    break;
                case Result.Ok:
                    if (requestCode == RequestCodeSelectKeyfile)
                    {
                        IOConnectionInfo ioc = new IOConnectionInfo();
                        SetIoConnectionFromIntent(ioc, data);
                        _keyFileOrProvider = IOConnectionInfo.SerializeToString(ioc);
                        UpdateKeyfileIocView();
                    }
                    break;
                case (Result)FileStorageResults.FileUsagePrepared:
                    if (requestCode == RequestCodePrepareDbFile)
                    {
                        if (KeyProviderType == KeyProviders.KeyFile)
                        {
                            var iocKeyfile = IOConnectionInfo.UnserializeFromString(_keyFileOrProvider);

                            App.Kp2a.GetFileStorage(iocKeyfile)
                                .PrepareFileUsage(new FileStorageSetupInitiatorActivity(this, OnActivityResult, null), iocKeyfile,
                                         RequestCodePrepareKeyFile, false);
                        }
                        else
                            PerformLoadDatabase();
                    }
                    if (requestCode == RequestCodePrepareKeyFile)
                    {
                        PerformLoadDatabase();
                    }
                    if (requestCode == RequestCodePrepareOtpAuxFile)
                    {
                        GetAuxFileLoader().LoadAuxFile(true);
                    }
                    break;
            }
            if (requestCode == RequestCodeSelectAuxFile && resultCode == Result.Ok)
            {
                IOConnectionInfo auxFileIoc = new IOConnectionInfo();
                SetIoConnectionFromIntent(auxFileIoc, data);

                PreferenceManager.GetDefaultSharedPreferences(this).Edit()
                                 .PutString("KP2A.PasswordAct.AuxFileIoc" + IOConnectionInfo.SerializeToString(_ioConnection),
                                            IOConnectionInfo.SerializeToString(auxFileIoc))
                                 .Apply();

                GetAuxFileLoader().LoadAuxFile(false);
            }
            if (requestCode == RequestCodeChallengeYubikey && resultCode == Result.Ok)
            {
                try
                {
                    _challengeProv = new KeeChallengeProv();
                    byte[] challengeResponse = data.GetByteArrayExtra("response");
                    _challengeSecret = _challengeProv.GetSecret(_chalInfo, challengeResponse);
                    Array.Clear(challengeResponse, 0, challengeResponse.Length);
                }
                catch (Exception e)
                {
                    Kp2aLog.Log(e.ToString());
                    Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show();
                    return;
                }

                UpdateOkButtonState();
                FindViewById(Resource.Id.otpInitView).Visibility = ViewStates.Gone;

                if (_challengeSecret != null)
                {
                    new LoadingDialog<object, object, object>(this, true,
                        //doInBackground
                    delegate
                    {
                        //save aux file
                        try
                        {
                            ChallengeInfo temp = _challengeProv.Encrypt(_challengeSecret);
                            IFileStorage fileStorage = App.Kp2a.GetOtpAuxFileStorage(_ioConnection);
                            IOConnectionInfo iocAux = fileStorage.GetFilePath(fileStorage.GetParentPath(_ioConnection),
                                fileStorage.GetFilenameWithoutPathAndExt(_ioConnection) + ".xml");
                            if (!temp.Save(iocAux))
                            {
                                Toast.MakeText(this, Resource.String.ErrorUpdatingChalAuxFile, ToastLength.Long).Show();
                                return false;
                            }

                        }
                        catch (Exception e)
                        {
                            Kp2aLog.Log(e.ToString());
                        }
                        return null;
                    }
                    , delegate
                    {

                    }).Execute();

                }
                else
                {
                    Toast.MakeText(this, Resource.String.bad_resp, ToastLength.Long).Show();
                    return;
                }
            }
        }
Esempio n. 15
0
        private void PerformLoadDatabaseWithCompositeKey(CompositeKey compositeKey)
        {
            CheckBox cbQuickUnlock = (CheckBox) FindViewById(Resource.Id.enable_quickunlock);
            App.Kp2a.SetQuickUnlockEnabled(cbQuickUnlock.Checked);

            //avoid password being visible while loading:
            _showPassword = false;
            MakePasswordMaskedOrVisible();

            Handler handler = new Handler();
            OnFinish onFinish = new AfterLoad(handler, this);
            _performingLoad = true;
            LoadDb task = (KeyProviderType == KeyProviders.Otp)
                              ? new SaveOtpAuxFileAndLoadDb(App.Kp2a, _ioConnection, _loadDbTask, compositeKey, _keyFileOrProvider,
                                                            onFinish, this)
                              : new LoadDb(App.Kp2a, _ioConnection, _loadDbTask, compositeKey, _keyFileOrProvider, onFinish);
            _loadDbTask = null; // prevent accidental re-use

            SetNewDefaultFile();

            new ProgressTask(App.Kp2a, this, task).Run();
        }
Esempio n. 16
0
 protected virtual void OnAfterLoad()
 {
     AfterLoad?.Invoke();
 }