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


C# IStatusLogger类代码示例

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


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

示例1: Export

		public static bool Export(PwExportInfo pwExportInfo, IStatusLogger slLogger)
		{
			if(pwExportInfo == null) throw new ArgumentNullException("pwExportInfo");
			if(pwExportInfo.DataGroup == null) throw new ArgumentException();

			if(!AppPolicy.Try(AppPolicyId.Export)) return false;

			ExchangeDataForm dlg = new ExchangeDataForm();
			dlg.InitEx(true, pwExportInfo.ContextDatabase, pwExportInfo.DataGroup);

			if(dlg.ShowDialog() == DialogResult.OK)
			{
				FileFormatProvider ffp = dlg.ResultFormat;
				if(ffp == null) { Debug.Assert(false); return false; }
				if(ffp.RequiresFile)
				{
					if(dlg.ResultFiles.Length != 1) { Debug.Assert(false); return false; }
					if(dlg.ResultFiles[0] == null) { Debug.Assert(false); return false; }
					if(dlg.ResultFiles[0].Length == 0) { Debug.Assert(false); return false; }
				}

				Application.DoEvents(); // Redraw parent window

				IOConnectionInfo iocOutput = (ffp.RequiresFile ? IOConnectionInfo.FromPath(
					dlg.ResultFiles[0]) : null);

				try
				{
					return Export(pwExportInfo, dlg.ResultFormat, iocOutput, slLogger);
				}
				catch(Exception ex) { MessageService.ShowWarning(ex); }
			}

			return false;
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:35,代码来源:ExportUtil.cs

示例2: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			StreamReader sr = new StreamReader(sInput, StrUtil.Utf8);
			string strDoc = sr.ReadToEnd();
			sr.Close();

			XmlDocument doc = new XmlDocument();
			doc.LoadXml(strDoc);

			XmlElement xmlRoot = doc.DocumentElement;
			Debug.Assert(xmlRoot.Name == ElemRoot);

			PwGroup pgRoot = pwStorage.RootGroup;

			foreach(XmlNode xmlChild in xmlRoot.ChildNodes)
			{
				if(xmlChild.Name == ElemGroup)
					ImportGroup(xmlChild, pgRoot, pwStorage, false);
				else if(xmlChild.Name == ElemRecycleBin)
					ImportGroup(xmlChild, pgRoot, pwStorage, true);
				else if(xmlChild.Name == ElemEntry)
					ImportEntry(xmlChild, pgRoot, pwStorage);
				else { Debug.Assert(false); }
			}
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:26,代码来源:PwSaverXml412.cs

示例3: Export

        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
            IStatusLogger slLogger)
        {
            PwGroup pg = pwExportInfo.DataGroup;
            if(pg == null) { Debug.Assert(false); return true; }

            string strBaseName = FilterFileName(string.IsNullOrEmpty(
                Program.Config.Defaults.WinFavsBaseFolderName) ? PwDefs.ShortProductName :
                Program.Config.Defaults.WinFavsBaseFolderName);

            string strRootName = strBaseName + " - " + FilterFileName(pg.Name);
            if(pwExportInfo.ContextDatabase != null)
            {
                if(pg == pwExportInfo.ContextDatabase.RootGroup)
                    strRootName = strBaseName;
            }

            string strFavsRoot = Environment.GetFolderPath(
                Environment.SpecialFolder.Favorites);
            if(string.IsNullOrEmpty(strFavsRoot)) return false;

            string strFavsSub = UrlUtil.EnsureTerminatingSeparator(strFavsRoot,
                false) + strRootName;
            if(Directory.Exists(strFavsSub))
            {
                Directory.Delete(strFavsSub, true);
                WaitForDirCommit(strFavsSub, false);
            }

            ExportGroup(pwExportInfo.DataGroup, strFavsSub);
            return true;
        }
开发者ID:elitak,项目名称:keepass,代码行数:32,代码来源:WinFavorites10.cs

示例4: Export

        public static void Export(PwExportInfo pwExportInfo, IStatusLogger slLogger)
        {
            if(pwExportInfo == null) throw new ArgumentNullException("pwExportInfo");
            if(pwExportInfo.DataGroup == null) throw new ArgumentException();

            if(!AppPolicy.Try(AppPolicyId.Export)) return;

            ExchangeDataForm dlg = new ExchangeDataForm();
            dlg.InitEx(true, pwExportInfo.ContextDatabase, pwExportInfo.DataGroup);

            if(dlg.ShowDialog() == DialogResult.OK)
            {
                if(dlg.ResultFormat == null) { Debug.Assert(false); return; }
                if(dlg.ResultFiles.Length != 1) { Debug.Assert(false); return; }
                if(dlg.ResultFiles[0] == null) { Debug.Assert(false); return; }
                if(dlg.ResultFiles[0].Length == 0) { Debug.Assert(false); return; }

                Application.DoEvents(); // Redraw parent window

                try
                {
                    PerformExport(pwExportInfo, dlg.ResultFormat, dlg.ResultFiles[0],
                        slLogger);
                }
                catch(Exception ex)
                {
                    MessageService.ShowWarning(ex);
                }
            }
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:30,代码来源:ExportUtil.cs

示例5: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			XmlDocument xmlDoc = new XmlDocument();
			xmlDoc.Load(sInput);

			XmlNode xmlRoot = xmlDoc.DocumentElement;
			Debug.Assert(xmlRoot.Name == ElemRoot);

			Stack<PwGroup> vGroups = new Stack<PwGroup>();
			vGroups.Push(pwStorage.RootGroup);

			int nNodeCount = xmlRoot.ChildNodes.Count;
			for(int i = 0; i < nNodeCount; ++i)
			{
				XmlNode xmlChild = xmlRoot.ChildNodes[i];

				if(xmlChild.Name == ElemGroup)
					ReadGroup(xmlChild, vGroups, pwStorage);
				else { Debug.Assert(false); }

				if(slLogger != null)
					slLogger.SetProgress((uint)(((i + 1) * 100) / nNodeCount));
			}
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:25,代码来源:KeePassXXml041.cs

示例6: Export

		public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
			IStatusLogger slLogger)
		{
			Kdb4File kdb4 = new Kdb4File(pwExportInfo.ContextDatabase);
			kdb4.Save(sOutput, pwExportInfo.DataGroup, Kdb4Format.Default, slLogger);
			return true;
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:7,代码来源:KeePassKdb2x.cs

示例7: KdbFile

		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="pwDataStore">The <c>PwDatabase</c> instance that the class
		/// will load file data into or use to create a KDB file. Must not be <c>null</c>.</param>
		/// <exception cref="System.ArgumentNullException">Thrown if the database
		/// reference is <c>null</c>.</exception>
		public KdbFile(PwDatabase pwDataStore, IStatusLogger slLogger)
		{
			Debug.Assert(pwDataStore != null);
			if(pwDataStore == null) throw new ArgumentNullException("pwDataStore");
			m_pwDatabase = pwDataStore;

			m_slLogger = slLogger;
		}
开发者ID:kusuriya,项目名称:PasswordKeeper,代码行数:15,代码来源:KdbFile.cs

示例8: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			XmlSerializer xs = new XmlSerializer(typeof(HspFolder));
			HspFolder hspRoot = (HspFolder)xs.Deserialize(sInput);

			AddFolder(pwStorage.RootGroup, hspRoot, false);
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:8,代码来源:HandySafeProXml12.cs

示例9: Save

		// public void Save(string strFile, PwGroup pgDataSource, KdbxFormat format,
		//	IStatusLogger slLogger)
		// {
		//	bool bMadeUnhidden = UrlUtil.UnhideFile(strFile);
		//
		//	IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile);
		//	this.Save(IOConnection.OpenWrite(ioc), pgDataSource, format, slLogger);
		//
		//	if(bMadeUnhidden) UrlUtil.HideFile(strFile, true); // Hide again
		// }

		/// <summary>
		/// Save the contents of the current <c>PwDatabase</c> to a KDBX file.
		/// </summary>
		/// <param name="sSaveTo">Stream to write the KDBX file into.</param>
		/// <param name="pgDataSource">Group containing all groups and
		/// entries to write. If <c>null</c>, the complete database will
		/// be written.</param>
		/// <param name="format">Format of the file to create.</param>
		/// <param name="slLogger">Logger that recieves status information.</param>
		public void Save(Stream sSaveTo, PwGroup pgDataSource, KdbxFormat format,
			IStatusLogger slLogger)
		{
			Debug.Assert(sSaveTo != null);
			if(sSaveTo == null) throw new ArgumentNullException("sSaveTo");

			m_format = format;
			m_slLogger = slLogger;

			HashingStreamEx hashedStream = new HashingStreamEx(sSaveTo, true, null);

			UTF8Encoding encNoBom = StrUtil.Utf8;
			CryptoRandom cr = CryptoRandom.Instance;

			try
			{
				m_pbMasterSeed = cr.GetRandomBytes(32);
				m_pbTransformSeed = cr.GetRandomBytes(32);
				m_pbEncryptionIV = cr.GetRandomBytes(16);

				m_pbProtectedStreamKey = cr.GetRandomBytes(32);
				m_craInnerRandomStream = CrsAlgorithm.Salsa20;
				m_randomStream = new CryptoRandomStream(m_craInnerRandomStream,
					m_pbProtectedStreamKey);

				m_pbStreamStartBytes = cr.GetRandomBytes(32);

				Stream writerStream;
				if(m_format == KdbxFormat.Default)
				{
					WriteHeader(hashedStream); // Also flushes the stream

					Stream sEncrypted = AttachStreamEncryptor(hashedStream);
					if((sEncrypted == null) || (sEncrypted == hashedStream))
						throw new SecurityException(KLRes.CryptoStreamFailed);

					sEncrypted.Write(m_pbStreamStartBytes, 0, m_pbStreamStartBytes.Length);

					Stream sHashed = new HashedBlockStream(sEncrypted, true);

					if(m_pwDatabase.Compression == PwCompressionAlgorithm.GZip)
						writerStream = new GZipStream(sHashed, CompressionMode.Compress);
					else
						writerStream = sHashed;
				}
				else if(m_format == KdbxFormat.PlainXml)
					writerStream = hashedStream;
				else { Debug.Assert(false); throw new FormatException("KdbFormat"); }

				m_xmlWriter = new XmlTextWriter(writerStream, encNoBom);
				WriteDocument(pgDataSource);

				m_xmlWriter.Flush();
				m_xmlWriter.Close();
				writerStream.Close();
			}
			finally { CommonCleanUpWrite(sSaveTo, hashedStream); }
		}
开发者ID:kusuriya,项目名称:PasswordKeeper,代码行数:78,代码来源:KdbxFile.Write.cs

示例10: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			StreamReader sr = new StreamReader(sInput, Encoding.Default);
			string strDoc = sr.ReadToEnd();
			sr.Close();

			ImportFileString(strDoc, pwStorage);
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:9,代码来源:FlexWalletXml17.cs

示例11: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			XPathDocument xpDoc = new XPathDocument(sInput);
			XPathNavigator xpNav = xpDoc.CreateNavigator();

			ImportLogins(xpNav, pwStorage);
			ImportMemos(xpNav, pwStorage);
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:9,代码来源:StickyPwXml50.cs

示例12: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			StreamReader sr = new StreamReader(sInput, Encoding.Default);
			string strDoc = sr.ReadToEnd();
			sr.Close();

			int nIndex = strDoc.IndexOf('<');
			while(nIndex >= 0)
			{
				int nAttrib = strDoc.LastIndexOf("=\"", nIndex);
				int nElem = strDoc.LastIndexOf('>', nIndex);
				
				if(nAttrib > nElem)
				{
					strDoc = strDoc.Remove(nIndex, 1);
					strDoc = strDoc.Insert(nIndex, @"&lt;");
				}
				nIndex = strDoc.IndexOf('<', nIndex + 1);
			}

			nIndex = strDoc.IndexOf('>');
			while(nIndex >= 0)
			{
				if(nIndex <= 3)
					throw new FormatException("Invalid header!");

				char chPrev = strDoc[nIndex - 1];
				string strPrev4 = strDoc.Substring(nIndex - 3, 4);

				if((chPrev != '/') && (chPrev != '\"') && (strPrev4 != @"xml>") &&
					(strPrev4 != @"ies>"))
				{
					strDoc = strDoc.Remove(nIndex, 1);
					strDoc = strDoc.Insert(nIndex, @"&gt;");
				}
				nIndex = strDoc.IndexOf('>', nIndex + 1);
			}

			MemoryStream msXml = new MemoryStream(Encoding.UTF8.GetBytes(strDoc), false);

			XmlDocument xmlDoc = new XmlDocument();
			xmlDoc.Load(msXml);
			msXml.Close();

			XmlNode xmlRoot = xmlDoc.DocumentElement;
			if(xmlRoot.Name != ElemRoot)
				throw new FormatException("Invalid root element!");

			foreach(XmlNode xmlChild in xmlRoot.ChildNodes)
			{
				if(xmlChild.Name == ElemEntries)
					ImportEntries(xmlChild, pwStorage);
				else { Debug.Assert(false); }
			}
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:56,代码来源:PwExporterXml105.cs

示例13: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			BinaryReader br = new BinaryReader(sInput);
			byte[] pbData = br.ReadBytes((int)sInput.Length);
			br.Close();

			ImportCsvForm csv = new ImportCsvForm();
			csv.InitEx(pwStorage, pbData);
			csv.ShowDialog();
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:11,代码来源:GenericCsv.cs

示例14: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			KdbxFile kdbx = new KdbxFile(pwStorage);
			// CappedByteStream s = new CappedByteStream(sInput, 64);

			kdbx.RepairMode = true;

			try { kdbx.Load(sInput, KdbxFormat.Default, slLogger); }
			catch(Exception) { }
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:11,代码来源:KeePassKdb2xRepair.cs

示例15: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			StreamReader sr = new StreamReader(sInput, Encoding.Default);
			string strData = sr.ReadToEnd();
			sr.Close();

			strData = strData.Replace("\r", string.Empty);
			string[] vLines = strData.Split(new char[] { '\n' });

			PwGroup pg = pwStorage.RootGroup;
			Dictionary<string, string> dItems = new Dictionary<string, string>();
			bool bInNotes = false;

			foreach(string strLine in vLines)
			{
				if(strLine.StartsWith(StrGroupStart) && strLine.EndsWith(StrGroupEnd))
				{
					AddEntry(pg, dItems, ref bInNotes);
					dItems.Clear();

					pg = new PwGroup(true, true);
					pg.Name = strLine.Substring(StrGroupStart.Length, strLine.Length -
						StrGroupStart.Length - StrGroupEnd.Length);

					pwStorage.RootGroup.AddGroup(pg, true);
				}
				else if(strLine.StartsWith(StrEntryStart) && strLine.EndsWith(StrEntryEnd))
				{
					AddEntry(pg, dItems, ref bInNotes);
					dItems.Clear();
				}
				else if(strLine == StrNotesBegin) bInNotes = true;
				else if(bInNotes)
				{
					if(dItems.ContainsKey(PwDefs.NotesField))
						dItems[PwDefs.NotesField] += MessageService.NewLine + strLine;
					else dItems[PwDefs.NotesField] = strLine;
				}
				else
				{
					int nSplitPos = strLine.IndexOf(StrFieldSplit);
					if(nSplitPos < 0) { Debug.Assert(false); }
					else
					{
						AddField(dItems, strLine.Substring(0, nSplitPos),
							strLine.Substring(nSplitPos + StrFieldSplit.Length));
					}
				}
			}

			AddEntry(pg, dItems, ref bInNotes);
		}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:53,代码来源:HandySafeTxt512.cs


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