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


C# IStatusLogger.SetText方法代码示例

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


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

示例1: Import

		public void Import(List<BaseRecord> baseRecords, PwDatabase storage, IStatusLogger status)
		{
			var records = new List<BaseRecord>();
			var trashedRecords = new List<BaseRecord>();

			baseRecords.ForEach(record =>
			{
				if (record.trashed)
					trashedRecords.Add(record);
				else
					records.Add(record);
			});


			var tree = BuildTree(records);

			status.SetText("Importing records..", LogStatusType.Info);
			
			PwGroup root = new PwGroup(true, true);
			root.Name = "1Password Import on " + DateTime.Now.ToString();


			foreach (var node in tree)
			{
				ImportRecord(node, root, storage);
			}

			if (trashedRecords.Count > 0)
			{
				PwGroup trash = new PwGroup(true, true) { Name = "Trash", IconId = PwIcon.TrashBin };

				foreach (var trecord in trashedRecords)
				{
					var wfrecord = trecord as WebFormRecord;
					if (wfrecord != null)
						CreateWebForm(trash, storage, wfrecord);
				}
				root.AddGroup(trash, true);
			}

			storage.RootGroup.AddGroup(root, true);
		}
开发者ID:diimdeep,项目名称:1P2KeePass,代码行数:42,代码来源:PIFImporter.cs

示例2: Import

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

            var root = document.DocumentElement;
            var products = root.SelectNodes("Product_Key");

            if (products == null || products.Count == 0)
                return;

            var msdnGroup = pwStorage.RootGroup.FindCreateGroup("Microsoft Product Keys", true);

            for (int i = 0; i < products.Count; i++ )
            {
                var product = new Product(products[i]);
                slLogger.SetText(string.Format("{0} ({1} of {2})", product.Name, i + 1, products.Count), LogStatusType.Info);
                AddProduct(pwStorage, msdnGroup, product);
            }
        }
开发者ID:jeff2001,项目名称:MicrosoftKeyImporterPlugin,代码行数:20,代码来源:MicrosoftKeysExportFileFormatProvider.cs

示例3: Import

		public override void Import(PwDatabase pwStorage, Stream sInput,
			IStatusLogger slLogger)
		{
			slLogger.SetText("> Spamex.com...", LogStatusType.Info);

			SingleLineEditForm dlgUser = new SingleLineEditForm();
			dlgUser.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.UserName,
				KPRes.UserNamePrompt, KeePass.Properties.Resources.B48x48_WWW,
				string.Empty, null);
			if(dlgUser.ShowDialog() != DialogResult.OK) return;

			SingleLineEditForm dlgPassword = new SingleLineEditForm();
			dlgPassword.InitEx("Spamex.com", KPRes.WebSiteLogin + " - " + KPRes.Password,
				KPRes.PasswordPrompt, KeePass.Properties.Resources.B48x48_WWW,
				string.Empty, null);
			if(dlgPassword.ShowDialog() != DialogResult.OK) return;

			RemoteCertificateValidationCallback pPrevCertCb =
				ServicePointManager.ServerCertificateValidationCallback;

			ServicePointManager.ServerCertificateValidationCallback =
				delegate(object sender, X509Certificate certificate, X509Chain chain,
					SslPolicyErrors sslPolicyErrors)
				{
					return true;
				};

			try
			{
				slLogger.SetText(KPRes.ImportingStatusMsg, LogStatusType.Info);

				string strUser = dlgUser.ResultString; ;
				string strPassword = dlgPassword.ResultString;

				string strPostData = @"toollogin=&MetaDomain=&LoginEmail=" +
					strUser + @"&LoginPassword=" + strPassword + @"&Remember=1";

				List<KeyValuePair<string, string>> vCookies;
				string strMain = NetUtil.WebPageLogin(new Uri(UrlLoginPage),
					strPostData, out vCookies);

				if(strMain.IndexOf("Welcome <b>" + strUser + "</b>") < 0)
				{
					MessageService.ShowWarning(KPRes.InvalidUserPassword);
					return;
				}

				string strIndexPage = NetUtil.WebPageGetWithCookies(new Uri(UrlIndexPage),
					vCookies, UrlDomain);

				ImportIndex(pwStorage, strIndexPage, vCookies, slLogger);

				int nOffset = 0;
				List<string> vSubPages = new List<string>();
				while(true)
				{
					string strLink = StrUtil.GetStringBetween(strIndexPage, nOffset,
						StrTabLinksStart, StrTabLinksEnd, out nOffset);
					++nOffset;

					if(strLink.Length == 0) break;

					if(!strLink.StartsWith(StrTabLinkUrl)) continue;
					if(vSubPages.IndexOf(strLink) >= 0) continue;

					vSubPages.Add(strLink);

					string strSubPage = NetUtil.WebPageGetWithCookies(new Uri(
						UrlBase + strLink), vCookies, UrlDomain);

					ImportIndex(pwStorage, strSubPage, vCookies, slLogger);
				}
			}
			catch
			{
				ServicePointManager.ServerCertificateValidationCallback = pPrevCertCb;
				throw;
			}

			ServicePointManager.ServerCertificateValidationCallback = pPrevCertCb;
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:81,代码来源:Spamex20070328.cs

示例4: ImportAccount

		private static void ImportAccount(PwDatabase pwStorage, string strID,
			List<KeyValuePair<string, string>> vCookies, IStatusLogger slf)
		{
			string strPage = NetUtil.WebPageGetWithCookies(new Uri(
				UrlAccountPage + strID), vCookies, UrlDomain);

			PwEntry pe = new PwEntry(true, true);
			pwStorage.RootGroup.AddEntry(pe, true);

			string str;

			string strTitle = StrUtil.GetStringBetween(strPage, 0, "Subject : <b>", "</b>");
			if(strTitle.StartsWith("<b>")) strTitle = strTitle.Substring(3, strTitle.Length - 3);
			pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectTitle, strTitle));

			string strUser = StrUtil.GetStringBetween(strPage, 0, "Site Username : <b>", "</b>");
			if(strUser.StartsWith("<b>")) strUser = strUser.Substring(3, strUser.Length - 3);
			pe.Strings.Set(PwDefs.UserNameField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectUserName, strUser));

			str = StrUtil.GetStringBetween(strPage, 0, "Site Password : <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set(PwDefs.PasswordField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectPassword, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Site URL : <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set(PwDefs.UrlField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectUrl, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Notes : <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
				pwStorage.MemoryProtection.ProtectNotes, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Address:&nbsp;</td><td><font class=\"midHD\">", "</font></td>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Address", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Forwards to: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Forward To", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Reply-To Messages: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Reply-To Messages", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Allow Reply From: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Allow Reply From", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Filter Mode: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Filter Mode", new ProtectedString(false, str));

			str = StrUtil.GetStringBetween(strPage, 0, "Created: <b>", "</b>");
			if(str.StartsWith("<b>")) str = str.Substring(3, str.Length - 3);
			pe.Strings.Set("Created", new ProtectedString(false, str));

			slf.SetText(strTitle + " - " + strUser + " (" + strID + ")",
				LogStatusType.Info);

			if(!slf.ContinueWork())
				throw new InvalidOperationException(string.Empty);
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:66,代码来源:Spamex20070328.cs

示例5: Import

		public override void Import(PwDatabase storage, Stream input, IStatusLogger status)
		{
			status.SetText("Parsing .pif ...", LogStatusType.Info);
			List<BaseRecord> baseRecords = _pifParser.Parse(input);
			_pifImporter.Import(baseRecords, storage, status);
		}
开发者ID:diimdeep,项目名称:1P2KeePass,代码行数:6,代码来源:_1PasswordPifFormatProvider.cs

示例6: Export

        public override bool Export(PwExportInfo pwExportInfo, Stream sOutput,
            IStatusLogger slLogger)
        {
            PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase());

            string strTempFile = Program.TempFilesPool.GetTempFileName(false);

            try
            {
                Kdb3File kdb = new Kdb3File(pd, slLogger);
                kdb.Save(strTempFile, pwExportInfo.DataGroup);

                byte[] pbKdb = File.ReadAllBytes(strTempFile);
                sOutput.Write(pbKdb, 0, pbKdb.Length);
                Array.Clear(pbKdb, 0, pbKdb.Length);
            }
            catch(Exception exKdb)
            {
                if(slLogger != null) slLogger.SetText(exKdb.Message, LogStatusType.Error);

                return false;
            }

            Program.TempFilesPool.Delete(strTempFile);
            return true;
        }
开发者ID:miracle2k,项目名称:keepass2,代码行数:26,代码来源:KeePassKdb1x.cs

示例7: ReadFile

		private static string ReadFile(BinaryReader br, PlgxPluginInfo plgx,
			IStatusLogger slStatus)
		{
			uint uSig1 = br.ReadUInt32();
			uint uSig2 = br.ReadUInt32();
			uint uVersion = br.ReadUInt32();

			if((uSig1 != PlgxSignature1) || (uSig2 != PlgxSignature2))
				return null; // Ignore file, don't throw
			if((uVersion & PlgxVersionMask) > (PlgxVersion & PlgxVersionMask))
				throw new PlgxException(KLRes.FileVersionUnsupported);

			string strPluginPath = null;
			string strTmpRoot = null;
			bool? bContent = null;
			string strBuildPre = null, strBuildPost = null;

			while(true)
			{
				KeyValuePair<ushort, byte[]> kvp = ReadObject(br);

				if(kvp.Key == PlgxEOF) break;
				else if(kvp.Key == PlgxFileUuid)
					plgx.FileUuid = new PwUuid(kvp.Value);
				else if(kvp.Key == PlgxBaseFileName)
					plgx.BaseFileName = StrUtil.Utf8.GetString(kvp.Value);
				else if(kvp.Key == PlgxCreationTime) { } // Ignore
				else if(kvp.Key == PlgxGeneratorName) { }
				else if(kvp.Key == PlgxGeneratorVersion) { }
				else if(kvp.Key == PlgxPrereqKP)
				{
					ulong uReq = MemUtil.BytesToUInt64(kvp.Value);
					if(uReq > PwDefs.FileVersion64)
						throw new PlgxException(KLRes.FileNewVerReq);
				}
				else if(kvp.Key == PlgxPrereqNet)
				{
					ulong uReq = MemUtil.BytesToUInt64(kvp.Value);
					ulong uInst = WinUtil.GetMaxNetFrameworkVersion();
					if((uInst != 0) && (uReq > uInst))
						throw new PlgxException(KPRes.NewerNetRequired);
				}
				else if(kvp.Key == PlgxPrereqOS)
				{
					string strOS = "," + WinUtil.GetOSStr() + ",";
					string strReq = "," + StrUtil.Utf8.GetString(kvp.Value) + ",";
					if(strReq.IndexOf(strOS, StrUtil.CaseIgnoreCmp) < 0)
						throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
				}
				else if(kvp.Key == PlgxPrereqPtr)
				{
					uint uReq = MemUtil.BytesToUInt32(kvp.Value);
					if(uReq > (uint)IntPtr.Size)
						throw new PlgxException(KPRes.PluginOperatingSystemUnsupported);
				}
				else if(kvp.Key == PlgxBuildPre)
					strBuildPre = StrUtil.Utf8.GetString(kvp.Value);
				else if(kvp.Key == PlgxBuildPost)
					strBuildPost = StrUtil.Utf8.GetString(kvp.Value);
				else if(kvp.Key == PlgxBeginContent)
				{
					if(bContent.HasValue)
						throw new PlgxException(KLRes.FileCorrupted);

					string strCached = PlgxCache.GetCacheFile(plgx, true, false);
					if(!string.IsNullOrEmpty(strCached) && plgx.AllowCached)
					{
						strPluginPath = strCached;
						break;
					}

					if(slStatus != null)
						slStatus.SetText(KPRes.PluginsCompilingAndLoading,
							LogStatusType.Info);

					bContent = true;
					if(plgx.LogStream != null) plgx.LogStream.WriteLine("Content:");
				}
				else if(kvp.Key == PlgxFile)
				{
					if(!bContent.HasValue || !bContent.Value)
						throw new PlgxException(KLRes.FileCorrupted);

					if(strTmpRoot == null) strTmpRoot = CreateTempDirectory();
					ExtractFile(kvp.Value, strTmpRoot, plgx);
				}
				else if(kvp.Key == PlgxEndContent)
				{
					if(!bContent.HasValue || !bContent.Value)
						throw new PlgxException(KLRes.FileCorrupted);

					bContent = false;
				}
				else { Debug.Assert(false); }
			}

			if((strPluginPath == null) && plgx.AllowCompile)
				strPluginPath = Compile(strTmpRoot, plgx, strBuildPre, strBuildPost);

			return strPluginPath;
//.........这里部分代码省略.........
开发者ID:riking,项目名称:go-keepass2,代码行数:101,代码来源:PlgxPlugin.cs

示例8: Load

        /// <summary>
        /// Load a KDB file from a stream.
        /// </summary>
        /// <param name="sSource">Stream to read the data from. Must contain
        /// a KDBX stream.</param>
        /// <param name="kdbFormat">Format specifier.</param>
        /// <param name="slLogger">Status logger (optional).</param>
        public void Load(Stream sSource, KdbxFormat kdbFormat, IStatusLogger slLogger)
        {
            Debug.Assert(sSource != null);
            if(sSource == null) throw new ArgumentNullException("sSource");

            m_format = kdbFormat;
            m_slLogger = slLogger;

            HashingStreamEx hashedStream = new HashingStreamEx(sSource, false, null);

            UTF8Encoding encNoBom = StrUtil.Utf8;
            try
            {
                BinaryReaderEx br = null;
                BinaryReaderEx brDecrypted = null;
                Stream readerStream = null;

                if(kdbFormat == KdbxFormat.Default || kdbFormat == KdbxFormat.ProtocolBuffers)
                {
                    br = new BinaryReaderEx(hashedStream, encNoBom, KLRes.FileCorrupted);
                    ReadHeader(br);

                    Stream sDecrypted = AttachStreamDecryptor(hashedStream);
                    if((sDecrypted == null) || (sDecrypted == hashedStream))
                        throw new SecurityException(KLRes.CryptoStreamFailed);

                    if (m_slLogger != null)
                        m_slLogger.SetText("KP2AKEY_TransformingKey", LogStatusType.AdditionalInfo);

                    brDecrypted = new BinaryReaderEx(sDecrypted, encNoBom, KLRes.FileCorrupted);
                    byte[] pbStoredStartBytes = brDecrypted.ReadBytes(32);

                    if((m_pbStreamStartBytes == null) || (m_pbStreamStartBytes.Length != 32))
                        throw new InvalidDataException();

                    if (m_slLogger != null)
                        m_slLogger.SetText("KP2AKEY_DecodingDatabase", LogStatusType.AdditionalInfo);

                    for(int iStart = 0; iStart < 32; ++iStart)
                    {
                        if(pbStoredStartBytes[iStart] != m_pbStreamStartBytes[iStart])
                            throw new InvalidCompositeKeyException();
                    }

                    Stream sHashed = new HashedBlockStream(sDecrypted, false, 0,
                        !m_bRepairMode);

                    if(m_pwDatabase.Compression == PwCompressionAlgorithm.GZip)
                        readerStream = new Ionic.Zlib.GZipStream(sHashed, Ionic.Zlib.CompressionMode.Decompress);
                    else readerStream = sHashed;
                }
                else if(kdbFormat == KdbxFormat.PlainXml)
                    readerStream = hashedStream;
                else { Debug.Assert(false); throw new FormatException("KdbFormat"); }

                if(kdbFormat != KdbxFormat.PlainXml) // Is an encrypted format
                {
                    if(m_pbProtectedStreamKey == null)
                    {
                        Debug.Assert(false);
                        throw new SecurityException("Invalid protected stream key!");
                    }

                    m_randomStream = new CryptoRandomStream(m_craInnerRandomStream,
                        m_pbProtectedStreamKey);
                }
                else m_randomStream = null; // No random stream for plain-text files
                if (m_slLogger != null)
                    m_slLogger.SetText("KP2AKEY_ParsingDatabase", LogStatusType.AdditionalInfo);
                var stopWatch = Stopwatch.StartNew();

                if (kdbFormat == KdbxFormat.ProtocolBuffers)
                {
                    KdbpFile.ReadDocument(m_pwDatabase, readerStream, m_pbProtectedStreamKey, m_pbHashOfHeader);

                    Kp2aLog.Log(String.Format("KdbpFile.ReadDocument: {0}ms", stopWatch.ElapsedMilliseconds));

                }
                else
                {
                    ReadXmlStreamed(readerStream, hashedStream);

                    Kp2aLog.Log(String.Format("ReadXmlStreamed: {0}ms", stopWatch.ElapsedMilliseconds));
                }

                readerStream.Close();
                // GC.KeepAlive(br);
                // GC.KeepAlive(brDecrypted);
            }
            catch(CryptographicException) // Thrown on invalid padding
            {
                throw new CryptographicException(KLRes.FileCorrupted);
            }
//.........这里部分代码省略.........
开发者ID:pythe,项目名称:wristpass,代码行数:101,代码来源:KdbxFile.Read.cs


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