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


C# IOConnectionInfo类代码示例

本文整理汇总了C#中IOConnectionInfo的典型用法代码示例。如果您正苦于以下问题:C# IOConnectionInfo类的具体用法?C# IOConnectionInfo怎么用?C# IOConnectionInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: TestCreateSaveAndLoad_TestIdenticalFiles_kdb

        public void TestCreateSaveAndLoad_TestIdenticalFiles_kdb()
        {
            string filename = DefaultDirectory + "createsaveandload.kdb";
            IKp2aApp app = SetupAppWithDatabase(filename);
            string kdbxXml = DatabaseToXml(app);
            //save it and reload it
            Android.Util.Log.Debug("KP2A", "-- Save DB -- ");
            SaveDatabase(app);
            Android.Util.Log.Debug("KP2A", "-- Load DB -- ");

            PwDatabase pwImp = new PwDatabase();
            PwDatabase pwDatabase = app.GetDb().KpDatabase;
            pwImp.New(new IOConnectionInfo(), pwDatabase.MasterKey);
            pwImp.MemoryProtection = pwDatabase.MemoryProtection.CloneDeep();
            pwImp.MasterKey = pwDatabase.MasterKey;

            IOConnectionInfo ioc = new IOConnectionInfo() {Path = filename};
            using (Stream s = app.GetFileStorage(ioc).OpenFileForRead(ioc))
            {
                app.GetDb().DatabaseFormat.PopulateDatabaseFromStream(pwImp, s, null);
            }
            string kdbxReloadedXml = DatabaseToXml(app);

            RemoveKdbLines(ref kdbxReloadedXml);
            RemoveKdbLines(ref kdbxXml);

            Assert.AreEqual(kdbxXml, kdbxReloadedXml);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:28,代码来源:TestSaveDb.cs

示例2: Construct

		private void Construct(IOConnectionInfo iocFile, bool bThrowIfDbFile)
		{
			byte[] pbFileData = IOConnection.ReadFile(iocFile);
			if(pbFileData == null) throw new FileNotFoundException();

			if(bThrowIfDbFile && (pbFileData.Length >= 8))
			{
				uint uSig1 = MemUtil.BytesToUInt32(MemUtil.Mid(pbFileData, 0, 4));
				uint uSig2 = MemUtil.BytesToUInt32(MemUtil.Mid(pbFileData, 4, 4));

				if(((uSig1 == KdbxFile.FileSignature1) &&
					(uSig2 == KdbxFile.FileSignature2)) ||
					((uSig1 == KdbxFile.FileSignaturePreRelease1) &&
					(uSig2 == KdbxFile.FileSignaturePreRelease2)) ||
					((uSig1 == KdbxFile.FileSignatureOld1) &&
					(uSig2 == KdbxFile.FileSignatureOld2)))
#if KeePassLibSD
					throw new Exception(KLRes.KeyFileDbSel);
#else
					throw new InvalidDataException(KLRes.KeyFileDbSel);
#endif
			}

			byte[] pbKey = LoadXmlKeyFile(pbFileData);
			if(pbKey == null) pbKey = LoadKeyFile(pbFileData);

			if(pbKey == null) throw new InvalidOperationException();

			m_strPath = iocFile.Path;
			m_pbKeyData = new ProtectedBinary(true, pbKey);

			MemUtil.ZeroByteArray(pbKey);
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:33,代码来源:KcpKeyFile.cs

示例3: 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;
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:34,代码来源:FileTransactionEx.cs

示例4: Invoke

        public async Task<object> Invoke(dynamic args)
        {
            var argsLookup = (IDictionary<string, object>)args;
            int databaseHandle = -1;
            string name = null, path = null;


            if (argsLookup.ContainsKey("handle"))
                databaseHandle = (int)argsLookup["database"];

            if (argsLookup.ContainsKey("name"))
                name = (string)argsLookup["name"];

            if (argsLookup.ContainsKey("path"))
                path = (string)argsLookup["path"];


            var database = TypedHandleTracker.GetObject<PwDatabase>(databaseHandle);

            if(database.Name != name)
                database.Name = name;
            

            if(database.IOConnectionInfo.Path != path)
            {
                var ioc = new IOConnectionInfo() { Path = path };
                database.SaveAs(ioc, true, null);
                return new { handle = databaseHandle, path = path, name = name };
            }

            
            database.Save(null);
            return new { handle = databaseHandle, path = path, name = name };
        }
开发者ID:badmishkallc,项目名称:jolt9-devops,代码行数:34,代码来源:SaveKeePassDatabaseCommand.cs

示例5: CreateAndSaveLocal

        public void CreateAndSaveLocal()
        {
            IKp2aApp app = new TestKp2aApp();
            IOConnectionInfo ioc = new IOConnectionInfo {Path = DefaultFilename};

            File outputDir = new File(DefaultDirectory);
            outputDir.Mkdirs();
            File targetFile = new File(ioc.Path);
            if (targetFile.Exists())
                targetFile.Delete();

            bool createSuccesful = false;
            //create the task:
            CreateDb createDb = new CreateDb(app, Application.Context, ioc, new ActionOnFinish((success, message) =>
                { createSuccesful = success;
                    if (!success)
                        Android.Util.Log.Debug("KP2A_Test", message);
                }), false);
            //run it:

            createDb.Run();
            //check expectations:
            Assert.IsTrue(createSuccesful);
            Assert.IsNotNull(app.GetDb());
            Assert.IsNotNull(app.GetDb().KpDatabase);
            //the create task should create two groups:
            Assert.AreEqual(2, app.GetDb().KpDatabase.RootGroup.Groups.Count());

            //ensure the the database can be loaded from file:
            PwDatabase loadedDb = new PwDatabase();
            loadedDb.Open(ioc, new CompositeKey(), null, new KdbxDatabaseFormat(KdbxFormat.Default));

            //Check whether the databases are equal
            AssertDatabasesAreEqual(loadedDb, app.GetDb().KpDatabase);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:35,代码来源:TestCreateDb.cs

示例6: KeyProviderQueryContext

		public KeyProviderQueryContext(IOConnectionInfo ioInfo, bool bCreatingNewKey)
		{
			if(ioInfo == null) throw new ArgumentNullException("ioInfo");

			m_ioInfo = ioInfo.CloneDeep();
			m_bCreatingNewKey = bCreatingNewKey;
		}
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:7,代码来源:KeyProvider.cs

示例7: GetDisplayName

 public string GetDisplayName(IOConnectionInfo ioc)
 {
     string displayName = null;
     if (TryGetDisplayName(ioc, ref displayName))
         return "content://" + displayName; //make sure we return the protocol in the display name for consistency, also expected e.g. by CreateDatabaseActivity
     return ioc.Path;
 }
开发者ID:pythe,项目名称:wristpass,代码行数:7,代码来源:AndroidContentStorage.cs

示例8: InitEx

		public void InitEx(IOConnectionInfo ioInfo, bool bCanExit,
			bool bRedirectActivation)
		{
			if(ioInfo != null) m_ioInfo = ioInfo;

			m_bCanExit = bCanExit;
			m_bRedirectActivation = bRedirectActivation;
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:8,代码来源:KeyPromptForm.cs

示例9: InitEx

 public void InitEx(bool bSave, IOConnectionInfo ioc, bool bCanRememberCred,
     bool bTestConnection)
 {
     m_bSave = bSave;
     if(ioc != null) m_ioc = ioc;
     m_bCanRememberCred = bCanRememberCred;
     m_bTestConnection = bTestConnection;
 }
开发者ID:ashwingj,项目名称:keepass2,代码行数:8,代码来源:IOConnectionForm.cs

示例10: CreateDb

 public CreateDb(IKp2aApp app, Context ctx, IOConnectionInfo ioc, OnFinish finish, bool dontSave)
     : base(finish)
 {
     _ctx = ctx;
     _ioc = ioc;
     _dontSave = dontSave;
     _app = app;
 }
开发者ID:pythe,项目名称:wristpass,代码行数:8,代码来源:CreateDB.cs

示例11: StartFileUsageProcess

		public void StartFileUsageProcess(IOConnectionInfo ioc, int requestCode, bool alwaysReturnSuccess)
		{
			Intent fileStorageSetupIntent = new Intent(_activity, typeof(FileStorageSetupActivity));
			fileStorageSetupIntent.PutExtra(FileStorageSetupDefs.ExtraProcessName, FileStorageSetupDefs.ProcessNameFileUsageSetup);
			fileStorageSetupIntent.PutExtra(FileStorageSetupDefs.ExtraAlwaysReturnSuccess, alwaysReturnSuccess);
			PasswordActivity.PutIoConnectionToIntent(ioc, fileStorageSetupIntent);

			_activity.StartActivityForResult(fileStorageSetupIntent, requestCode);
		}
开发者ID:pythe,项目名称:wristpass,代码行数:9,代码来源:FileStorageSetupInitiatorActivity.cs

示例12: StartSelectFileProcess

		public void StartSelectFileProcess(IOConnectionInfo ioc, bool isForSave, int requestCode)
		{
			Kp2aLog.Log("FSSIA: StartSelectFileProcess "+ioc.Path);
			Intent fileStorageSetupIntent = new Intent(_activity, typeof(FileStorageSetupActivity));
			fileStorageSetupIntent.PutExtra(FileStorageSetupDefs.ExtraProcessName, FileStorageSetupDefs.ProcessNameSelectfile);
			fileStorageSetupIntent.PutExtra(FileStorageSetupDefs.ExtraIsForSave, isForSave);
			PasswordActivity.PutIoConnectionToIntent(ioc, fileStorageSetupIntent);

			_activity.StartActivityForResult(fileStorageSetupIntent, requestCode);
		}
开发者ID:pythe,项目名称:wristpass,代码行数:10,代码来源:FileStorageSetupInitiatorActivity.cs

示例13: CheckShutdown

 public static bool CheckShutdown(Activity act, IOConnectionInfo ioc)
 {
     if ((  !App.Kp2a.DatabaseIsUnlocked )
         || (IocChanged(ioc, App.Kp2a.GetDb().Ioc))) //file was changed from ActionSend-Intent
     {
         App.Kp2a.LockDatabase();
         return true;
     }
     return false;
 }
开发者ID:pythe,项目名称:wristpass,代码行数:10,代码来源:TimeoutHelper.cs

示例14: 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;
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:55,代码来源:FileTransactionEx.cs

示例15: LoadDb

        public LoadDb(IKp2aApp app, IOConnectionInfo ioc, Task<MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish)
            : base(finish)
        {
            _app = app;
            _ioc = ioc;
            _databaseData = databaseData;
            _compositeKey = compositeKey;
            _keyfileOrProvider = keyfileOrProvider;

            _rememberKeyfile = app.GetBooleanPreference(PreferenceKey.remember_keyfile);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:11,代码来源:LoadDB.cs


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