本文整理汇总了C#中IOConnectionInfo.CloneDeep方法的典型用法代码示例。如果您正苦于以下问题:C# IOConnectionInfo.CloneDeep方法的具体用法?C# IOConnectionInfo.CloneDeep怎么用?C# IOConnectionInfo.CloneDeep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOConnectionInfo
的用法示例。
在下文中一共展示了IOConnectionInfo.CloneDeep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KeyProviderQueryContext
public KeyProviderQueryContext(IOConnectionInfo ioInfo, bool bCreatingNewKey)
{
if(ioInfo == null) throw new ArgumentNullException("ioInfo");
m_ioInfo = ioInfo.CloneDeep();
m_bCreatingNewKey = bCreatingNewKey;
}
示例2: Initialize
private void Initialize(IOConnectionInfo iocBaseFile, bool bTransacted)
{
if(iocBaseFile == null) throw new ArgumentNullException("iocBaseFile");
m_bTransacted = bTransacted;
m_iocBase = iocBaseFile.CloneDeep();
string strPath = m_iocBase.Path;
// Prevent transactions for FTP URLs under .NET 4.0 in order to
// avoid/workaround .NET bug 621450:
// https://connect.microsoft.com/VisualStudio/feedback/details/621450/problem-renaming-file-on-ftp-server-using-ftpwebrequest-in-net-framework-4-0-vs2010-only
if(strPath.StartsWith("ftp:", StrUtil.CaseIgnoreCmp) &&
(Environment.Version.Major >= 4) && !NativeLib.IsUnix())
m_bTransacted = false;
else
{
foreach(KeyValuePair<string, bool> kvp in g_dEnabled)
{
if(strPath.StartsWith(kvp.Key, StrUtil.CaseIgnoreCmp))
{
m_bTransacted = kvp.Value;
break;
}
}
}
if(m_bTransacted)
{
m_iocTemp = m_iocBase.CloneDeep();
m_iocTemp.Path += StrTempSuffix;
}
else m_iocTemp = m_iocBase;
}
示例3: InitEx
public void InitEx(bool bSave, IOConnectionInfo ioc, bool bCanRememberCred,
bool bTestConnection)
{
m_bSave = bSave;
if(ioc != null) m_ioc = ioc.CloneDeep();
m_bCanRememberCred = bCanRememberCred;
m_bTestConnection = bTestConnection;
}
示例4: Initialize
private void Initialize(IOConnectionInfo iocBaseFile, bool bTransacted)
{
if(iocBaseFile == null) throw new ArgumentNullException("iocBaseFile");
m_bTransacted = bTransacted;
m_iocBase = iocBaseFile.CloneDeep();
string strPath = m_iocBase.Path;
if(m_iocBase.IsLocalFile())
{
try
{
if(File.Exists(strPath))
{
// Symbolic links are realized via reparse points;
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365503.aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365680.aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006.aspx
// Performing a file transaction on a symbolic link
// would delete/replace the symbolic link instead of
// writing to its target
FileAttributes fa = File.GetAttributes(strPath);
if((long)(fa & FileAttributes.ReparsePoint) != 0)
m_bTransacted = false;
}
}
catch(Exception) { Debug.Assert(false); }
}
#if !KeePassUAP
// Prevent transactions for FTP URLs under .NET 4.0 in order to
// avoid/workaround .NET bug 621450:
// https://connect.microsoft.com/VisualStudio/feedback/details/621450/problem-renaming-file-on-ftp-server-using-ftpwebrequest-in-net-framework-4-0-vs2010-only
if(strPath.StartsWith("ftp:", StrUtil.CaseIgnoreCmp) &&
(Environment.Version.Major >= 4) && !NativeLib.IsUnix())
m_bTransacted = false;
#endif
foreach(KeyValuePair<string, bool> kvp in g_dEnabled)
{
if(strPath.StartsWith(kvp.Key, StrUtil.CaseIgnoreCmp))
{
m_bTransacted = kvp.Value;
break;
}
}
if(m_bTransacted)
{
m_iocTemp = m_iocBase.CloneDeep();
m_iocTemp.Path += StrTempSuffix;
}
else m_iocTemp = m_iocBase;
}
示例5: Initialize
private void Initialize(IOConnectionInfo iocBaseFile, bool bTransacted)
{
if(iocBaseFile == null) throw new ArgumentNullException("iocBaseFile");
m_bTransacted = bTransacted;
m_iocBase = iocBaseFile.CloneDeep();
if(m_bTransacted)
{
m_iocTemp = m_iocBase.CloneDeep();
m_iocTemp.Path += StrTempSuffix;
}
else m_iocTemp = m_iocBase;
}
示例6: GetParentPath
public static IOConnectionInfo GetParentPath(IOConnectionInfo ioc)
{
var iocParent = ioc.CloneDeep();
if (iocParent.Path.EndsWith("/"))
iocParent.Path = iocParent.Path.Substring(0, iocParent.Path.Length - 1);
int slashPos = iocParent.Path.LastIndexOf("/", StringComparison.Ordinal);
if (slashPos == -1)
iocParent.Path = "";
else
{
iocParent.Path = iocParent.Path.Substring(0, slashPos);
}
return iocParent;
}
示例7: FileLock
public FileLock(IOConnectionInfo iocBaseFile)
{
if(iocBaseFile == null) throw new ArgumentNullException("strBaseFile");
m_iocLockFile = iocBaseFile.CloneDeep();
m_iocLockFile.Path += LockFileExt;
LockFileInfo lfiEx = LockFileInfo.Load(m_iocLockFile);
if(lfiEx != null)
{
m_iocLockFile = null; // Otherwise Dispose deletes the existing one
throw new FileLockException(iocBaseFile.GetDisplayName(),
lfiEx.GetOwner());
}
LockFileInfo.Create(m_iocLockFile);
}
示例8: GetPseudoIoc
private IOConnectionInfo GetPseudoIoc(IOConnectionInfo folderPath, string filename)
{
IOConnectionInfo res = folderPath.CloneDeep();
if (!res.Path.EndsWith("/"))
res.Path += "/";
res.Path += filename;
return res;
}
示例9: PostSavingEx
private void PostSavingEx(bool bPrimary, PwDatabase pwDatabase,
IOConnectionInfo ioc, IStatusLogger sl)
{
if(ioc == null) { Debug.Assert(false); return; }
byte[] pbIO = null;
if(Program.Config.Application.VerifyWrittenFileAfterSaving)
{
pbIO = WinUtil.HashFile(ioc);
Debug.Assert((pbIO != null) && (pwDatabase.HashOfLastIO != null));
if(!MemUtil.ArraysEqual(pbIO, pwDatabase.HashOfLastIO))
MessageService.ShowWarning(ioc.GetDisplayName(),
KPRes.FileVerifyHashFail, KPRes.FileVerifyHashFailRec);
}
if(bPrimary)
{
#if DEBUG
Debug.Assert(MemUtil.ArraysEqual(pbIO, pwDatabase.HashOfFileOnDisk));
try
{
PwDatabase pwCheck = new PwDatabase();
pwCheck.Open(ioc.CloneDeep(), pwDatabase.MasterKey, null);
Debug.Assert(MemUtil.ArraysEqual(pwDatabase.HashOfLastIO,
pwCheck.HashOfLastIO));
uint uGroups1, uGroups2, uEntries1, uEntries2;
pwDatabase.RootGroup.GetCounts(true, out uGroups1, out uEntries1);
pwCheck.RootGroup.GetCounts(true, out uGroups2, out uEntries2);
Debug.Assert((uGroups1 == uGroups2) && (uEntries1 == uEntries2));
}
catch(Exception exVerify) { Debug.Assert(false, exVerify.Message); }
#endif
m_mruList.AddItem(ioc.GetDisplayName(), ioc.CloneDeep());
// SetLastUsedFile(ioc);
// if(Program.Config.Application.CreateBackupFileAfterSaving && bHashValid)
// {
// try { pwDatabase.CreateBackupFile(sl); }
// catch(Exception exBackup)
// {
// MessageService.ShowWarning(KPRes.FileBackupFailed, exBackup);
// }
// }
// ulong uTotalBinSize = 0;
// EntryHandler ehCnt = delegate(PwEntry pe)
// {
// foreach(KeyValuePair<string, ProtectedBinary> kvpCnt in pe.Binaries)
// {
// uTotalBinSize += kvpCnt.Value.Length;
// }
//
// return true;
// };
// pwDatabase.RootGroup.TraverseTree(TraversalMethod.PreOrder, null, ehCnt);
}
RememberKeySources(pwDatabase);
WinUtil.FlushStorageBuffers(ioc.Path, true);
}
示例10: OpenDatabaseInternal
private PwDatabase OpenDatabaseInternal(IOConnectionInfo ioc,
CompositeKey cmpKey, out bool bAbort)
{
bAbort = false;
PerformSelfTest();
ShowWarningsLogger swLogger = CreateShowWarningsLogger();
swLogger.StartLogging(KPRes.OpeningDatabase, true);
PwDocument ds = null;
string strPathNrm = ioc.Path.Trim().ToLower();
for(int iScan = 0; iScan < m_docMgr.Documents.Count; ++iScan)
{
if(m_docMgr.Documents[iScan].LockedIoc.Path.Trim().ToLower() == strPathNrm)
ds = m_docMgr.Documents[iScan];
else if(m_docMgr.Documents[iScan].Database.IOConnectionInfo.Path == strPathNrm)
ds = m_docMgr.Documents[iScan];
}
PwDatabase pwDb;
if(ds == null) pwDb = m_docMgr.CreateNewDocument(true).Database;
else pwDb = ds.Database;
Exception ex = null;
try
{
pwDb.Open(ioc, cmpKey, swLogger);
#if DEBUG
byte[] pbDiskDirect = WinUtil.HashFile(ioc);
Debug.Assert(MemUtil.ArraysEqual(pbDiskDirect, pwDb.HashOfFileOnDisk));
#endif
}
catch(Exception exLoad)
{
ex = exLoad;
pwDb = null;
}
swLogger.EndLogging();
if(pwDb == null)
{
if(ds == null) m_docMgr.CloseDatabase(m_docMgr.ActiveDatabase);
}
if(ex != null)
{
string strMsg = MessageService.GetLoadWarningMessage(
ioc.GetDisplayName(), ex,
(Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null));
bool bShowStd = true;
if(!ioc.IsLocalFile())
{
VistaTaskDialog vtd = new VistaTaskDialog();
vtd.CommandLinks = false;
vtd.Content = strMsg;
vtd.DefaultButtonID = (int)DialogResult.Cancel;
// vtd.VerificationText = KPRes.CredSpecifyDifferent;
vtd.WindowTitle = PwDefs.ShortProductName;
vtd.SetIcon(VtdIcon.Warning);
vtd.AddButton((int)DialogResult.Cancel, KPRes.Ok, null);
vtd.AddButton((int)DialogResult.Retry,
KPRes.CredSpecifyDifferent, null);
if(vtd.ShowDialog(this))
{
bShowStd = false;
// if(vtd.ResultVerificationChecked)
if(vtd.Result == (int)DialogResult.Retry)
{
IOConnectionInfo iocNew = ioc.CloneDeep();
// iocNew.ClearCredentials(false);
iocNew.CredSaveMode = IOCredSaveMode.NoSave;
iocNew.IsComplete = false;
// iocNew.Password = string.Empty;
OpenDatabase(iocNew, null, false);
bAbort = true;
}
}
}
if(bShowStd) MessageService.ShowWarning(strMsg);
// MessageService.ShowLoadWarning(ioc.GetDisplayName(), ex,
// (Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null));
}
return pwDb;
}
示例11: OpenDatabase
/// <summary>
/// Open a database. This function opens the specified database and updates
/// the user interface.
/// </summary>
public void OpenDatabase(IOConnectionInfo ioConnection, CompositeKey cmpKey,
bool bOpenLocal)
{
if(!m_bFormLoaded && Program.Config.Application.Start.MinimizedAndLocked &&
(ioConnection != null) && (ioConnection.Path.Length > 0))
{
PwDocument ds = m_docMgr.CreateNewDocument(true);
ds.LockedIoc = ioConnection.CloneDeep();
UpdateUI(true, ds, true, null, true, null, false);
return;
}
SaveWindowState(); // KPF 1093
IOConnectionInfo ioc;
if(ioConnection == null)
{
if(bOpenLocal)
{
OpenFileDialogEx ofdDb = UIUtil.CreateOpenFileDialog(KPRes.OpenDatabaseFile,
UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt,
KPRes.KdbxFiles, true), 1, null, false,
AppDefs.FileDialogContext.Database);
GlobalWindowManager.AddDialog(ofdDb.FileDialog);
DialogResult dr = ofdDb.ShowDialog();
GlobalWindowManager.RemoveDialog(ofdDb.FileDialog);
if(dr != DialogResult.OK) return;
ioc = IOConnectionInfo.FromPath(ofdDb.FileName);
}
else
{
ioc = CompleteConnectionInfo(new IOConnectionInfo(), false,
true, true, true);
if(ioc == null) return;
}
}
else // ioConnection != null
{
ioc = CompleteConnectionInfo(ioConnection, false, true, true, false);
if(ioc == null) return;
}
if(!ioc.CanProbablyAccess())
{
MessageService.ShowWarning(ioc.GetDisplayName(), KPRes.FileNotFoundError);
return;
}
if(OpenDatabaseRestoreIfOpened(ioc)) return;
PwDatabase pwOpenedDb = null;
bool bAbort;
if(cmpKey == null)
{
for(int iTry = 0; iTry < 3; ++iTry)
{
OdKpfConstructParams kpfParams = new OdKpfConstructParams();
kpfParams.IOConnectionInfo = ioc;
kpfParams.CanExit = IsFileLocked(null);
DialogResult dr;
OdKpfResult kpfResult;
if(Program.Config.Security.MasterKeyOnSecureDesktop &&
WinUtil.IsAtLeastWindows2000 &&
!KeePassLib.Native.NativeLib.IsUnix())
{
kpfParams.SecureDesktopMode = true;
ProtectedDialog dlg = new ProtectedDialog(OdKpfConstruct,
OdKpfBuildResult);
object objResult;
dr = dlg.ShowDialog(out objResult, kpfParams);
if(dr == DialogResult.None) { Debug.Assert(false); dr = DialogResult.Cancel; }
kpfResult = (objResult as OdKpfResult);
if(kpfResult == null) { Debug.Assert(false); continue; }
if(kpfResult.ShowHelpAfterClose)
AppHelp.ShowHelp(AppDefs.HelpTopics.KeySources, null);
}
else // Show dialog on normal desktop
{
Form dlg = OdKpfConstruct(kpfParams);
dr = dlg.ShowDialog();
kpfResult = (OdKpfBuildResult(dlg) as OdKpfResult);
UIUtil.DestroyForm(dlg);
if(kpfResult == null) { Debug.Assert(false); continue; }
}
if(dr == DialogResult.Cancel) break;
else if(kpfResult.HasClosedWithExit)
{
//.........这里部分代码省略.........
示例12: CompleteConnectionInfo
internal static IOConnectionInfo CompleteConnectionInfo(IOConnectionInfo ioc,
bool bSave, bool bCanRememberCred, bool bTestConnection, bool bForceShow)
{
if(ioc == null) { Debug.Assert(false); return null; }
if(!bForceShow && ((ioc.CredSaveMode == IOCredSaveMode.SaveCred) ||
ioc.IsLocalFile() || ioc.IsComplete))
return ioc.CloneDeep();
IOConnectionForm dlg = new IOConnectionForm();
dlg.InitEx(bSave, ioc.CloneDeep(), bCanRememberCred, bTestConnection);
if(UIUtil.ShowDialogNotValue(dlg, DialogResult.OK)) return null;
IOConnectionInfo iocResult = dlg.IOConnectionInfo;
UIUtil.DestroyForm(dlg);
return iocResult;
}
示例13: RaiseIOAccessPreEvent
private static void RaiseIOAccessPreEvent(IOConnectionInfo ioc,
IOConnectionInfo ioc2, IOAccessType t)
{
if(ioc == null) { Debug.Assert(false); return; }
// ioc2 may be null
if(IOConnection.IOAccessPre != null)
{
IOConnectionInfo ioc2Lcl = ((ioc2 != null) ? ioc2.CloneDeep() : null);
IOAccessEventArgs e = new IOAccessEventArgs(ioc.CloneDeep(), ioc2Lcl, t);
IOConnection.IOAccessPre(null, e);
}
}
示例14: SetLastUsedFile
private static void SetLastUsedFile(IOConnectionInfo ioc)
{
if(ioc == null) { Debug.Assert(false); return; }
AceApplication aceApp = Program.Config.Application;
if(aceApp.Start.OpenLastFile)
{
if(!string.IsNullOrEmpty(ioc.Path))
aceApp.LastUsedFile = ioc.CloneDeep();
}
else aceApp.LastUsedFile = new IOConnectionInfo();
}
示例15: OpenDatabase
/// <summary>
/// Open a database. This function opens the specified database and updates
/// the user interface.
/// </summary>
public void OpenDatabase(IOConnectionInfo ioConnection, CompositeKey cmpKey,
bool bOpenLocal)
{
// OnFileClose(null, null);
// if(m_docMgr.ActiveDatabase.IsOpen) return;
if(m_bFormLoading && Program.Config.Application.Start.MinimizedAndLocked &&
(ioConnection != null) && (ioConnection.Path.Length > 0))
{
PwDocument ds = m_docMgr.CreateNewDocument(true);
ds.LockedIoc = ioConnection.CloneDeep();
UpdateUI(true, ds, true, null, true, null, false);
return;
}
IOConnectionInfo ioc;
if(ioConnection == null)
{
if(bOpenLocal)
{
OpenFileDialog ofdDb = UIUtil.CreateOpenFileDialog(KPRes.OpenDatabaseFile,
UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt,
KPRes.KdbxFiles, true), 1, null, false, false);
GlobalWindowManager.AddDialog(ofdDb);
DialogResult dr = ofdDb.ShowDialog();
GlobalWindowManager.RemoveDialog(ofdDb);
if(dr != DialogResult.OK) return;
ioc = IOConnectionInfo.FromPath(ofdDb.FileName);
}
else
{
ioc = CompleteConnectionInfo(new IOConnectionInfo(), false,
true, true, true);
if(ioc == null) return;
}
}
else // ioConnection != null
{
ioc = CompleteConnectionInfo(ioConnection, false, true, true, false);
if(ioc == null) return;
}
if(!ioc.CanProbablyAccess())
{
MessageService.ShowWarning(ioc.GetDisplayName(), KPRes.FileNotFoundError);
return;
}
if(OpenDatabaseRestoreIfOpened(ioc)) return;
PwDatabase pwOpenedDb = null;
if(cmpKey == null)
{
for(int iTry = 0; iTry < 3; ++iTry)
{
KeyPromptForm kpf = new KeyPromptForm();
kpf.InitEx(ioc, IsFileLocked(null), true);
DialogResult dr = kpf.ShowDialog();
if(dr == DialogResult.Cancel) break;
else if(kpf.HasClosedWithExit)
{
Debug.Assert(dr == DialogResult.Abort);
OnFileExit(null, null);
return;
}
pwOpenedDb = OpenDatabaseInternal(ioc, kpf.CompositeKey);
if(pwOpenedDb != null) break;
}
}
else // cmpKey != null
{
pwOpenedDb = OpenDatabaseInternal(ioc, cmpKey);
}
if((pwOpenedDb == null) || !pwOpenedDb.IsOpen) return;
string strName = pwOpenedDb.IOConnectionInfo.GetDisplayName();
m_mruList.AddItem(strName, pwOpenedDb.IOConnectionInfo.CloneDeep(), true);
PwDocument dsExisting = m_docMgr.FindDocument(pwOpenedDb);
if(dsExisting != null) m_docMgr.ActiveDocument = dsExisting;
bool bCorrectDbActive = (m_docMgr.ActiveDocument.Database == pwOpenedDb);
Debug.Assert(bCorrectDbActive);
// AutoEnableVisualHiding();
SetLastUsedFile(pwOpenedDb.IOConnectionInfo);
RememberKeyFilePath(pwOpenedDb);
PwGroup pgRestoreSelect = null;
if(bCorrectDbActive)
//.........这里部分代码省略.........