• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Spr.SprContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ReplacePickPw

		// Legacy, for backward compatibility only; see PickChars
		private static string ReplacePickPw(string strText, SprContext ctx,
			uint uRecursionLevel)
		{
			if(ctx.Entry == null) { Debug.Assert(false); return strText; }

			string str = strText;

			while(true)
			{
				const string strStart = @"{PICKPASSWORDCHARS";

				int iStart = str.IndexOf(strStart, StrUtil.CaseIgnoreCmp);
				if(iStart < 0) break;

				int iEnd = str.IndexOf('}', iStart);
				if(iEnd < 0) break;

				string strPlaceholder = str.Substring(iStart, iEnd - iStart + 1);

				string strParam = str.Substring(iStart + strStart.Length,
					iEnd - (iStart + strStart.Length));
				string[] vParams = strParam.Split(new char[] { ':' });

				uint uCharCount = 0;
				if(vParams.Length >= 2) uint.TryParse(vParams[1], out uCharCount);

				str = ReplacePickPwPlaceholder(str, strPlaceholder, uCharCount,
					ctx, uRecursionLevel);
			}

			return str;
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:33,代码来源:SprEngine.PickChars.cs


示例2: ReplacePickPwPlaceholder

		private static string ReplacePickPwPlaceholder(string str,
			string strPlaceholder, uint uCharCount, SprContext ctx,
			uint uRecursionLevel)
		{
			if(str.IndexOf(strPlaceholder, StrUtil.CaseIgnoreCmp) < 0) return str;

			ProtectedString ps = ctx.Entry.Strings.Get(PwDefs.PasswordField);
			if(ps != null)
			{
				string strPassword = ps.ReadString();

				string strPick = SprEngine.CompileInternal(strPassword,
					ctx.WithoutContentTransformations(), uRecursionLevel + 1);

				if(!string.IsNullOrEmpty(strPick))
				{
					ProtectedString psPick = new ProtectedString(false, strPick);
					string strPicked = (CharPickerForm.ShowAndRestore(psPick,
						true, true, uCharCount, null) ?? string.Empty);

					str = StrUtil.ReplaceCaseInsensitive(str, strPlaceholder,
						SprEngine.TransformContent(strPicked, ctx));
				}
			}

			return StrUtil.ReplaceCaseInsensitive(str, strPlaceholder, string.Empty);
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:27,代码来源:SprEngine.PickChars.cs


示例3: Compile

		public static string Compile(string strText, bool bIsAutoTypeSequence,
			PwEntry pwEntry, PwDatabase pwDatabase, bool bEscapeForAutoType,
			bool bEscapeQuotesForCommandLine)
		{
			SprContext ctx = new SprContext(pwEntry, pwDatabase, SprCompileFlags.All,
				bEscapeForAutoType, bEscapeQuotesForCommandLine);
			return Compile(strText, ctx);
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:8,代码来源:SprEngine.cs


示例4: Compile

        public static string Compile(string strText, SprContext ctx)
        {
            if(strText == null) { Debug.Assert(false); return string.Empty; }
            if(strText.Length == 0) return string.Empty;

            SprEngine.InitializeStatic();

            if(ctx == null) ctx = new SprContext();
            ctx.RefsCache.Clear();

            string str = SprEngine.CompileInternal(strText, ctx, 0);

            // if(bEscapeForAutoType && !bIsAutoTypeSequence)
            //	str = SprEncoding.MakeAutoTypeSequence(str);

            return str;
        }
开发者ID:amiryal,项目名称:keepass2,代码行数:17,代码来源:SprEngine.cs


示例5: FillEntryStrings

		private static string FillEntryStrings(string str, SprContext ctx,
			uint uRecursionLevel)
		{
			List<string> vKeys = ctx.Entry.Strings.GetKeys();

			// Ensure that all standard field names are in the list
			// (this is required in order to replace the standard placeholders
			// even if the corresponding standard field isn't present in
			// the entry)
			List<string> vStdNames = PwDefs.GetStandardFields();
			foreach(string strStdField in vStdNames)
			{
				if(!vKeys.Contains(strStdField)) vKeys.Add(strStdField);
			}

			// Do not directly enumerate the strings in ctx.Entry.Strings,
			// because strings might change during the Spr compilation
			foreach(string strField in vKeys)
			{
				string strKey = (PwDefs.IsStandardField(strField) ?
					(@"{" + strField + @"}") :
					(@"{" + PwDefs.AutoTypeStringPrefix + strField + @"}"));

				if(!ctx.ForcePlainTextPasswords && strKey.Equals(@"{" +
					PwDefs.PasswordField + @"}", StrUtil.CaseIgnoreCmp) &&
					Program.Config.MainWindow.IsColumnHidden(AceColumnType.Password))
				{
					str = SprEngine.FillIfExists(str, strKey, new ProtectedString(
						false, PwDefs.HiddenPassword), ctx, uRecursionLevel);
					continue;
				}

				// Use GetSafe because the field doesn't necessarily exist
				// (might be a standard field that has been added above)
				str = SprEngine.FillIfExists(str, strKey, ctx.Entry.Strings.GetSafe(
					strField), ctx, uRecursionLevel);
			}

			return str;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:40,代码来源:SprEngine.cs


示例6: GetEntryListSprContext

		internal static SprContext GetEntryListSprContext(PwEntry pe,
			PwDatabase pd)
		{
			SprContext ctx = new SprContext(pe, pd, SprCompileFlags.Deref);
			ctx.ForcePlainTextPasswords = false;
			return ctx;
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:7,代码来源:MainForm_Functions.cs


示例7: TransformContent

		public static string TransformContent(string strContent, SprContext ctx)
		{
			if(strContent == null) { Debug.Assert(false); return string.Empty; }

			string str = strContent;

			if(ctx != null)
			{
				if(ctx.EncodeQuotesForCommandLine)
					str = SprEncoding.MakeCommandQuotes(str);

				if(ctx.EncodeAsAutoTypeSequence)
					str = SprEncoding.MakeAutoTypeSequence(str);
			}

			return str;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:17,代码来源:SprEngine.cs


示例8: DerefFn

		internal static string DerefFn(string str, PwEntry pe)
		{
			if(!MightDeref(str)) return str;

			SprContext ctx = new SprContext(pe,
				Program.MainForm.DocumentManager.SafeFindContainerOf(pe),
				SprCompileFlags.Deref);
			// ctx.ForcePlainTextPasswords = false;

			return Compile(str, ctx);
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:11,代码来源:SprEngine.cs


示例9: PerformTextTransforms

		private static string PerformTextTransforms(string strText, SprContext ctx,
			uint uRecursionLevel)
		{
			string str = strText;
			int iStart;
			List<string> lParams;

			while(ParseAndRemovePlhWithParams(ref str, ctx, uRecursionLevel,
				@"{T-REPLACE-RX:", out iStart, out lParams, true))
			{
				if(lParams.Count < 2) continue;
				if(lParams.Count == 2) lParams.Add(string.Empty);

				try
				{
					string strNew = Regex.Replace(lParams[0], lParams[1], lParams[2]);
					strNew = TransformContent(strNew, ctx);
					str = str.Insert(iStart, strNew);
				}
				catch(Exception) { }
			}

			while(ParseAndRemovePlhWithParams(ref str, ctx, uRecursionLevel,
				@"{T-CONV:", out iStart, out lParams, true))
			{
				if(lParams.Count < 2) continue;

				try
				{
					string strNew = lParams[0];
					string strCmd = lParams[1].ToLower();

					if((strCmd == "u") || (strCmd == "upper"))
						strNew = strNew.ToUpper();
					else if((strCmd == "l") || (strCmd == "lower"))
						strNew = strNew.ToLower();
					else if(strCmd == "base64")
					{
						byte[] pbUtf8 = StrUtil.Utf8.GetBytes(strNew);
						strNew = Convert.ToBase64String(pbUtf8);
					}
					else if(strCmd == "hex")
					{
						byte[] pbUtf8 = StrUtil.Utf8.GetBytes(strNew);
						strNew = MemUtil.ByteArrayToHexString(pbUtf8);
					}
					else if(strCmd == "uri")
						strNew = Uri.EscapeDataString(strNew);
					else if(strCmd == "uri-dec")
						strNew = Uri.UnescapeDataString(strNew);

					strNew = TransformContent(strNew, ctx);
					str = str.Insert(iStart, strNew);
				}
				catch(Exception) { Debug.Assert(false); }
			}

			return str;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:59,代码来源:SprEngine.cs


示例10: FillRefPlaceholders

		private static string FillRefPlaceholders(string strSeq, SprContext ctx,
			uint uRecursionLevel)
		{
			if(ctx.Database == null) return strSeq;

			string str = strSeq;

			int nOffset = 0;
			for(int iLoop = 0; iLoop < 20; ++iLoop)
			{
				str = SprEngine.FillRefsUsingCache(str, ctx);

				int nStart = str.IndexOf(StrRefStart, nOffset, SprEngine.ScMethod);
				if(nStart < 0) break;
				int nEnd = str.IndexOf(StrRefEnd, nStart + 1, SprEngine.ScMethod);
				if(nEnd <= nStart) break;

				string strFullRef = str.Substring(nStart, nEnd - nStart + 1);
				char chScan, chWanted;
				PwEntry peFound = FindRefTarget(strFullRef, ctx, out chScan, out chWanted);

				if(peFound != null)
				{
					string strInsData;
					if(chWanted == 'T')
						strInsData = peFound.Strings.ReadSafe(PwDefs.TitleField);
					else if(chWanted == 'U')
						strInsData = peFound.Strings.ReadSafe(PwDefs.UserNameField);
					else if(chWanted == 'A')
						strInsData = peFound.Strings.ReadSafe(PwDefs.UrlField);
					else if(chWanted == 'P')
						strInsData = peFound.Strings.ReadSafe(PwDefs.PasswordField);
					else if(chWanted == 'N')
						strInsData = peFound.Strings.ReadSafe(PwDefs.NotesField);
					else if(chWanted == 'I')
						strInsData = peFound.Uuid.ToHexString();
					else { nOffset = nStart + 1; continue; }

					if((chWanted == 'P') && !ctx.ForcePlainTextPasswords &&
						Program.Config.MainWindow.IsColumnHidden(AceColumnType.Password))
						strInsData = PwDefs.HiddenPassword;

					SprContext sprSub = ctx.WithoutContentTransformations();
					sprSub.Entry = peFound;

					string strInnerContent = SprEngine.CompileInternal(strInsData,
						sprSub, uRecursionLevel + 1);
					strInnerContent = SprEngine.TransformContent(strInnerContent, ctx);

					// str = str.Substring(0, nStart) + strInnerContent + str.Substring(nEnd + 1);
					SprEngine.AddRefToCache(strFullRef, strInnerContent, ctx);
					str = SprEngine.FillRefsUsingCache(str, ctx);
				}
				else { nOffset = nStart + 1; continue; }
			}

			return str;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:58,代码来源:SprEngine.cs


示例11: FillRefsUsingCache

		private static string FillRefsUsingCache(string strText, SprContext ctx)
		{
			string str = strText;

			foreach(KeyValuePair<string, string> kvp in ctx.RefsCache)
			{
				// str = str.Replace(kvp.Key, kvp.Value);
				str = StrUtil.ReplaceCaseInsensitive(str, kvp.Key, kvp.Value);
			}

			return str;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:12,代码来源:SprEngine.cs


示例12: GeneratePassword

        private static string GeneratePassword(string strProfile, SprContext ctx)
        {
            PwProfile prf = Program.Config.PasswordGenerator.AutoGeneratedPasswordsProfile;
            if(!string.IsNullOrEmpty(strProfile))
            {
                if(strProfile == @"~")
                    prf = PwProfile.DeriveFromPassword(ctx.Entry.Strings.GetSafe(
                        PwDefs.PasswordField));
                else
                {
                    List<PwProfile> lPrf = PwGeneratorUtil.GetAllProfiles(false);
                    foreach(PwProfile p in lPrf)
                    {
                        if(strProfile.Equals(p.Name, StrUtil.CaseIgnoreCmp))
                        {
                            prf = p;
                            break;
                        }
                    }
                }
            }

            ProtectedString ps;
            PwgError e = PwGenerator.Generate(out ps, prf, null,
                Program.PwGeneratorPool);
            if((e != PwgError.Success) || (ps == null)) return string.Empty;

            string strGen = ps.ReadString();
            strGen = SprEngine.TransformContent(strGen, ctx);
            return strGen;
        }
开发者ID:rdealexb,项目名称:keepass,代码行数:31,代码来源:EntryUtil.cs


示例13: ReplaceHmacOtpPlaceholder

        private static string ReplaceHmacOtpPlaceholder(string strText,
            SprContext ctx)
        {
            PwEntry pe = ctx.Entry;
            PwDatabase pd = ctx.Database;
            if((pe == null) || (pd == null)) return strText;

            string str = strText;

            const string strHmacOtpPlh = @"{HMACOTP}";
            if(str.IndexOf(strHmacOtpPlh, StrUtil.CaseIgnoreCmp) >= 0)
            {
                const string strKeyFieldUtf8 = "HmacOtp-Secret";
                const string strKeyFieldHex = "HmacOtp-Secret-Hex";
                const string strKeyFieldBase32 = "HmacOtp-Secret-Base32";
                const string strKeyFieldBase64 = "HmacOtp-Secret-Base64";
                const string strCounterField = "HmacOtp-Counter";

                byte[] pbSecret = null;
                try
                {
                    string strKey = pe.Strings.ReadSafe(strKeyFieldUtf8);
                    if(strKey.Length > 0)
                        pbSecret = StrUtil.Utf8.GetBytes(strKey);

                    if(pbSecret == null)
                    {
                        strKey = pe.Strings.ReadSafe(strKeyFieldHex);
                        if(strKey.Length > 0)
                            pbSecret = MemUtil.HexStringToByteArray(strKey);
                    }

                    if(pbSecret == null)
                    {
                        strKey = pe.Strings.ReadSafe(strKeyFieldBase32);
                        if(strKey.Length > 0)
                            pbSecret = MemUtil.ParseBase32(strKey);
                    }

                    if(pbSecret == null)
                    {
                        strKey = pe.Strings.ReadSafe(strKeyFieldBase64);
                        if(strKey.Length > 0)
                            pbSecret = Convert.FromBase64String(strKey);
                    }
                }
                catch(Exception) { Debug.Assert(false); }
                if(pbSecret == null) pbSecret = new byte[0];

                string strCounter = pe.Strings.ReadSafe(strCounterField);
                ulong uCounter;
                ulong.TryParse(strCounter, out uCounter);

                string strValue = HmacOtp.Generate(pbSecret, uCounter, 6,
                    false, -1);

                pe.Strings.Set(strCounterField, new ProtectedString(false,
                    (uCounter + 1).ToString()));
                pd.Modified = true;

                str = StrUtil.ReplaceCaseInsensitive(str, strHmacOtpPlh, strValue);
            }

            return str;
        }
开发者ID:rdealexb,项目名称:keepass,代码行数:65,代码来源:EntryUtil.cs


示例14: FillPlaceholders

 public static string FillPlaceholders(string strText, SprContext ctx)
 {
     return FillPlaceholders(strText, ctx, 0);
 }
开发者ID:rdealexb,项目名称:keepass,代码行数:4,代码来源:EntryUtil.cs


示例15: FillEntryStringsSpecial

        private static string FillEntryStringsSpecial(string str, SprContext ctx,
            uint uRecursionLevel)
        {
            if((str.IndexOf(UrlSpecialRmvScm, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialScm, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialHost, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialPort, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialPath, SprEngine.ScMethod) >= 0) ||
                (str.IndexOf(UrlSpecialQuery, SprEngine.ScMethod) >= 0))
            {
                string strUrl = SprEngine.FillIfExists(@"{URL}", @"{URL}",
                    ctx.Entry.Strings.GetSafe(PwDefs.UrlField), ctx, uRecursionLevel);

                str = StrUtil.ReplaceCaseInsensitive(str, UrlSpecialRmvScm,
                    UrlUtil.RemoveScheme(strUrl));

                try
                {
                    Uri uri = new Uri(strUrl);

                    str = StrUtil.ReplaceCaseInsensitive(str, UrlSpecialScm,
                        uri.Scheme);
                    str = StrUtil.ReplaceCaseInsensitive(str, UrlSpecialHost,
                        uri.Host);
                    str = StrUtil.ReplaceCaseInsensitive(str, UrlSpecialPort,
                        uri.Port.ToString());
                    str = StrUtil.ReplaceCaseInsensitive(str, UrlSpecialPath,
                        uri.AbsolutePath);
                    str = StrUtil.ReplaceCaseInsensitive(str, UrlSpecialQuery,
                        uri.Query);
                }
                catch(Exception) { } // Invalid URI
            }

            return str;
        }
开发者ID:ashwingj,项目名称:keepass2,代码行数:36,代码来源:SprEngine.cs


示例16: OpenUrl

		public static void OpenUrl(string strUrlToOpen, PwEntry peDataSource,
			bool bAllowOverride, string strBaseRaw)
		{
			// If URL is null, return, do not throw exception.
			Debug.Assert(strUrlToOpen != null); if(strUrlToOpen == null) return;

			string strPrevWorkDir = WinUtil.GetWorkingDirectory();
			string strThisExe = WinUtil.GetExecutable();
			
			string strExeDir = UrlUtil.GetFileDirectory(strThisExe, false, true);
			WinUtil.SetWorkingDirectory(strExeDir);

			string strUrlFlt = strUrlToOpen;
			strUrlFlt = strUrlFlt.TrimStart(new char[]{ ' ', '\t', '\r', '\n' });

			PwDatabase pwDatabase = null;
			try
			{
				pwDatabase = Program.MainForm.DocumentManager.SafeFindContainerOf(
					peDataSource);
			}
			catch(Exception) { Debug.Assert(false); }

			bool bCmdQuotes = WinUtil.IsCommandLineUrl(strUrlFlt);

			SprContext ctx = new SprContext(peDataSource, pwDatabase,
				SprCompileFlags.All, false, bCmdQuotes);
			ctx.Base = strBaseRaw;
			ctx.BaseIsEncoded = false;

			string strUrl = SprEngine.Compile(strUrlFlt, ctx);

			string strOvr = Program.Config.Integration.UrlSchemeOverrides.GetOverrideForUrl(
				strUrl);
			if(!bAllowOverride) strOvr = null;
			if(strOvr != null)
			{
				bool bCmdQuotesOvr = WinUtil.IsCommandLineUrl(strOvr);

				SprContext ctxOvr = new SprContext(peDataSource, pwDatabase,
					SprCompileFlags.All, false, bCmdQuotesOvr);
				ctxOvr.Base = strUrl;
				ctxOvr.BaseIsEncoded = bCmdQuotes;

				strUrl = SprEngine.Compile(strOvr, ctxOvr);
			}

			if(WinUtil.IsCommandLineUrl(strUrl))
			{
				string strApp, strArgs;
				StrUtil.SplitCommandLine(WinUtil.GetCommandLineFromUrl(strUrl),
					out strApp, out strArgs);

				try
				{
					if((strArgs != null) && (strArgs.Length > 0))
						Process.Start(strApp, strArgs);
					else
						Process.Start(strApp);
				}
				catch(Win32Exception)
				{
					StartWithoutShellExecute(strApp, strArgs);
				}
				catch(Exception exCmd)
				{
					string strInf = KPRes.FileOrUrl + ": " + strApp;
					if((strArgs != null) && (strArgs.Length > 0))
						strInf += MessageService.NewParagraph +
							KPRes.Arguments + ": " + strArgs;

					MessageService.ShowWarning(strInf, exCmd);
				}
			}
			else // Standard URL
			{
				try { Process.Start(strUrl); }
				catch(Exception exUrl)
				{
					MessageService.ShowWarning(strUrl, exUrl);
				}
			}

			// Restore previous working directory
			WinUtil.SetWorkingDirectory(strPrevWorkDir);

			// SprEngine.Compile might have modified the database
			Program.MainForm.UpdateUI(false, null, false, null, false, null, false);
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:89,代码来源:WinUtil.cs


示例17: GetUserPass

        internal string[] GetUserPass(PwEntryDatabase entryDatabase)
        {
            // follow references
            SprContext ctx = new SprContext(entryDatabase.entry, entryDatabase.database,
                    SprCompileFlags.All, false, false);
            string user = SprEngine.Compile(
                    entryDatabase.entry.Strings.ReadSafe(PwDefs.UserNameField), ctx);
            string pass = SprEngine.Compile(
                    entryDatabase.entry.Strings.ReadSafe(PwDefs.PasswordField), ctx);
            var f = (MethodInvoker)delegate
            {
                // apparently, SprEngine.Compile might modify the database
                host.MainWindow.UpdateUI(false, null, false, null, false, null, false);
            };
            if (host.MainWindow.InvokeRequired)
                host.MainWindow.Invoke(f);
            else
                f.Invoke();

            return new string[] { user, pass };
        }
开发者ID:Articus7,项目名称:keepasshttp,代码行数:21,代码来源:KeePassHttp.cs


示例18: FillEntryStringsSpecial

		private static string FillEntryStringsSpecial(string str, SprContext ctx,
			uint uRecursionLevel)
		{
			return FillUriSpecial(str, ctx, @"{URL", ctx.Entry.Strings.ReadSafe(
				PwDefs.UrlField), false, uRecursionLevel);
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:6,代码来源:SprEngine.cs


示例19: ReplaceNewPasswordPlaceholder

        private static string ReplaceNewPasswordPlaceholder(string strText,
            SprContext ctx, uint uRecursionLevel)
        {
            PwEntry pe = ctx.Entry;
            PwDatabase pd = ctx.Database;
            if((pe == null) || (pd == null)) return strText;

            string str = strText;

            const string strNewPwStart = @"{NEWPASSWORD";
            if(str.IndexOf(strNewPwStart, StrUtil.CaseIgnoreCmp) < 0) return str;

            string strGen = null;

            int iStart;
            List<string> lParams;
            while(SprEngine.ParseAndRemovePlhWithParams(ref str, ctx, uRecursionLevel,
                strNewPwStart + ":", out iStart, out lParams, true))
            {
                if(strGen == null)
                    strGen = GeneratePassword((((lParams != null) &&
                        (lParams.Count > 0)) ? lParams[0] : string.Empty), ctx);

                str = str.Insert(iStart, strGen);
            }

            const string strNewPwPlh = strNewPwStart + @"}";
            if(str.IndexOf(strNewPwPlh, StrUtil.CaseIgnoreCmp) >= 0)
            {
                if(strGen == null) strGen = GeneratePassword(null, ctx);

                str = StrUtil.ReplaceCaseInsensitive(str, strNewPwPlh, strGen);
            }

            if(strGen != null)
            {
                pe.CreateBackup(pd);

                ProtectedString psGen = new ProtectedString(
                    pd.MemoryProtection.ProtectPassword, strGen);
                pe.Strings.Set(PwDefs.PasswordField, psGen);

                pe.Touch(true, false);
                pd.Modified = true;
            }
            else { Debug.Assert(false); }

            return str;
        }
开发者ID:rdealexb,项目名称:keepass,代码行数:49,代码来源:EntryUtil.cs


示例20: FillUriSpecial

		private static string FillUriSpecial(string strText, SprContext ctx,
			string strPlhInit, string strData, bool bDataIsEncoded,
			uint uRecursionLevel)
		{
			Debug.Assert(strPlhInit.StartsWith(@"{") && !strPlhInit.EndsWith(@"}"));
			Debug.Assert(strData != null);

			string[] vPlhs = new string[] {
				strPlhInit + @"}",
				strPlhInit + @":RMVSCM}",
				strPlhInit + @":SCM}",
				strPlhInit + @":HOST}",
				strPlhInit + @":PORT}",
				strPlhInit + @":PATH}",
				strPlhInit + @":QUERY}",
				strPlhInit + @":USERINFO}",
				strPlhInit + @":USERNAME}",
				strPlhInit + @":PASSWORD}"
			};

			string str = strText;
			string strDataCmp = null;
			Uri uri = null;
			for(int i = 0; i < vPlhs.Length; ++i)
			{
				string strPlh = vPlhs[i];
				if(str.IndexOf(strPlh, SprEngine.ScMethod) < 0) continue;

				if(strDataCmp == null)
				{
					SprContext ctxData = (bDataIsEncoded ?
						ctx.WithoutContentTransformations() : ctx);
					strDataCmp = SprEngine.CompileInternal(strData, ctxData,
						uRecursionLevel + 1);
				}

				string strRep = null;
				if(i == 0) strRep = strDataCmp;
				else if(i == 1) strRep = UrlUtil.RemoveScheme(strDataCmp);
				else
				{
					try
					{
						if(uri == null) uri = new Uri(strDataCmp);

						int t;
						switch(i)
						{
							case 2: strRep = uri.Scheme; break;
							case 3: strRep = uri.Host; break;
							case 4:
								strRep = uri.Port.ToString(
									NumberFormatInfo.InvariantInfo);
								break;
							case 5: strRep = uri.AbsolutePath; break;
							case 6: strRep = uri.Query; break;
							case 7: strRep = uri.UserInfo; break;
							case 8:
								strRep = uri.UserInfo;
								t = strRep.IndexOf(':');
								if(t >= 0) strRep = strRep.Substring(0, t);
								break;
							case 9:
								strRep = uri.UserInfo;
								t = strRep.IndexOf(':');
								if(t < 0) strRep = string.Empty;
								else strRep = strRep.Substring(t + 1);
								break;
							default: Debug.Assert(false); break;
						}
					}
					catch(Exception) { } // Invalid URI
				}
				if(strRep == null) strRep = string.Empty; // No assert

				str = StrUtil.ReplaceCaseInsensitive(str, strPlh, strRep);
			}

			return str;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:80,代码来源:SprEngine.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# KeePassHttp.Request类代码示例发布时间:2022-05-26
下一篇:
C# UI.PwDocument类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap