当前位置: 首页>>代码示例>>C#>>正文


C# PwGroup.AddGroup方法代码示例

本文整理汇总了C#中PwGroup.AddGroup方法的典型用法代码示例。如果您正苦于以下问题:C# PwGroup.AddGroup方法的具体用法?C# PwGroup.AddGroup怎么用?C# PwGroup.AddGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PwGroup的用法示例。


在下文中一共展示了PwGroup.AddGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadGroup

		private static void ReadGroup(XmlNode xmlNode, PwGroup pgParent, PwDatabase pwStorage)
		{
			PwGroup pg = new PwGroup(true, true);
			pgParent.AddGroup(pg, true);

			foreach(XmlNode xmlChild in xmlNode)
			{
				if(xmlChild.Name == ElemGroupName)
					pg.Name = XmlUtil.SafeInnerText(xmlChild);
				else if(xmlChild.Name == ElemGroup)
					ReadGroup(xmlChild, pg, pwStorage);
				else if(xmlChild.Name == ElemEntry)
					ReadEntry(xmlChild, pg, pwStorage);
				else { Debug.Assert(false); }
			}
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:16,代码来源:PwTresorXml100.cs

示例2: AddObject

		private static void AddObject(PwGroup pgStorage, JsonObject jObject,
			PwDatabase pwContext, bool bCreateSubGroups)
		{
			if(jObject.Items.ContainsKey(m_strGroup))
			{
				JsonArray jArray = jObject.Items[m_strGroup].Value as JsonArray;
				if(jArray == null) { Debug.Assert(false); return; }

				PwGroup pgNew;
				if(bCreateSubGroups)
				{
					pgNew = new PwGroup(true, true);
					pgStorage.AddGroup(pgNew, true);

					if(jObject.Items.ContainsKey("title"))
						pgNew.Name = ((jObject.Items["title"].Value != null) ?
							jObject.Items["title"].Value.ToString() : string.Empty);
				}
				else pgNew = pgStorage;

				foreach(JsonValue jValue in jArray.Values)
				{
					JsonObject objSub = jValue.Value as JsonObject;
					if(objSub != null) AddObject(pgNew, objSub, pwContext, true);
					else { Debug.Assert(false); }
				}

				return;
			}

			PwEntry pe = new PwEntry(true, true);

			SetString(pe, "Index", false, jObject, "index");
			SetString(pe, PwDefs.TitleField, pwContext.MemoryProtection.ProtectTitle,
				jObject, "title");
			SetString(pe, "ID", false, jObject, "id");
			SetString(pe, PwDefs.UrlField, pwContext.MemoryProtection.ProtectUrl,
				jObject, "uri");
			SetString(pe, "CharSet", false, jObject, "charset");

			if((pe.Strings.ReadSafe(PwDefs.TitleField).Length > 0) ||
				(pe.Strings.ReadSafe(PwDefs.UrlField).Length > 0))
				pgStorage.AddEntry(pe, true);
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:44,代码来源:MozillaBookmarksJson100.cs

示例3: Import

		public void Import(List<BaseRecord> baseRecords, PwDatabase storage, IStatusLogger status)
		{
			var records = new List<BaseRecord>();
			var trashedRecords = new List<BaseRecord>();

			baseRecords.ForEach(record =>
			{
				if (record.trashed)
					trashedRecords.Add(record);
				else
					records.Add(record);
			});


			var tree = BuildTree(records);

			status.SetText("Importing records..", LogStatusType.Info);
			
			PwGroup root = new PwGroup(true, true);
			root.Name = "1Password Import on " + DateTime.Now.ToString();


			foreach (var node in tree)
			{
				ImportRecord(node, root, storage);
			}

			if (trashedRecords.Count > 0)
			{
				PwGroup trash = new PwGroup(true, true) { Name = "Trash", IconId = PwIcon.TrashBin };

				foreach (var trecord in trashedRecords)
				{
					var wfrecord = trecord as WebFormRecord;
					if (wfrecord != null)
						CreateWebForm(trash, storage, wfrecord);
				}
				root.AddGroup(trash, true);
			}

			storage.RootGroup.AddGroup(root, true);
		}
开发者ID:diimdeep,项目名称:1P2KeePass,代码行数:42,代码来源:PIFImporter.cs

示例4: Import

        public static void Import(PwGroup pgStorage, Stream s, GxiProfile p,
            PwDatabase pdContext, IStatusLogger sl)
        {
            if(pgStorage == null) throw new ArgumentNullException("pgStorage");
            if(s == null) throw new ArgumentNullException("s");
            if(p == null) throw new ArgumentNullException("p");
            if(pdContext == null) throw new ArgumentNullException("pdContext");
            // sl may be null

            // Import into virtual group first, in order to realize
            // an all-or-nothing import
            PwGroup pgVirt = new PwGroup(true, true);

            try { ImportPriv(pgVirt, s, p, pdContext, sl); }
            finally { s.Close(); }

            foreach(PwGroup pg in pgVirt.Groups)
                pgStorage.AddGroup(pg, true);
            foreach(PwEntry pe in pgVirt.Entries)
                pgStorage.AddEntry(pe, true);
        }
开发者ID:rdealexb,项目名称:keepass,代码行数:21,代码来源:GxiImporter.cs

示例5: AddFolder

		private static void AddFolder(PwGroup pgParent, HspFolder hspFolder,
			bool bNewGroup)
		{
			if(hspFolder == null) { Debug.Assert(false); return; }

			PwGroup pg;
			if(bNewGroup)
			{
				pg = new PwGroup(true, true);
				pgParent.AddGroup(pg, true);

				if(!string.IsNullOrEmpty(hspFolder.Name))
					pg.Name = hspFolder.Name;
			}
			else pg = pgParent;

			if(hspFolder.Folders != null)
			{
				foreach(HspFolder fld in hspFolder.Folders)
					AddFolder(pg, fld, true);
			}

			if(hspFolder.Cards != null)
			{
				foreach(HspCard crd in hspFolder.Cards)
					AddCard(pg, crd);
			}
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:28,代码来源:HandySafeProXml12.cs

示例6: CreateFolder

		private static PwGroup CreateFolder(PwGroup groupAddTo, FolderRecord folderRecord)
		{
			PwGroup folder = new PwGroup(true, true);
			folder.Name = StringExt.GetValueOrEmpty(folderRecord.title);
			folder.CreationTime = DateTimeExt.FromUnixTimeStamp(folderRecord.createdAt);
			folder.LastModificationTime = DateTimeExt.FromUnixTimeStamp(folderRecord.updatedAt);
			groupAddTo.AddGroup(folder, true);
			return folder;
		}
开发者ID:diimdeep,项目名称:1P2KeePass,代码行数:9,代码来源:PIFImporter.cs

示例7: ImportGroup

        private static void ImportGroup(XmlNode xmlNode, PwDatabase pwStorage,
			PwGroup pg)
        {
            PwGroup pgSub = pg;
            PwEntry pe = null;

            foreach(XmlNode xmlChild in xmlNode)
            {
                if(xmlChild.Name == "A")
                {
                    pe = new PwEntry(true, true);
                    pg.AddEntry(pe, true);

                    pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
                        pwStorage.MemoryProtection.ProtectTitle,
                        XmlUtil.SafeInnerText(xmlChild)));

                    XmlNode xnUrl = xmlChild.Attributes.GetNamedItem("HREF");
                    if((xnUrl != null) && (xnUrl.Value != null))
                        pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
                            pwStorage.MemoryProtection.ProtectUrl, xnUrl.Value));
                    else { Debug.Assert(false); }

                    // pe.Strings.Set("RDF_ID", new ProtectedString(
                    //	false, xmlChild.Attributes.GetNamedItem("ID").Value));

                    ImportIcon(xmlChild, pe, pwStorage);

                    XmlNode xnTags = xmlChild.Attributes.GetNamedItem("TAGS");
                    if((xnTags != null) && (xnTags.Value != null))
                    {
                        string[] vTags = xnTags.Value.Split(',');
                        foreach(string strTag in vTags)
                        {
                            if(string.IsNullOrEmpty(strTag)) continue;
                            pe.AddTag(strTag);
                        }
                    }
                }
                else if(xmlChild.Name == "DD")
                {
                    if(pe != null)
                        ImportUtil.AppendToField(pe, PwDefs.NotesField,
                            XmlUtil.SafeInnerText(xmlChild).Trim(), pwStorage,
                            "\r\n", false);
                    else { Debug.Assert(false); }
                }
                else if(xmlChild.Name == "H3")
                {
                    string strGroup = XmlUtil.SafeInnerText(xmlChild);
                    if(strGroup.Length == 0) { Debug.Assert(false); pgSub = pg; }
                    else
                    {
                        pgSub = new PwGroup(true, true, strGroup, PwIcon.Folder);
                        pg.AddGroup(pgSub, true);
                    }
                }
                else if(xmlChild.Name == "DL")
                    ImportGroup(xmlChild, pwStorage, pgSub);
                else { Debug.Assert(false); }
            }
        }
开发者ID:Stoom,项目名称:KeePass,代码行数:62,代码来源:MozillaBookmarksHtml100.cs

示例8: ImportGroup

        private static void ImportGroup(PwDatabase pd, PwGroup pgParent, XmlNode xmlNode)
        {
            PwGroup pg = new PwGroup(true, true);

            foreach(XmlNode xmlChild in xmlNode.ChildNodes)
            {
                if(xmlChild.Name == "name")
                    pg.Name = XmlUtil.SafeInnerText(xmlChild);
                else if(xmlChild.Name == "description")
                    pg.Notes = XmlUtil.SafeInnerText(xmlChild);
                else if(xmlChild.Name == "entry") { }
                else if(xmlChild.Name == "updated")
                    pg.LastModificationTime = ImportTime(xmlChild);
                else { Debug.Assert(false); }
            }

            pgParent.AddGroup(pg, true);

            ProcessEntries(pd, pg, xmlNode.ChildNodes);
        }
开发者ID:ashwingj,项目名称:keepass2,代码行数:20,代码来源:RevelationXml04.cs

示例9: DeleteOneUserShouldRemoveObsoleteProxyNodes

        public void DeleteOneUserShouldRemoveObsoleteProxyNodes()
        {
            m_treeManager.Initialize(m_database);
            m_treeManager.CreateNewUser("mrX");
            m_treeManager.CreateNewUser("mrY");

            //a DeleteUser should also delete all proxies of this user!
            //so we create some and look if all proxies will be deleted...
            PwGroup testGroup1 = new PwGroup( true, false );
            PwGroup testGroup2 = new PwGroup( true, false );
            PwGroup testGroup3 = new PwGroup( true, false );

            m_database.RootGroup.AddGroup( testGroup1, true );
            m_database.RootGroup.AddGroup( testGroup2, true );

            testGroup2.AddGroup( testGroup3, true );

            PwEntry mrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX");
            PwEntry mrY = TestHelper.GetUserRootNodeByNameFor(m_database, "mrY");

            PwEntry mrXproxy1 = PwNode.CreateProxyNode( mrX );
            PwEntry mrXproxy2 = PwNode.CreateProxyNode( mrX );
            PwEntry mrXproxy3 = PwNode.CreateProxyNode( mrX );

            testGroup1.AddEntry( mrXproxy1, true );
            testGroup2.AddEntry( mrXproxy2, true );
            testGroup3.AddEntry( mrXproxy3, true );

            Assert.AreEqual( 7, NumberOfEntriesIn(m_database)); // 2 standard proxies each + 3 additional proxies for mrX

            m_treeManager.DeleteUser( mrX );

            Assert.AreEqual(2, NumberOfEntriesIn(m_database));
            foreach( PwEntry proxy in m_database.RootGroup.GetEntries( true ) )
            {
                Assert.AreEqual("mrY", proxy.Strings.ReadSafe(KeeShare.KeeShare.TitleField));
            }
            IsUsersGroupSane( m_database, 1 );
        }
开发者ID:hicknhack-software,项目名称:KeeShare,代码行数:39,代码来源:TreeManagerUnitTest.cs

示例10: AddSecLine

        private void AddSecLine(PwGroup pgContainer, SecLine line, bool bIsContainer,
			PwDatabase pwParent)
        {
            if(!bIsContainer)
            {
                if(line.SubLines.Count > 0)
                {
                    PwGroup pg = new PwGroup(true, true);
                    pg.Name = line.Text;

                    pgContainer.AddGroup(pg, true);

                    pgContainer = pg;
                }
                else
                {
                    PwEntry pe = new PwEntry(true, true);
                    pgContainer.AddEntry(pe, true);

                    pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
                        pwParent.MemoryProtection.ProtectTitle, line.Text));
                }
            }

            foreach(SecLine subLine in line.SubLines)
                AddSecLine(pgContainer, subLine, false, pwParent);
        }
开发者ID:haro-freezd,项目名称:KeePass,代码行数:27,代码来源:SecurityTxt12.cs

示例11: AddObject

        private static void AddObject(PwGroup pgStorage, JsonObject jObject,
			PwDatabase pwContext, bool bCreateSubGroups,
			Dictionary<string, List<string>> dTags, List<PwEntry> lCreatedEntries)
        {
            JsonValue jvRoot;
            jObject.Items.TryGetValue("root", out jvRoot);
            string strRoot = (((jvRoot != null) ? jvRoot.ToString() : null) ?? string.Empty);
            if(strRoot.Equals("tagsFolder", StrUtil.CaseIgnoreCmp))
            {
                ImportTags(jObject, dTags);
                return;
            }

            if(jObject.Items.ContainsKey(m_strGroup))
            {
                JsonArray jArray = (jObject.Items[m_strGroup].Value as JsonArray);
                if(jArray == null) { Debug.Assert(false); return; }

                PwGroup pgNew;
                if(bCreateSubGroups)
                {
                    pgNew = new PwGroup(true, true);
                    pgStorage.AddGroup(pgNew, true);

                    if(jObject.Items.ContainsKey("title"))
                        pgNew.Name = ((jObject.Items["title"].Value != null) ?
                            jObject.Items["title"].Value.ToString() : string.Empty);
                }
                else pgNew = pgStorage;

                foreach(JsonValue jValue in jArray.Values)
                {
                    JsonObject objSub = (jValue.Value as JsonObject);
                    if(objSub != null)
                        AddObject(pgNew, objSub, pwContext, true, dTags, lCreatedEntries);
                    else { Debug.Assert(false); }
                }

                return;
            }

            PwEntry pe = new PwEntry(true, true);

            SetString(pe, "Index", false, jObject, "index");
            SetString(pe, PwDefs.TitleField, pwContext.MemoryProtection.ProtectTitle,
                jObject, "title");
            SetString(pe, "ID", false, jObject, "id");
            SetString(pe, PwDefs.UrlField, pwContext.MemoryProtection.ProtectUrl,
                jObject, "uri");
            SetString(pe, "CharSet", false, jObject, "charset");

            if(jObject.Items.ContainsKey("annos"))
            {
                JsonArray vAnnos = (jObject.Items["annos"].Value as JsonArray);
                if(vAnnos != null)
                {
                    foreach(JsonValue jv in vAnnos.Values)
                    {
                        if(jv == null) { Debug.Assert(false); continue; }
                        JsonObject jo = (jv.Value as JsonObject);
                        if(jo == null) { Debug.Assert(false); continue; }

                        JsonValue jvAnnoName, jvAnnoValue;
                        jo.Items.TryGetValue("name", out jvAnnoName);
                        jo.Items.TryGetValue("value", out jvAnnoValue);
                        if((jvAnnoName == null) || (jvAnnoValue == null)) continue;

                        string strAnnoName = jvAnnoName.ToString();
                        string strAnnoValue = jvAnnoValue.ToString();
                        if((strAnnoName == null) || (strAnnoValue == null)) continue;

                        if(strAnnoName == "bookmarkProperties/description")
                            pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
                                pwContext.MemoryProtection.ProtectNotes, strAnnoValue));
                    }
                }
            }

            if((pe.Strings.ReadSafe(PwDefs.TitleField).Length > 0) ||
                (pe.Strings.ReadSafe(PwDefs.UrlField).Length > 0))
            {
                pgStorage.AddEntry(pe, true);
                lCreatedEntries.Add(pe);
            }
        }
开发者ID:haro-freezd,项目名称:KeePass,代码行数:85,代码来源:MozillaBookmarksJson100.cs

示例12: ImportGroup

		private static void ImportGroup(XmlNode xn, PwGroup pgParent, PwDatabase pd,
			bool bIsRecycleBin)
		{
			PwGroup pg;
			if(!bIsRecycleBin)
			{
				pg = new PwGroup(true, true);
				pgParent.AddGroup(pg, true);
			}
			else
			{
				pg = pd.RootGroup.FindGroup(pd.RecycleBinUuid, true);

				if(pg == null)
				{
					pg = new PwGroup(true, true, KPRes.RecycleBin, PwIcon.TrashBin);
					pgParent.AddGroup(pg, true);

					pd.RecycleBinUuid = pg.Uuid;
					pd.RecycleBinChanged = DateTime.UtcNow;
				}
			}

			foreach(XmlNode xmlChild in xn.ChildNodes)
			{
				if(xmlChild.Name == ElemName)
					pg.Name = XmlUtil.SafeInnerText(xmlChild);
				else if(xmlChild.Name == ElemIcon)
					pg.IconId = GetIcon(XmlUtil.SafeInnerText(xmlChild));
				else if(xmlChild.Name == ElemGroup)
					ImportGroup(xmlChild, pg, pd, false);
				else if(xmlChild.Name == ElemEntry)
					ImportEntry(xmlChild, pg, pd);
				else { Debug.Assert(false); }
			}
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:36,代码来源:PwSaverXml412.cs

示例13: FindCreateGroup

        private static PwGroup FindCreateGroup(string strSpec, PwGroup pgStorage,
			Dictionary<string, PwGroup> dRootGroups, string strSep, CsvOptions opt)
        {
            List<string> l = new List<string>();
            if(string.IsNullOrEmpty(strSep)) l.Add(strSpec);
            else
            {
                string[] vChain = strSpec.Split(new string[1] { strSep },
                    StringSplitOptions.RemoveEmptyEntries);
                for(int i = 0; i < vChain.Length; ++i)
                {
                    string strGrp = vChain[i];
                    if(opt.TrimFields) strGrp = strGrp.Trim();
                    if(strGrp.Length > 0) l.Add(strGrp);
                }
                if(l.Count == 0) l.Add(strSpec);
            }

            string strRootSub = l[0];
            if(!dRootGroups.ContainsKey(strRootSub))
            {
                PwGroup pgNew = new PwGroup(true, true);
                pgNew.Name = strRootSub;
                pgStorage.AddGroup(pgNew, true);
                dRootGroups[strRootSub] = pgNew;
            }
            PwGroup pg = dRootGroups[strRootSub];

            if(l.Count > 1)
            {
                char chSep = StrUtil.GetUnusedChar(strSpec);
                StringBuilder sb = new StringBuilder();
                for(int i = 1; i < l.Count; ++i)
                {
                    if(i > 1) sb.Append(chSep);
                    sb.Append(l[i]);
                }

                pg = pg.FindCreateSubTree(sb.ToString(), new char[1]{ chSep });
            }

            return pg;
        }
开发者ID:saadware,项目名称:kpn,代码行数:43,代码来源:CsvImportForm.cs

示例14: SetupAppWithDatabase

        protected TestKp2aApp SetupAppWithDatabase(string filename)
        {
            TestKp2aApp app = CreateTestKp2aApp();

            IOConnectionInfo ioc = new IOConnectionInfo {Path = filename};
            Database db = app.CreateNewDatabase();
            if (filename.EndsWith(".kdb"))
            {
                db.DatabaseFormat = new KdbDatabaseFormat(app);
            }

            db.KpDatabase = new PwDatabase();

            CompositeKey compositeKey = new CompositeKey();
            compositeKey.AddUserKey(new KcpPassword(DefaultPassword));
            if (!String.IsNullOrEmpty(DefaultKeyfile))
                compositeKey.AddUserKey(new KcpKeyFile(DefaultKeyfile));
            db.KpDatabase.New(ioc, compositeKey);

            db.KpDatabase.KeyEncryptionRounds = 3;
            db.KpDatabase.Name = "Keepass2Android Testing Password Database";

            // Set Database state
            db.Root = db.KpDatabase.RootGroup;
            db.Loaded = true;
            db.SearchHelper = new SearchDbHelper(app);

            // Add a couple default groups
            db.KpDatabase.RootGroup.AddGroup(new PwGroup(true, true, "Internet", PwIcon.Key), true);

            mailGroup = new PwGroup(true, true, "eMail", PwIcon.UserCommunication);
            db.KpDatabase.RootGroup.AddGroup(mailGroup, true);

            mailGroup.AddGroup(new PwGroup(true, true, "business", PwIcon.BlackBerry), true);

            mailEntry = new PwEntry(true, true);
            mailEntry.Strings.Set(PwDefs.UserNameField, new ProtectedString(
                                                            true, "[email protected]"));
            mailEntry.Strings.Set(PwDefs.TitleField, new ProtectedString(
                                                         true, "[email protected] Entry"));
            mailGroup.AddEntry(mailEntry, true);

            db.KpDatabase.RootGroup.AddGroup(new PwGroup(true, true, "eMail2", PwIcon.UserCommunication), true);

            return app;
        }
开发者ID:pythe,项目名称:wristpass,代码行数:46,代码来源:TestBase.cs

示例15: SetParent

 public static void SetParent(this PwGroup group, PwGroup parent, bool bTakeOwnership = true)
 {
     parent.AddGroup(group, bTakeOwnership);
 }
开发者ID:hicknhack-software,项目名称:KeeShare,代码行数:4,代码来源:ExtensionMethods.cs


注:本文中的PwGroup.AddGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。