本文整理汇总了C#中KeePassLib.Utility.CharStream.PeekChar方法的典型用法代码示例。如果您正苦于以下问题:C# CharStream.PeekChar方法的具体用法?C# CharStream.PeekChar怎么用?C# CharStream.PeekChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeePassLib.Utility.CharStream
的用法示例。
在下文中一共展示了CharStream.PeekChar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsonArray
public JsonArray(CharStream csDataSource)
{
if(csDataSource == null) throw new ArgumentNullException("csDataSource");
char chInit = csDataSource.ReadChar(true);
if(chInit != '[') throw new JsonFormatException();
List<JsonValue> lValues = new List<JsonValue>();
while(true)
{
char chNext = csDataSource.PeekChar(true);
if(chNext == ']') break;
lValues.Add(new JsonValue(csDataSource));
chNext = csDataSource.PeekChar(true);
if(chNext == ',') csDataSource.ReadChar(true);
}
char chTerminator = csDataSource.ReadChar(true);
if(chTerminator != ']') throw new JsonFormatException();
m_values = lValues.ToArray();
}
示例2: JsonObject
public JsonObject(CharStream csDataSource)
{
if(csDataSource == null) throw new ArgumentNullException("csDataSource");
char chInit = csDataSource.ReadChar(true);
if(chInit != '{') throw new JsonFormatException();
while(true)
{
string strName = (new JsonString(csDataSource)).Value;
char chSeparator = csDataSource.ReadChar(true);
if(chSeparator != ':') throw new JsonFormatException();
JsonValue jValue = new JsonValue(csDataSource);
m_dict[strName] = jValue;
char chNext = csDataSource.PeekChar(true);
if(chNext == '}') break;
else if(chNext == ',') csDataSource.ReadChar(true);
else throw new JsonFormatException();
}
char chTerminator = csDataSource.ReadChar(true);
if(chTerminator != '}') throw new JsonFormatException();
}
示例3: Import
public override void Import(PwDatabase pwStorage, Stream sInput,
IStatusLogger slLogger)
{
StreamReader sr = new StreamReader(sInput, Encoding.UTF8);
string strContent = sr.ReadToEnd();
sr.Close();
if(strContent.Length == 0) return;
CharStream cs = new CharStream(strContent);
JsonObject jRoot = new JsonObject(cs);
AddObject(pwStorage.RootGroup, jRoot, pwStorage, false);
Debug.Assert(cs.PeekChar(true) == char.MinValue);
}
示例4: Import
public override void Import(PwDatabase pwStorage, Stream sInput,
IStatusLogger slLogger)
{
StreamReader sr = new StreamReader(sInput, StrUtil.Utf8);
string strContent = sr.ReadToEnd();
sr.Close();
if(string.IsNullOrEmpty(strContent)) return;
CharStream cs = new CharStream(strContent);
Dictionary<string, List<string>> dTags =
new Dictionary<string, List<string>>();
List<PwEntry> lCreatedEntries = new List<PwEntry>();
JsonObject jRoot = new JsonObject(cs);
AddObject(pwStorage.RootGroup, jRoot, pwStorage, false, dTags,
lCreatedEntries);
Debug.Assert(cs.PeekChar(true) == char.MinValue);
// Assign tags
foreach(PwEntry pe in lCreatedEntries)
{
string strUri = pe.Strings.ReadSafe(PwDefs.UrlField);
if(strUri.Length == 0) continue;
foreach(KeyValuePair<string, List<string>> kvp in dTags)
{
foreach(string strTagUri in kvp.Value)
{
if(strUri.Equals(strTagUri, StrUtil.CaseIgnoreCmp))
pe.AddTag(kvp.Key);
}
}
}
}
示例5: JsonNumber
public JsonNumber(CharStream csDataSource)
{
if(csDataSource == null) throw new ArgumentNullException("csDataSource");
StringBuilder sb = new StringBuilder();
while(true)
{
char ch = csDataSource.PeekChar(true);
if(((ch >= '0') && (ch <= '9')) || (ch == 'e') || (ch == 'E') ||
(ch == '+') || (ch == '-') || (ch == '.'))
{
csDataSource.ReadChar(true);
sb.Append(ch);
}
else break;
}
if(!double.TryParse(sb.ToString(), out m_value)) { Debug.Assert(false); }
}
示例6: JsonValue
public JsonValue(CharStream csDataSource)
{
if(csDataSource == null) throw new ArgumentNullException("csDataSource");
char chNext = csDataSource.PeekChar(true);
if(chNext == '\"') m_value = (new JsonString(csDataSource)).Value;
else if(chNext == '{') m_value = new JsonObject(csDataSource);
else if(chNext == '[') m_value = new JsonArray(csDataSource);
else if(chNext == 't')
{
for(int i = 0; i < 4; ++i) csDataSource.ReadChar(true);
m_value = true;
}
else if(chNext == 'f')
{
for(int i = 0; i < 5; ++i) csDataSource.ReadChar(true);
m_value = false;
}
else if(chNext == 'n')
{
for(int i = 0; i < 4; ++i) csDataSource.ReadChar(true);
m_value = null;
}
else m_value = new JsonNumber(csDataSource);
}
示例7: JsonNumber
public JsonNumber(CharStream csDataSource)
{
if(csDataSource == null) throw new ArgumentNullException("csDataSource");
StringBuilder sb = new StringBuilder();
while(true)
{
char ch = csDataSource.PeekChar(true);
if(((ch >= '0') && (ch <= '9')) || (ch == 'e') || (ch == 'E') ||
(ch == '+') || (ch == '-') || (ch == '.'))
{
csDataSource.ReadChar(true);
sb.Append(ch);
}
else break;
}
const NumberStyles ns = (NumberStyles.Integer | NumberStyles.AllowDecimalPoint |
NumberStyles.AllowThousands | NumberStyles.AllowExponent);
if(!double.TryParse(sb.ToString(), ns, NumberFormatInfo.InvariantInfo,
out m_value)) { Debug.Assert(false); }
}
示例8: ParseSpecial
private static List<SiEvent> ParseSpecial(CharStream cs)
{
// Skip leading white space
while(true)
{
char ch = cs.PeekChar();
if(ch == char.MinValue) { Debug.Assert(false); return null; }
if(!char.IsWhiteSpace(ch)) break;
cs.ReadChar();
}
// First char is *always* part of the name (support for "{{}", etc.)
char chFirst = cs.ReadChar();
if(chFirst == char.MinValue) { Debug.Assert(false); return null; }
int iPart = 0;
StringBuilder sbName = new StringBuilder(), sbParams =
new StringBuilder();
sbName.Append(chFirst);
while(true)
{
char ch = cs.ReadChar();
if(ch == char.MinValue) { Debug.Assert(false); return null; }
if(ch == '}') break;
if(iPart == 0)
{
if(char.IsWhiteSpace(ch)) ++iPart;
else sbName.Append(ch);
}
else sbParams.Append(ch);
}
string strName = sbName.ToString();
string strParams = sbParams.ToString().Trim();
uint? ouParam = null;
if(strParams.Length > 0)
{
uint uParamTry;
if(uint.TryParse(strParams, out uParamTry)) ouParam = uParamTry;
}
List<SiEvent> l = new List<SiEvent>();
if(strName.Equals("DELAY", StrUtil.CaseIgnoreCmp))
{
if(!ouParam.HasValue) { Debug.Assert(false); return null; }
SiEvent si = new SiEvent();
si.Type = SiEventType.Delay;
si.Delay = ouParam.Value;
l.Add(si);
return l;
}
if(strName.StartsWith("DELAY=", StrUtil.CaseIgnoreCmp))
{
SiEvent si = new SiEvent();
si.Type = SiEventType.SetDefaultDelay;
string strDelay = strName.Substring(6).Trim();
uint uDelay;
if(uint.TryParse(strDelay, out uDelay))
si.Delay = uDelay;
else { Debug.Assert(false); return null; }
l.Add(si);
return l;
}
if(strName.Equals("VKEY", StrUtil.CaseIgnoreCmp) ||
strName.Equals("VKEY-NX", StrUtil.CaseIgnoreCmp) ||
strName.Equals("VKEY-EX", StrUtil.CaseIgnoreCmp))
{
if(!ouParam.HasValue) { Debug.Assert(false); return null; }
SiEvent si = new SiEvent();
si.Type = SiEventType.Key;
si.VKey = (int)ouParam.Value;
if(strName.EndsWith("-NX", StrUtil.CaseIgnoreCmp))
si.ExtendedKey = false;
else if(strName.EndsWith("-EX", StrUtil.CaseIgnoreCmp))
si.ExtendedKey = true;
l.Add(si);
return l;
}
if(strName.Equals("APPACTIVATE", StrUtil.CaseIgnoreCmp))
{
SiEvent si = new SiEvent();
si.Type = SiEventType.AppActivate;
si.Text = strParams;
l.Add(si);
return l;
}
//.........这里部分代码省略.........