本文整理汇总了C#中KeePass.Util.Spr.SprContext.WithoutContentTransformations方法的典型用法代码示例。如果您正苦于以下问题:C# SprContext.WithoutContentTransformations方法的具体用法?C# SprContext.WithoutContentTransformations怎么用?C# SprContext.WithoutContentTransformations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeePass.Util.Spr.SprContext
的用法示例。
在下文中一共展示了SprContext.WithoutContentTransformations方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: ParseAndRemovePlhWithParams
/// <summary>
/// Parse and remove a placeholder of the form
/// <c>{PLH:/Param1/Param2/.../}</c>.
/// </summary>
internal static bool ParseAndRemovePlhWithParams(ref string str,
SprContext ctx, uint uRecursionLevel, string strPlhStart,
out int iStart, out List<string> lParams, bool bSprCmpParams)
{
Debug.Assert(strPlhStart.StartsWith(@"{") && !strPlhStart.EndsWith(@"}"));
iStart = str.IndexOf(strPlhStart, StrUtil.CaseIgnoreCmp);
if(iStart < 0) { lParams = null; return false; }
lParams = new List<string>();
try
{
int p = iStart + strPlhStart.Length;
if(p >= str.Length) throw new FormatException();
char chSep = str[p];
while(true)
{
if((p + 1) >= str.Length) throw new FormatException();
if(str[p + 1] == '}') break;
int q = str.IndexOf(chSep, p + 1);
if(q < 0) throw new FormatException();
lParams.Add(str.Substring(p + 1, q - p - 1));
p = q;
}
Debug.Assert(str[p + 1] == '}');
str = str.Remove(iStart, (p + 1) - iStart + 1);
}
catch(Exception)
{
str = str.Substring(0, iStart);
}
if(bSprCmpParams && (ctx != null))
{
SprContext ctxSub = ctx.WithoutContentTransformations();
for(int i = 0; i < lParams.Count; ++i)
lParams[i] = CompileInternal(lParams[i], ctxSub, uRecursionLevel);
}
return true;
}
示例3: 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;
}
示例4: 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;
}
示例5: FillIfExists
private static string FillIfExists(string strData, string strPlaceholder,
ProtectedString psParsable, SprContext ctx, uint uRecursionLevel)
{
// // The UrlRemoveSchemeOnce property of ctx must be cleared
// // before this method returns and before any recursive call
// bool bRemoveScheme = false;
// if(ctx != null)
// {
// bRemoveScheme = ctx.UrlRemoveSchemeOnce;
// ctx.UrlRemoveSchemeOnce = false;
// }
if(strData == null) { Debug.Assert(false); return string.Empty; }
if(strPlaceholder == null) { Debug.Assert(false); return strData; }
if(strPlaceholder.Length == 0) { Debug.Assert(false); return strData; }
if(psParsable == null) { Debug.Assert(false); return strData; }
if(strData.IndexOf(strPlaceholder, SprEngine.ScMethod) >= 0)
{
string strReplacement = SprEngine.CompileInternal(
psParsable.ReadString(), ctx.WithoutContentTransformations(),
uRecursionLevel + 1);
// if(bRemoveScheme)
// strReplacement = UrlUtil.RemoveScheme(strReplacement);
return SprEngine.FillPlaceholder(strData, strPlaceholder,
strReplacement, ctx);
}
return strData;
}
示例6: ShowCharPickDlg
private static string ShowCharPickDlg(string strWord, uint uCharCount,
bool? bInitHide, SprContext ctx, uint uRecursionLevel)
{
string strPick = SprEngine.CompileInternal(strWord,
ctx.WithoutContentTransformations(), uRecursionLevel + 1);
// No need to show the dialog when there's nothing to pick from
// (this also prevents the dialog from showing up MaxRecursionDepth
// times in case of a cyclic {PICKCHARS})
if(string.IsNullOrEmpty(strPick)) return string.Empty;
ProtectedString psWord = new ProtectedString(false, strPick);
string strPicked = CharPickerForm.ShowAndRestore(psWord,
true, true, uCharCount, bInitHide);
return (strPicked ?? string.Empty); // Don't transform here
}
示例7: ShowCharPickDlg
private static string ShowCharPickDlg(string strWord, uint uCharCount,
bool? bInitHide, SprContext ctx, uint uRecursionLevel)
{
string strPick = SprEngine.CompileInternal(strWord,
ctx.WithoutContentTransformations(), uRecursionLevel + 1);
// No need to show the dialog when there's nothing to pick from
// (this also prevents the dialog from showing up MaxRecursionDepth
// times in case of a cyclic {PICKCHARS})
if(string.IsNullOrEmpty(strPick)) return string.Empty;
CharPickerForm cpf = new CharPickerForm();
cpf.InitEx(new ProtectedString(false, strPick), true, true,
uCharCount, bInitHide);
string strResult = string.Empty;
if(cpf.ShowDialog() == DialogResult.OK)
strResult = cpf.SelectedCharacters.ReadString();
UIUtil.DestroyForm(cpf);
return strResult; // Don't transform here
}