public static bool IsCustomAttributeSet(this StringDictionaryEx dict, KeeShare.AttributeFlags attribute) { string value = dict.Get(KeeShare.CustomDataKey); if (null == value) { return(false); } return(value.IsFlagSet(attribute)); }
public static bool IsFlagSet(this string aString, KeeShare.AttributeFlags flag) { uint setValue; if (KeePassLib.Utility.StrUtil.TryParseUInt(aString, out setValue)) { KeeShare.AttributeFlags setFlags = (KeeShare.AttributeFlags)setValue; return(setFlags.HasFlag(flag)); } return(false); }
public static bool SetCustomAttribute(this StringDictionaryEx dict, KeeShare.AttributeFlags attribute, bool set) { string value = dict.Get(KeeShare.CustomDataKey); if (null == value) { if (!set) { return(false); // no data } value = attribute.ToString("d"); dict.Set(KeeShare.CustomDataKey, attribute.ToString("d")); return(true); // set and return; } KeeShare.AttributeFlags flags; uint shortValue = 0; if (KeePassLib.Utility.StrUtil.TryParseUInt(value, out shortValue)) { Debug.Assert(false); } flags = (KeeShare.AttributeFlags)shortValue; if (set) { flags &= attribute; } else { flags ^= attribute; } string newValue = flags.ToString(); if (newValue != value) { if (flags == 0) { dict.Remove(KeeShare.CustomDataKey); } else { dict.Set(KeeShare.CustomDataKey, newValue); } return(true); } return(false); }
public static PwGroup FindOrCreateGroupWithAttribute(this PwDatabase database, KeeShare.AttributeFlags attribute, string name, PwGroup parent, PwIcon icon = PwIcon.Folder) { PwGroup group = database.FindOrCreateGroupWithAttribute(attribute, name, icon); if (group.ParentGroup != parent) { group.MoveToParent(parent); } return(group); }
public static PwGroup FindOrCreateGroupWithAttribute(this PwDatabase database, KeeShare.AttributeFlags attribute, string name, PwIcon icon = PwIcon.Folder) { foreach (PwGroup aGroup in database.RootGroup.GetGroups(true)) { if (aGroup.IsCustomAttributeSet(attribute)) { return(aGroup); } } //if we cant find the group yet, we create a new one and add it to the rootGroup PwGroup group = new PwGroup(true, true, name, icon); group.SetCustomAttribute(attribute, true); group.SetParent(database.RootGroup); Debug.Assert(null != group, "group for " + attribute + " - " + name + " is 'null' but should not!"); return(group); }
public static bool IsCustomAttributeSet(this PwDatabase db, KeeShare.AttributeFlags attribute) { return(db.CustomData.IsCustomAttributeSet(attribute)); }
public static void SetCustomAttribute(this PwDatabase db, KeeShare.AttributeFlags attribute, bool set) { db.CustomData.SetCustomAttribute(attribute, set); }
public static void SetCustomAttribute(this PwGroup group, KeeShare.AttributeFlags attribute, bool set) { group.CustomData.SetCustomAttribute(attribute, set); }
public static bool IsCustomAttributeSet(this PwGroup group, KeeShare.AttributeFlags attribute) { return(group.CustomData.IsCustomAttributeSet(attribute)); }
public static void SetCustomAttribute(this PwEntry entry, KeeShare.AttributeFlags attribute, bool set) { entry.CustomData.SetCustomAttribute(attribute, set); }
public static bool IsCustomAttributeSet(this PwEntry entry, KeeShare.AttributeFlags attribute) { return(entry.CustomData.IsCustomAttributeSet(attribute)); }