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


C# PwEntry.SetUuid方法代码示例

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


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

示例1: ReadEntry

        private static void ReadEntry(XmlNode xmlNode, PwDatabase pwStorage)
        {
            PwEntry pe = new PwEntry(true, true);
            PwGroup pg = pwStorage.RootGroup;

            string strAttachDesc = null, strAttachment = null;

            foreach(XmlNode xmlChild in xmlNode)
            {
                if(xmlChild.Name == ElemGroup)
                {
                    string strPreTree = null;
                    try
                    {
                        XmlNode xmlTree = xmlChild.Attributes.GetNamedItem(AttribGroupTree);
                        strPreTree = xmlTree.Value;
                    }
                    catch(Exception) { }

                    string strLast = XmlUtil.SafeInnerText(xmlChild);
                    string strGroup = ((!string.IsNullOrEmpty(strPreTree)) ?
                        strPreTree + "\\" + strLast : strLast);

                    pg = pwStorage.RootGroup.FindCreateSubTree(strGroup,
                        new string[1]{ "\\" }, true);
                }
                else if(xmlChild.Name == ElemTitle)
                    pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
                        pwStorage.MemoryProtection.ProtectTitle,
                        XmlUtil.SafeInnerText(xmlChild)));
                else if(xmlChild.Name == ElemUserName)
                    pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(
                        pwStorage.MemoryProtection.ProtectUserName,
                        XmlUtil.SafeInnerText(xmlChild)));
                else if(xmlChild.Name == ElemUrl)
                    pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
                        pwStorage.MemoryProtection.ProtectUrl,
                        XmlUtil.SafeInnerText(xmlChild)));
                else if(xmlChild.Name == ElemPassword)
                    pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(
                        pwStorage.MemoryProtection.ProtectPassword,
                        XmlUtil.SafeInnerText(xmlChild)));
                else if(xmlChild.Name == ElemNotes)
                    pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
                        pwStorage.MemoryProtection.ProtectNotes,
                        XmlUtil.SafeInnerText(xmlChild)));
                else if(xmlChild.Name == ElemUuid)
                    pe.SetUuid(new PwUuid(MemUtil.HexStringToByteArray(
                        XmlUtil.SafeInnerText(xmlChild))), false);
                else if(xmlChild.Name == ElemImage)
                {
                    int nImage;
                    if(int.TryParse(XmlUtil.SafeInnerText(xmlChild), out nImage))
                    {
                        if((nImage >= 0) && (nImage < (int)PwIcon.Count))
                            pe.IconId = (PwIcon)nImage;
                        else { Debug.Assert(false); }
                    }
                    else { Debug.Assert(false); }
                }
                else if(xmlChild.Name == ElemCreationTime)
                    pe.CreationTime = ParseTime(XmlUtil.SafeInnerText(xmlChild));
                else if(xmlChild.Name == ElemLastModTime)
                    pe.LastModificationTime = ParseTime(XmlUtil.SafeInnerText(xmlChild));
                else if(xmlChild.Name == ElemLastAccessTime)
                    pe.LastAccessTime = ParseTime(XmlUtil.SafeInnerText(xmlChild));
                else if(xmlChild.Name == ElemExpiryTime)
                {
                    try
                    {
                        XmlNode xmlExpires = xmlChild.Attributes.GetNamedItem(AttribExpires);
                        if(StrUtil.StringToBool(xmlExpires.Value))
                        {
                            pe.Expires = true;
                            pe.ExpiryTime = ParseTime(XmlUtil.SafeInnerText(xmlChild));
                        }
                        else { Debug.Assert(ParseTime(XmlUtil.SafeInnerText(xmlChild)).Year == 2999); }
                    }
                    catch(Exception) { Debug.Assert(false); }
                }
                else if(xmlChild.Name == ElemAttachDesc)
                    strAttachDesc = XmlUtil.SafeInnerText(xmlChild);
                else if(xmlChild.Name == ElemAttachment)
                    strAttachment = XmlUtil.SafeInnerText(xmlChild);
                else { Debug.Assert(false); }
            }

            if(!string.IsNullOrEmpty(strAttachDesc) && (strAttachment != null))
            {
                byte[] pbData = Convert.FromBase64String(strAttachment);
                ProtectedBinary pb = new ProtectedBinary(false, pbData);
                pe.Binaries.Set(strAttachDesc, pb);
            }

            pg.AddEntry(pe, true);
        }
开发者ID:Stoom,项目名称:KeePass,代码行数:96,代码来源:KeePassXml1x.cs

示例2: ReadEntries

		private void ReadEntries(KdbManager mgr, Dictionary<UInt32, PwGroup> dictGroups)
		{
			DateTime dtNeverExpire = KdbManager.GetNeverExpireTime();
			uint uEntryCount = mgr.EntryCount;

			for(uint uEntry = 0; uEntry < uEntryCount; ++uEntry)
			{
				KdbEntry e = mgr.GetEntry(uEntry);

				PwGroup pgContainer;
				if(!dictGroups.TryGetValue(e.GroupId, out pgContainer))
				{
					Debug.Assert(false);
					continue;
				}

				PwEntry pe = new PwEntry(false, false);
				pe.SetUuid(new PwUuid(e.Uuid.ToByteArray()), false);

				pgContainer.AddEntry(pe, true, true);

				pe.IconId = (e.ImageId < (uint)PwIcon.Count) ? (PwIcon)e.ImageId : PwIcon.Key;

				pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
					m_pwDatabase.MemoryProtection.ProtectTitle, e.Title));
				pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(
					m_pwDatabase.MemoryProtection.ProtectUserName, e.UserName));
				pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(
					m_pwDatabase.MemoryProtection.ProtectPassword, e.Password));
				pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
					m_pwDatabase.MemoryProtection.ProtectUrl, e.Url));

				string strNotes = e.Additional;
				ImportAutoType(ref strNotes, pe);
				ImportUrlOverride(ref strNotes, pe);
				pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
					m_pwDatabase.MemoryProtection.ProtectNotes, strNotes));

				pe.CreationTime = e.CreationTime.ToDateTime();
				pe.LastModificationTime = e.LastModificationTime.ToDateTime();
				pe.LastAccessTime = e.LastAccessTime.ToDateTime();
				pe.ExpiryTime = e.ExpirationTime.ToDateTime();

				pe.Expires = (pe.ExpiryTime != dtNeverExpire);

				if((e.BinaryDataLength > 0) && (e.BinaryData != IntPtr.Zero))
				{
					byte[] pbData = KdbManager.ReadBinary(e.BinaryData, e.BinaryDataLength);
					Debug.Assert(pbData.Length == e.BinaryDataLength);

					string strDesc = e.BinaryDescription;
					if(string.IsNullOrEmpty(strDesc)) strDesc = "Attachment";

					pe.Binaries.Set(strDesc, new ProtectedBinary(false, pbData));
				}

				if(m_slLogger != null)
				{
					if(!m_slLogger.SetProgress((100 * uEntry) / uEntryCount))
						throw new Exception(KPRes.Cancel);
				}
			}
		}
开发者ID:kusuriya,项目名称:PasswordKeeper,代码行数:63,代码来源:KdbFile.cs


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