本文整理汇总了C#中IOConnectionInfo.GetDisplayName方法的典型用法代码示例。如果您正苦于以下问题:C# IOConnectionInfo.GetDisplayName方法的具体用法?C# IOConnectionInfo.GetDisplayName怎么用?C# IOConnectionInfo.GetDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOConnectionInfo
的用法示例。
在下文中一共展示了IOConnectionInfo.GetDisplayName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: CreateAuxFile
public static bool CreateAuxFile(OtpInfo otpInfo,
KeyProviderQueryContext ctx, IOConnectionInfo auxFileIoc)
{
otpInfo.Type = ProvType;
otpInfo.Version = ProvVersion;
otpInfo.Generator = ProductName;
otpInfo.EncryptSecret();
if(!OtpInfo.Save(auxFileIoc, otpInfo))
{
MessageService.ShowWarning("Failed to save auxiliary OTP info file:",
auxFileIoc.GetDisplayName());
return false;
}
return true;
}
示例3: OnMenuDown
private void OnMenuDown(object sender, EventArgs e) {
Thread uploadThread = new Thread(new ThreadStart(delegate() {
string qiniuurl = QiniuCloud.Instance.GetQiniuUrl(KeePassQiniuConfig.Default.QiniuDataBase);
IOConnectionInfo m_ioc = new IOConnectionInfo();
m_ioc.Path = qiniuurl;
string localSavePath = KeePassQiniuConfig.Default.DataDir + KeePassQiniuConfig.Default.QiniuDataBase;
if(File.Exists(localSavePath)) {
m_host.MainWindow.Invoke(new MethodInvoker(delegate() {
MessageService.ShowWarning("本地数据库存在", "数据库" + KeePassQiniuConfig.Default.QiniuDataBase + "已经存在!");
}));
return;
}
try {
if(!IOConnection.FileExists(m_ioc, true)) {
throw new FileNotFoundException();
} else {
byte[] bytes = IOConnection.ReadFile(m_ioc);
File.WriteAllBytes(localSavePath, bytes);
m_host.MainWindow.Invoke(new MethodInvoker(delegate() {
MessageService.ShowInfo("下载成功");
IOConnectionInfo local = new IOConnectionInfo();
local.Path = localSavePath;
m_host.MainWindow.OpenDatabase(local, null, true);
}));
}
} catch(Exception exTest) {
string strError = exTest.Message;
if(strError.Contains("404")) {
} else {
if((exTest.InnerException != null) &&
!string.IsNullOrEmpty(exTest.InnerException.Message))
strError += MessageService.NewParagraph +
exTest.InnerException.Message;
m_host.MainWindow.Invoke(new MethodInvoker(delegate() {
MessageService.ShowWarning(m_ioc.GetDisplayName(), strError);
}));
}
}
}));
uploadThread.Start();
}
示例4: FixDuplicateUuids
private bool FixDuplicateUuids(PwDatabase pd, IOConnectionInfo ioc)
{
if(pd == null) { Debug.Assert(false); return false; }
if(!pd.HasDuplicateUuids()) return false;
string str = string.Empty;
if(ioc != null)
{
string strFile = ioc.GetDisplayName();
if(!string.IsNullOrEmpty(strFile))
str += strFile + MessageService.NewParagraph;
}
str += KPRes.UuidDupInDb + MessageService.NewParagraph +
KPRes.CorruptionByExt + MessageService.NewParagraph +
KPRes.UuidFix;
if(VistaTaskDialog.ShowMessageBoxEx(str, null,
PwDefs.ShortProductName, VtdIcon.Warning, null,
KPRes.RepairCmd, (int)DialogResult.Cancel, null, 0) < 0)
MessageService.ShowWarning(str);
pd.FixDuplicateUuids();
pd.Modified = true;
return true;
}
示例5: AskIfSynchronizeInstead
private static DialogResult AskIfSynchronizeInstead(IOConnectionInfo ioc)
{
VistaTaskDialog dlg = new VistaTaskDialog();
string strText = string.Empty;
if(ioc.GetDisplayName().Length > 0)
strText += ioc.GetDisplayName() + MessageService.NewParagraph;
strText += KPRes.FileChanged;
dlg.CommandLinks = true;
dlg.WindowTitle = PwDefs.ShortProductName;
dlg.Content = strText;
dlg.SetIcon(VtdCustomIcon.Question);
dlg.MainInstruction = KPRes.OverwriteExistingFileQuestion;
dlg.AddButton((int)DialogResult.Yes, KPRes.Synchronize, KPRes.FileChangedSync);
dlg.AddButton((int)DialogResult.No, KPRes.Overwrite, KPRes.FileChangedOverwrite);
dlg.AddButton((int)DialogResult.Cancel, KPRes.Cancel, KPRes.FileSaveQOpCancel);
DialogResult dr;
if(dlg.ShowDialog()) dr = (DialogResult)dlg.Result;
else
{
strText += MessageService.NewParagraph;
strText += @"[" + KPRes.Yes + @"]: " + KPRes.Synchronize + @". " +
KPRes.FileChangedSync + MessageService.NewParagraph;
strText += @"[" + KPRes.No + @"]: " + KPRes.Overwrite + @". " +
KPRes.FileChangedOverwrite + MessageService.NewParagraph;
strText += @"[" + KPRes.Cancel + @"]: " + KPRes.FileSaveQOpCancel;
dr = MessageService.Ask(strText, PwDefs.ShortProductName,
MessageBoxButtons.YesNoCancel);
}
return dr;
}
示例6: 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);
}
示例7: 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;
}
示例8: Create
// Throws on error
public static LockFileInfo Create(IOConnectionInfo iocLockFile)
{
LockFileInfo lfi;
Stream s = null;
try
{
byte[] pbID = CryptoRandom.Instance.GetRandomBytes(16);
string strTime = TimeUtil.SerializeUtc(DateTime.Now);
lfi = new LockFileInfo(Convert.ToBase64String(pbID), strTime,
#if KeePassUAP
EnvironmentExt.UserName, EnvironmentExt.MachineName,
EnvironmentExt.UserDomainName);
#elif KeePassLibSD
string.Empty, string.Empty, string.Empty);
#else
Environment.UserName, Environment.MachineName,
Environment.UserDomainName);
#endif
StringBuilder sb = new StringBuilder();
#if !KeePassLibSD
sb.AppendLine(LockFileHeader);
sb.AppendLine(lfi.ID);
sb.AppendLine(strTime);
sb.AppendLine(lfi.UserName);
sb.AppendLine(lfi.Machine);
sb.AppendLine(lfi.Domain);
#else
sb.Append(LockFileHeader + MessageService.NewLine);
sb.Append(lfi.ID + MessageService.NewLine);
sb.Append(strTime + MessageService.NewLine);
sb.Append(lfi.UserName + MessageService.NewLine);
sb.Append(lfi.Machine + MessageService.NewLine);
sb.Append(lfi.Domain + MessageService.NewLine);
#endif
byte[] pbFile = StrUtil.Utf8.GetBytes(sb.ToString());
s = IOConnection.OpenWrite(iocLockFile);
if(s == null) throw new IOException(iocLockFile.GetDisplayName());
s.Write(pbFile, 0, pbFile.Length);
}
finally { if(s != null) s.Close(); }
return lfi;
}
示例9: Import
public static bool? Import(PwDatabase pd, FileFormatProvider fmtImp,
IOConnectionInfo iocImp, PwMergeMethod mm, CompositeKey cmpKey)
{
if(pd == null) { Debug.Assert(false); return false; }
if(fmtImp == null) { Debug.Assert(false); return false; }
if(iocImp == null) { Debug.Assert(false); return false; }
if(cmpKey == null) cmpKey = new CompositeKey();
if(!AppPolicy.Try(AppPolicyId.Import)) return false;
if(!fmtImp.TryBeginImport()) return false;
PwDatabase pdImp = new PwDatabase();
pdImp.New(new IOConnectionInfo(), cmpKey);
pdImp.MemoryProtection = pd.MemoryProtection.CloneDeep();
Stream s = IOConnection.OpenRead(iocImp);
if(s == null)
throw new FileNotFoundException(iocImp.GetDisplayName() +
MessageService.NewLine + KPRes.FileNotFoundError);
try { fmtImp.Import(pdImp, s, null); }
finally { s.Close(); }
pd.MergeIn(pdImp, mm);
return true;
}
示例10: GetFilePath
public IOConnectionInfo GetFilePath(IOConnectionInfo folderPath, string filename)
{
try
{
return IOConnectionInfo.FromPath(
ListContents(folderPath).Where(desc => { return desc.DisplayName == filename; })
.Single()
.Path);
}
catch (Exception e)
{
throw new Exception("Error finding " + filename + " in " + folderPath.GetDisplayName(), e);
}
}
示例11: OpenDatabaseInternal
private PwDatabase OpenDatabaseInternal(IOConnectionInfo ioc, CompositeKey cmpKey)
{
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;
try
{
pwDb.Open(ioc, cmpKey, swLogger);
#if DEBUG
byte[] pbDiskDirect = WinUtil.HashFile(ioc);
Debug.Assert(MemUtil.ArraysEqual(pbDiskDirect, pwDb.HashOfFileOnDisk));
#endif
}
catch(Exception ex)
{
MessageService.ShowLoadWarning(ioc.GetDisplayName(), ex);
pwDb = null;
}
swLogger.EndLogging();
if(pwDb == null)
{
if(ds == null) m_docMgr.CloseDatabase(m_docMgr.ActiveDatabase);
}
return pwDb;
}
示例12: PostSavingEx
private void PostSavingEx(bool bPrimary, PwDatabase pwDatabase, IOConnectionInfo ioc)
{
if(ioc == null) { Debug.Assert(false); return; }
byte[] pbIO = WinUtil.HashFile(ioc);
Debug.Assert((pbIO != null) && (pwDatabase.HashOfLastIO != null));
if(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());
Program.Config.Application.LastUsedFile = ioc.CloneDeep();
}
WinUtil.FlushStorageBuffers(ioc.Path, true);
}
示例13: GetDisplayName
public string GetDisplayName(IOConnectionInfo ioc)
{
return ioc.GetDisplayName();
}
示例14: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
_design.ApplyTheme();
//use FlagSecure to make sure the last (revealed) character of the master password is not visible in recent apps
if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(
GetString(Resource.String.ViewDatabaseSecure_key), true))
{
Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure);
}
Intent i = Intent;
//only load the AppTask if this is the "first" OnCreate (not because of kill/resume, i.e. savedInstanceState==null)
// and if the activity is not launched from history (i.e. recent tasks) because this would mean that
// the Activity was closed already (user cancelling the task or task complete) but is restarted due recent tasks.
// Don't re-start the task (especially bad if tak was complete already)
if (Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory))
{
AppTask = new NullTask();
}
else
{
AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent);
}
String action = i.Action;
_prefs = PreferenceManager.GetDefaultSharedPreferences(this);
_rememberKeyfile = _prefs.GetBoolean(GetString(Resource.String.keyfile_key), Resources.GetBoolean(Resource.Boolean.keyfile_default));
_ioConnection = new IOConnectionInfo();
if (action != null && action.Equals(ViewIntent))
{
if (!GetIocFromViewIntent(i)) return;
}
else if ((action != null) && (action.Equals(Intents.StartWithOtp)))
{
if (!GetIocFromOtpIntent(savedInstanceState, i)) return;
_keepPasswordInOnResume = true;
}
else
{
SetIoConnectionFromIntent(_ioConnection, i);
var keyFileFromIntent = i.GetStringExtra(KeyKeyfile);
if (keyFileFromIntent != null)
{
Kp2aLog.Log("try get keyfile from intent");
_keyFileOrProvider = IOConnectionInfo.SerializeToString(IOConnectionInfo.FromPath(keyFileFromIntent));
Kp2aLog.Log("try get keyfile from intent ok");
}
else
{
_keyFileOrProvider = null;
}
_password = i.GetStringExtra(KeyPassword) ?? "";
if (string.IsNullOrEmpty(_keyFileOrProvider))
{
_keyFileOrProvider = GetKeyFile(_ioConnection.Path);
}
if ((!string.IsNullOrEmpty(_keyFileOrProvider)) || (_password != ""))
{
_keepPasswordInOnResume = true;
}
}
if (App.Kp2a.GetDb().Loaded && App.Kp2a.GetDb().Ioc != null &&
App.Kp2a.GetDb().Ioc.GetDisplayName() != _ioConnection.GetDisplayName())
{
// A different database is currently loaded, unload it before loading the new one requested
App.Kp2a.LockDatabase(false);
}
SetContentView(Resource.Layout.password);
InitializeFilenameView();
if (KeyProviderType == KeyProviders.KeyFile)
{
UpdateKeyfileIocView();
}
FindViewById<EditText>(Resource.Id.password).TextChanged +=
(sender, args) =>
{
_password = FindViewById<EditText>(Resource.Id.password).Text;
UpdateOkButtonState();
};
FindViewById<EditText>(Resource.Id.password).EditorAction += (sender, args) =>
{
if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down)))
OnOk();
};
FindViewById<EditText>(Resource.Id.pass_otpsecret).TextChanged += (sender, args) => UpdateOkButtonState();
EditText passwordEdit = FindViewById<EditText>(Resource.Id.password);
passwordEdit.Text = _password;
passwordEdit.RequestFocus();
//.........这里部分代码省略.........
示例15: IocChanged
static bool IocChanged(IOConnectionInfo ioc, IOConnectionInfo other)
{
if ((ioc == null) || (other == null)) return false;
return ioc.GetDisplayName() != other.GetDisplayName();
}