Ejemplo n.º 1
0
        public static FileEventFlags GetFileEventFlags(PwDatabase db,
                                                       string key, bool bErase)
        {
            if (db == null || !db.IsOpen || db.CustomData == null)
            {
                return(FileEventFlags.None);
            }
            StringDictionaryEx props     = db.CustomData;
            string             stringVal = props.Get(key);

            if (string.IsNullOrEmpty(stringVal))
            {
                stringVal = string.Empty;
            }
            FileEventFlags retVal;

            if (!Enum.TryParse(stringVal, out retVal))
            {
                retVal = FileEventFlags.None;
            }
            retVal &= FileEventFlags.Exiting | FileEventFlags.Locking;
            if ((bErase || retVal == FileEventFlags.None) &&
                props.Exists(key))
            {
                props.Remove(key);
            }
            return(retVal);
        }
Ejemplo n.º 2
0
        public static void SetFileEventFlags(PwDatabase db,
                                             string key, FileEventFlags reason)
        {
            if (db == null || !db.IsOpen || db.CustomData == null)
            {
                return;
            }

            // Record only locking & exit events.
            StringDictionaryEx props = db.CustomData;

            reason &= FileEventFlags.Exiting | FileEventFlags.Locking;
            if (reason != FileEventFlags.None)
            {
                props.Set(key, reason.ToString("G"));
            }
            else if (props.Exists(key))
            {
                props.Remove(key);
            }
        }