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


C# CharStream.PeekChar方法代码示例

本文整理汇总了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();
        }
开发者ID:Stoom,项目名称:KeePass,代码行数:25,代码来源:Json.cs

示例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();
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:27,代码来源:Json.cs

示例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);
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:15,代码来源:MozillaBookmarksJson100.cs

示例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);
					}
				}
			}
		}
开发者ID:riking,项目名称:go-keepass2,代码行数:36,代码来源:MozillaBookmarksJson100.cs

示例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); }
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:20,代码来源:Json.cs

示例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);
		}
开发者ID:ComradeP,项目名称:KeePass-2.x,代码行数:26,代码来源:Json.cs

示例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); }
        }
开发者ID:Stoom,项目名称:KeePass,代码行数:23,代码来源:Json.cs

示例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;
            }

//.........这里部分代码省略.........
开发者ID:rdealexb,项目名称:keepass,代码行数:101,代码来源:SendInputEx.cs


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