本文整理汇总了C#中PwObjectList.GetAt方法的典型用法代码示例。如果您正苦于以下问题:C# PwObjectList.GetAt方法的具体用法?C# PwObjectList.GetAt怎么用?C# PwObjectList.GetAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PwObjectList
的用法示例。
在下文中一共展示了PwObjectList.GetAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindRefTarget
public static PwEntry FindRefTarget(string strFullRef, SprContext ctx,
out char chScan, out char chWanted)
{
chScan = char.MinValue;
chWanted = char.MinValue;
if(strFullRef == null) { Debug.Assert(false); return null; }
if(!strFullRef.StartsWith(StrRefStart, SprEngine.ScMethod) ||
!strFullRef.EndsWith(StrRefEnd, SprEngine.ScMethod))
return null;
if((ctx == null) || (ctx.Database == null)) { Debug.Assert(false); return null; }
string strRef = strFullRef.Substring(StrRefStart.Length,
strFullRef.Length - StrRefStart.Length - StrRefEnd.Length);
if(strRef.Length <= 4) return null;
if(strRef[1] != '@') return null;
if(strRef[3] != ':') return null;
chScan = char.ToUpper(strRef[2]);
chWanted = char.ToUpper(strRef[0]);
SearchParameters sp = SearchParameters.None;
sp.SearchString = strRef.Substring(4);
sp.RespectEntrySearchingDisabled = false;
if(chScan == 'T') sp.SearchInTitles = true;
else if(chScan == 'U') sp.SearchInUserNames = true;
else if(chScan == 'A') sp.SearchInUrls = true;
else if(chScan == 'P') sp.SearchInPasswords = true;
else if(chScan == 'N') sp.SearchInNotes = true;
else if(chScan == 'I') sp.SearchInUuids = true;
else if(chScan == 'O') sp.SearchInOther = true;
else return null;
PwObjectList<PwEntry> lFound = new PwObjectList<PwEntry>();
ctx.Database.RootGroup.SearchEntries(sp, lFound);
return ((lFound.UCount > 0) ? lFound.GetAt(0) : null);
}
示例2: EntriesHaveSameParent
public static bool EntriesHaveSameParent(PwObjectList<PwEntry> v)
{
if(v == null) { Debug.Assert(false); return true; }
if(v.UCount == 0) return true;
PwGroup pg = v.GetAt(0).ParentGroup;
foreach(PwEntry pe in v)
{
if(pe.ParentGroup != pg) return false;
}
return true;
}
示例3: PerformGlobal
public static bool PerformGlobal(List<PwDatabase> vSources,
ImageList ilIcons)
{
Debug.Assert(vSources != null); if(vSources == null) return false;
if(KeePassLib.Native.NativeLib.IsUnix())
{
if(!NativeMethods.TryXDoTool(true))
{
MessageService.ShowWarning(KPRes.AutoTypeXDoToolRequiredGlobalVer);
return false;
}
}
IntPtr hWnd;
string strWindow;
try
{
// hWnd = NativeMethods.GetForegroundWindowHandle();
// strWindow = NativeMethods.GetWindowText(hWnd);
NativeMethods.GetForegroundWindowInfo(out hWnd, out strWindow, true);
}
catch(Exception) { Debug.Assert(false); hWnd = IntPtr.Zero; strWindow = null; }
if(string.IsNullOrEmpty(strWindow)) return false;
if(!IsValidAutoTypeWindow(hWnd, true)) return false;
PwObjectList<PwEntry> vList = new PwObjectList<PwEntry>();
DateTime dtNow = DateTime.Now;
EntryHandler eh = delegate(PwEntry pe)
{
// Ignore expired entries
if(pe.Expires && (pe.ExpiryTime < dtNow)) return true;
if(GetSequenceForWindow(pe, strWindow, true) != null)
vList.Add(pe);
return true;
};
foreach(PwDatabase pwSource in vSources)
{
if(pwSource.IsOpen == false) continue;
pwSource.RootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh);
}
if(vList.UCount == 1)
AutoType.PerformInternal(vList.GetAt(0), strWindow);
else if(vList.UCount > 1)
{
EntryListForm elf = new EntryListForm();
elf.InitEx(KPRes.AutoTypeEntrySelection, KPRes.AutoTypeEntrySelectionDescShort,
KPRes.AutoTypeEntrySelectionDescLong,
Properties.Resources.B48x48_KGPG_Key2, ilIcons, vList);
elf.EnsureForeground = true;
if(elf.ShowDialog() == DialogResult.OK)
{
try { NativeMethods.EnsureForegroundWindow(hWnd); }
catch(Exception) { Debug.Assert(false); }
if(elf.SelectedEntry != null)
AutoType.PerformInternal(elf.SelectedEntry, strWindow);
}
UIUtil.DestroyForm(elf);
}
return true;
}
示例4: FillRefPlaceholders
private static string FillRefPlaceholders(string strSeq, PwDatabase pwDatabase,
SprContentFlags cf, uint uRecursionLevel, SprRefsCache vRefsCache)
{
if(pwDatabase == null) return strSeq;
string str = strSeq;
const string strStart = @"{REF:";
const string strEnd = @"}";
int nOffset = 0;
for(int iLoop = 0; iLoop < 20; ++iLoop)
{
str = SprEngine.FillRefsUsingCache(str, vRefsCache);
int nStart = str.IndexOf(strStart, nOffset, SprEngine.ScMethod);
if(nStart < 0) break;
int nEnd = str.IndexOf(strEnd, nStart, SprEngine.ScMethod);
if(nEnd < 0) break;
string strFullRef = str.Substring(nStart, nEnd - nStart + 1);
string strRef = str.Substring(nStart + strStart.Length, nEnd -
nStart - strStart.Length);
if(strRef.Length <= 4) { nOffset = nStart + 1; continue; }
if(strRef[1] != '@') { nOffset = nStart + 1; continue; }
if(strRef[3] != ':') { nOffset = nStart + 1; continue; }
char chScan = char.ToUpper(strRef[2]);
char chWanted = char.ToUpper(strRef[0]);
SearchParameters sp = SearchParameters.None;
sp.SearchString = strRef.Substring(4);
if(chScan == 'T') sp.SearchInTitles = true;
else if(chScan == 'U') sp.SearchInUserNames = true;
else if(chScan == 'A') sp.SearchInUrls = true;
else if(chScan == 'P') sp.SearchInPasswords = true;
else if(chScan == 'N') sp.SearchInNotes = true;
else if(chScan == 'I') sp.SearchInUuids = true;
else if(chScan == 'O') sp.SearchInOther = true;
else { nOffset = nStart + 1; continue; }
PwObjectList<PwEntry> lFound = new PwObjectList<PwEntry>();
pwDatabase.RootGroup.SearchEntries(sp, lFound, true);
if(lFound.UCount > 0)
{
PwEntry peFound = lFound.GetAt(0);
string strInsData;
if(chWanted == 'T')
strInsData = peFound.Strings.ReadSafe(PwDefs.TitleField);
else if(chWanted == 'U')
strInsData = peFound.Strings.ReadSafe(PwDefs.UserNameField);
else if(chWanted == 'A')
strInsData = peFound.Strings.ReadSafe(PwDefs.UrlField);
else if(chWanted == 'P')
strInsData = peFound.Strings.ReadSafe(PwDefs.PasswordField);
else if(chWanted == 'N')
strInsData = peFound.Strings.ReadSafe(PwDefs.NotesField);
else if(chWanted == 'I')
strInsData = peFound.Uuid.ToHexString();
else { nOffset = nStart + 1; continue; }
string strInnerContent = SprEngine.CompileInternal(strInsData,
peFound, pwDatabase, null, uRecursionLevel + 1, vRefsCache);
strInnerContent = SprEngine.TransformContent(strInnerContent, cf);
// str = str.Substring(0, nStart) + strInnerContent + str.Substring(nEnd + 1);
SprEngine.AddRefToCache(strFullRef, strInnerContent, vRefsCache);
str = SprEngine.FillRefsUsingCache(str, vRefsCache);
}
else { nOffset = nStart + 1; continue; }
}
return str;
}
示例5: PerformGlobal
public static bool PerformGlobal(List<PwDatabase> vSources,
ImageList ilIcons)
{
Debug.Assert(vSources != null); if(vSources == null) return false;
IntPtr hWnd;
string strWindow;
try
{
hWnd = NativeMethods.GetForegroundWindow();
strWindow = NativeMethods.GetWindowText(hWnd);
}
catch(Exception) { Debug.Assert(false); hWnd = IntPtr.Zero; strWindow = null; }
if((strWindow == null) || (strWindow.Length == 0)) return false;
PwObjectList<PwEntry> m_vList = new PwObjectList<PwEntry>();
DateTime dtNow = DateTime.Now;
EntryHandler eh = delegate(PwEntry pe)
{
// Ignore expired entries
if(pe.Expires && (pe.ExpiryTime < dtNow)) return true;
if(GetSequenceForWindow(pe, strWindow, true) != null)
m_vList.Add(pe);
return true;
};
foreach(PwDatabase pwSource in vSources)
{
if(pwSource.IsOpen == false) continue;
pwSource.RootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh);
}
if(m_vList.UCount == 1)
AutoType.PerformInternal(m_vList.GetAt(0), strWindow);
else if(m_vList.UCount > 1)
{
EntryListForm elf = new EntryListForm();
elf.InitEx(KPRes.AutoTypeEntrySelection, KPRes.AutoTypeEntrySelectionDescShort,
KPRes.AutoTypeEntrySelectionDescLong,
Properties.Resources.B48x48_KGPG_Key2, ilIcons, m_vList);
elf.EnsureForeground = true;
if(elf.ShowDialog() == DialogResult.OK)
{
try { NativeMethods.EnsureForegroundWindow(hWnd); }
catch(Exception) { Debug.Assert(false); }
if(elf.SelectedEntry != null)
AutoType.PerformInternal(elf.SelectedEntry, strWindow);
}
}
return true;
}