本文整理汇总了C#中PwEntry类的典型用法代码示例。如果您正苦于以下问题:C# PwEntry类的具体用法?C# PwEntry怎么用?C# PwEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PwEntry类属于命名空间,在下文中一共展示了PwEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Copy
public static bool Copy(ProtectedString psToCopy, bool bIsEntryInfo,
PwEntry peEntryInfo, PwDatabase pwReferenceSource)
{
if(psToCopy == null) throw new ArgumentNullException("psToCopy");
return Copy(psToCopy.ReadString(), true, bIsEntryInfo, peEntryInfo,
pwReferenceSource, IntPtr.Zero);
}
示例2: ProcessCsvLine
private static void ProcessCsvLine(string strLine, PwDatabase pwStorage)
{
List<string> list = ImportUtil.SplitCsvLine(strLine, ",");
Debug.Assert(list.Count == 5);
PwEntry pe = new PwEntry(true, true);
pwStorage.RootGroup.AddEntry(pe, true);
if(list.Count == 5)
{
pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
pwStorage.MemoryProtection.ProtectTitle,
ProcessCsvWord(list[0])));
pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(
pwStorage.MemoryProtection.ProtectUserName,
ProcessCsvWord(list[1])));
pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(
pwStorage.MemoryProtection.ProtectPassword,
ProcessCsvWord(list[2])));
pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
pwStorage.MemoryProtection.ProtectUrl,
ProcessCsvWord(list[3])));
pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
pwStorage.MemoryProtection.ProtectNotes,
ProcessCsvWord(list[4])));
}
else throw new FormatException("Invalid field count!");
}
示例3: SetEntry
public void SetEntry(PwEntry e)
{
KpDatabase = new PwDatabase();
KpDatabase.New(new IOConnectionInfo(), new CompositeKey());
KpDatabase.RootGroup.AddEntry(e, true);
}
示例4: AddItem
private static void AddItem(PwEntry pe)
{
if(pe == null) { Debug.Assert(false); return; }
ToolStripMenuItem tsmi = new ToolStripMenuItem(pe.Strings.ReadSafe(
PwDefs.TitleField));
tsmi.Tag = pe;
tsmi.Click += OnMenuExecute;
Image img = null;
PwDatabase pd = Program.MainForm.ActiveDatabase;
if(pd != null)
{
if(!pe.CustomIconUuid.EqualsValue(PwUuid.Zero))
img = pd.GetCustomIcon(pe.CustomIconUuid);
if(img == null)
{
try { img = Program.MainForm.ClientIcons.Images[(int)pe.IconId]; }
catch(Exception) { Debug.Assert(false); }
}
}
if(img == null) img = Properties.Resources.B16x16_KGPG_Key1;
tsmi.Image = img;
m_btnItemsHost.DropDownItems.Add(tsmi);
m_vToolStripItems.Add(tsmi);
}
示例5: PwEntryView
private PwEntryView(GroupBaseActivity groupActivity, PwEntry pw, int pos)
: base(groupActivity)
{
_groupActivity = groupActivity;
View ev = Inflate(groupActivity, Resource.Layout.entry_list_entry, null);
_textView = (TextView)ev.FindViewById(Resource.Id.entry_text);
_textView.TextSize = PrefsUtil.GetListTextSize(groupActivity);
_textviewDetails = (TextView)ev.FindViewById(Resource.Id.entry_text_detail);
_textviewDetails.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity);
_textgroupFullPath = (TextView)ev.FindViewById(Resource.Id.group_detail);
_textgroupFullPath.TextSize = PrefsUtil.GetListDetailTextSize(groupActivity);
_showDetail = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean(
groupActivity.GetString(Resource.String.ShowUsernameInList_key),
Resources.GetBoolean(Resource.Boolean.ShowUsernameInList_default));
_showGroupFullPath = PreferenceManager.GetDefaultSharedPreferences(groupActivity).GetBoolean(
groupActivity.GetString(Resource.String.ShowGroupnameInSearchResult_key),
Resources.GetBoolean(Resource.Boolean.ShowGroupnameInSearchResult_default));
_isSearchResult = _groupActivity is keepass2android.search.SearchResults;
PopulateView(ev, pw, pos);
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);
AddView(ev, lp);
}
示例6: Copy
public static bool Copy(ProtectedString psToCopy, bool bIsEntryInfo,
PwEntry peEntryInfo, PwDatabase pwReferenceSource)
{
Debug.Assert(psToCopy != null);
if(psToCopy == null) throw new ArgumentNullException("psToCopy");
if(bIsEntryInfo && !AppPolicy.Try(AppPolicyId.CopyToClipboard))
return false;
string strData = SprEngine.Compile(psToCopy.ReadString(), false,
peEntryInfo, pwReferenceSource, false, false);
try
{
ClipboardUtil.Clear();
DataObject doData = CreateProtectedDataObject(strData);
Clipboard.SetDataObject(doData);
m_pbDataHash32 = HashClipboard();
m_strFormat = null;
RaiseCopyEvent(bIsEntryInfo, strData);
}
catch(Exception) { Debug.Assert(false); return false; }
if(peEntryInfo != null) peEntryInfo.Touch(false);
// SprEngine.Compile might have modified the database
Program.MainForm.UpdateUI(false, null, false, null, false, null, false);
return true;
}
示例7: DeleteEntry
public DeleteEntry(Context ctx, IKp2aApp app, PwEntry entry, OnFinish finish)
: base(finish, app)
{
Ctx = ctx;
Db = app.GetDb();
_entry = entry;
}
示例8: FillPlaceholders
public static string FillPlaceholders(string strText, PwEntry pe,
SprContentFlags cf)
{
if(pe == null) return strText;
string str = strText;
if(str.ToUpper().IndexOf(@"{PICKPASSWORDCHARS}") >= 0)
{
ProtectedString ps = pe.Strings.Get(PwDefs.PasswordField);
if(ps != null)
{
byte[] pb = ps.ReadUtf8();
bool bNotEmpty = (pb.Length > 0);
Array.Clear(pb, 0, pb.Length);
if(bNotEmpty)
{
CharPickerForm cpf = new CharPickerForm();
cpf.InitEx(ps, true, true);
if(cpf.ShowDialog() == DialogResult.OK)
{
str = StrUtil.ReplaceCaseInsensitive(str, @"{PICKPASSWORDCHARS}",
SprEngine.TransformContent(cpf.SelectedCharacters.ReadString(), cf));
}
}
}
str = StrUtil.ReplaceCaseInsensitive(str, @"{PICKPASSWORDCHARS}", string.Empty);
}
return str;
}
示例9: AfterUpdate
public AfterUpdate(PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnFinish finish)
: base(finish)
{
_backup = backup;
_updatedEntry = updatedEntry;
_app = app;
}
示例10: WriteEntries
/// <summary>
/// Write entries to a stream.
/// </summary>
/// <param name="msOutput">Output stream to which the entries will be written.</param>
/// <param name="pwDatabase">Source database.</param>
/// <param name="vEntries">Entries to serialize.</param>
/// <returns>Returns <c>true</c>, if the entries were written successfully to the stream.</returns>
public static bool WriteEntries(Stream msOutput, PwDatabase pwDatabase, PwEntry[] vEntries)
{
Kdb4File f = new Kdb4File(pwDatabase);
f.m_format = Kdb4Format.PlainXml;
XmlTextWriter xtw = null;
try { xtw = new XmlTextWriter(msOutput, Encoding.UTF8); }
catch(Exception) { Debug.Assert(false); return false; }
if(xtw == null) { Debug.Assert(false); return false; }
f.m_xmlWriter = xtw;
xtw.Formatting = Formatting.Indented;
xtw.IndentChar = '\t';
xtw.Indentation = 1;
xtw.WriteStartDocument(true);
xtw.WriteStartElement(ElemRoot);
foreach(PwEntry pe in vEntries)
f.WriteEntry(pe, false);
xtw.WriteEndElement();
xtw.WriteEndDocument();
xtw.Flush();
xtw.Close();
return true;
}
示例11: Copy
public static bool Copy(string strToCopy, bool bIsEntryInfo,
PwEntry peEntryInfo, PwDatabase pwReferenceSource)
{
Debug.Assert(strToCopy != null);
if(strToCopy == null) throw new ArgumentNullException("strToCopy");
if(bIsEntryInfo && !AppPolicy.Try(AppPolicyId.CopyToClipboard))
return false;
string strData = SprEngine.Compile(strToCopy, false, peEntryInfo,
pwReferenceSource, false, false);
try
{
Clipboard.Clear();
DataObject doData = CreateProtectedDataObject(strData);
Clipboard.SetDataObject(doData);
m_pbDataHash32 = HashClipboard();
m_strFormat = null;
}
catch(Exception) { Debug.Assert(false); return false; }
return true;
}
示例12: AddItem
private static void AddItem(PwEntry pe)
{
if(pe == null) { Debug.Assert(false); return; }
string strText = StrUtil.EncodeMenuText(pe.Strings.ReadSafe(
PwDefs.TitleField));
ToolStripMenuItem tsmi = new ToolStripMenuItem(strText);
tsmi.Tag = pe;
tsmi.Click += OnMenuExecute;
Image img = null;
PwDatabase pd = Program.MainForm.DocumentManager.SafeFindContainerOf(pe);
if(pd != null)
{
if(!pe.CustomIconUuid.Equals(PwUuid.Zero))
img = DpiUtil.GetIcon(pd, pe.CustomIconUuid);
if(img == null)
{
try { img = Program.MainForm.ClientIcons.Images[(int)pe.IconId]; }
catch(Exception) { Debug.Assert(false); }
}
}
if(img == null) img = Properties.Resources.B16x16_KGPG_Key1;
tsmi.Image = img;
m_btnItemsHost.DropDownItems.Add(tsmi);
m_vToolStripItems.Add(tsmi);
}
示例13: GetCellData
/// <summary>
/// Tells KeePass what to display in the column.
/// </summary>
/// <param name="strColumnName"></param>
/// <param name="pe"></param>
/// <returns>String displayed in the columns.</returns>
public override string GetCellData(string strColumnName, PwEntry pe)
{
if (strColumnName == null) throw new ArgumentNullException("strColumnName");
if (pe == null) throw new ArgumentNullException("pe");
if (plugin.SettingsCheck(pe) && plugin.SeedCheck(pe))
{
bool ValidInterval;
bool ValidLength;
bool ValidUrl;
if (plugin.SettingsValidate(pe, out ValidInterval, out ValidLength, out ValidUrl))
{
string[] Settings = plugin.SettingsGet(pe);
TOTPProvider TOTPGenerator = new TOTPProvider(Settings, ref plugin.TimeCorrections);
if (plugin.SeedValidate(pe))
{
return TOTPGenerator.GenerateByByte(
Base32.Decode(plugin.SeedGet(pe).ReadString().ExtWithoutSpaces())) + (m_host.CustomConfig.GetBool(setname_bool_TOTPColumnTimer_Visible, true) ? TOTPGenerator.Timer.ToString().ExtWithParenthesis().ExtWithSpaceBefore() : string.Empty);
}
return TrayTOTP_CustomColumn_Localization.strWarningBadSeed;
}
return TrayTOTP_CustomColumn_Localization.strWarningBadSet;
}
return (plugin.SettingsCheck(pe) || plugin.SeedCheck(pe) ? TrayTOTP_CustomColumn_Localization.strWarningStorage : string.Empty);
}
示例14: ApplyTo
// public bool CopyHistory
// {
// get { return m_bCopyHistory; }
// }
public void ApplyTo(PwEntry peNew, PwEntry pe, PwDatabase pd)
{
if((peNew == null) || (pe == null)) { Debug.Assert(false); return; }
Debug.Assert(peNew.Strings.ReadSafe(PwDefs.UserNameField) ==
pe.Strings.ReadSafe(PwDefs.UserNameField));
Debug.Assert(peNew.Strings.ReadSafe(PwDefs.PasswordField) ==
pe.Strings.ReadSafe(PwDefs.PasswordField));
if(m_bAppendCopy && (pd != null))
{
string strTitle = peNew.Strings.ReadSafe(PwDefs.TitleField);
peNew.Strings.Set(PwDefs.TitleField, new ProtectedString(
pd.MemoryProtection.ProtectTitle, strTitle + " - " +
KPRes.CopyOfItem));
}
if(m_bFieldRefs && (pd != null))
{
string strUser = @"{REF:[email protected]:" + pe.Uuid.ToHexString() + @"}";
peNew.Strings.Set(PwDefs.UserNameField, new ProtectedString(
pd.MemoryProtection.ProtectUserName, strUser));
string strPw = @"{REF:[email protected]:" + pe.Uuid.ToHexString() + @"}";
peNew.Strings.Set(PwDefs.PasswordField, new ProtectedString(
pd.MemoryProtection.ProtectPassword, strPw));
}
if(!m_bCopyHistory)
peNew.History = new PwObjectList<PwEntry>();
}
示例15: hasFields
public static bool hasFields(PwEntry entry)
{
foreach (KeyValuePair<string, ProtectedString> kvpStr in entry.Strings)
{
if (!PwDefs.IsStandardField(kvpStr.Key)) return true;
}
return false;
}