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


C# IScanner类代码示例

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


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

示例1: ParseMain

				/// <summary>
				/// Inner parse method
				/// </summary>
				/// <param name="scanner">scanner</param>
				/// <returns>the match</returns>
				protected override ParserMatch ParseMain(IScanner scanner)
		{
			// save scanner state
			long offset = scanner.Offset;

			// apply the first parser
			ParserMatch m = FirstParser.Parse(scanner);
			// if m1 successful, do m2
			if (m.Success)
			{
				return m;
			}

			// not found try the next
			scanner.Seek(offset);

			// apply the second parser
			m = SecondParser.Parse(scanner);
			if (m.Success)
			{
				return m;
			}

			scanner.Seek(offset);
			return ParserMatch.CreateFailureMatch(scanner);
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:31,代码来源:AlternativeParser.cs

示例2: CategoriesListViewModel

        public CategoriesListViewModel(IProductService service, INavigationService navi, IScanner scanner)
        {
            _service = service;
            _navi = navi;
            _scanner = scanner;

            Items = new NotifyTaskCompletion<List<Product>>(_service.GetProducts());
            Categories = new NotifyTaskCompletion<List<string>>(_service.GetCategories());

            NavigateToCategory = new RelayCommand<string>(async cat =>
            {
                var items = (await _service.GetProductsForCategory(cat))
                    .OrderByDescending(i => i.Rating)
                    .ToList();

                if (items != null && items.Any())
                {
                    var page = App.GetProductsListPage(items, cat);
                    await _navi.PushAsync(page);
                }
                else
                {
                    await _navi.DisplayAlert("Error", "There are no items in the category " + cat);
                }
            });

            _searchCommand = new RelayCommand(Search, () => !string.IsNullOrWhiteSpace(SearchTerm));
            ScanCommand = new RelayCommand(async () =>
            {
                var result = await _scanner.Scan();

                SearchTerm = result.Text;
                Search();
            });
        }
开发者ID:adbk,项目名称:spikes,代码行数:35,代码来源:CategoriesListViewModel.cs

示例3: ParseMain

		/// <summary>
		/// Inner parse method
		/// </summary>
		/// <param name="scanner">scanner</param>
		/// <returns>the match</returns>
		protected override ParserMatch ParseMain(IScanner scanner)
		{
			if (scanner == null)
				throw new ArgumentNullException("scanner");

			return ParserMatch.CreateFailureMatch(scanner);
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:12,代码来源:NothingParser.cs

示例4: ParseMain

		/// <summary>
		/// Inner parse method
		/// </summary>
		/// <param name="scanner">scanner</param>
		/// <returns>the match</returns>
		protected override ParserMatch ParseMain(IScanner scanner)
		{
			long offset = scanner.Offset;

			ParserMatch m = FirstParser.Parse(scanner);
			if (!m.Success)
			{
				scanner.Seek(offset);
				return m;
			}

			while (!scanner.AtEnd)
			{
				offset = scanner.Offset;

				ParserMatch b = SecondParser.Parse(scanner);
				if (!b.Success)
				{
					scanner.Seek(offset);
					return m;
				}
				ParserMatch a = FirstParser.Parse(scanner);
				if (!a.Success)
				{
					scanner.Seek(offset);
					return m;
				}

				m.Concat(b);
				m.Concat(a);
			}

			return m;
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:39,代码来源:ListParser.cs

示例5: Parse

        /// <summary>
        /// Public scanner method. Test scanner input for this parser's patterns.
        /// </summary>
        /// <remarks>Most parsers won't need to override this method</remarks>
        /// <param name="scan">Scanner to parse from</param>
        /// <returns>Match (success of failure) of the parser against the scanne</returns>
        public virtual ParserMatch Parse(IScanner scan)
        {
            scan.Normalise();

            var st = new System.Diagnostics.StackTrace();
            scan.StackStats(st.FrameCount);

            if (scan.RecursionCheck(this, scan.Offset))
                if (!(this is Recursion))
                    return scan.NoMatch;

            ParserMatch m;

            if (this is IMatchingParser) m = ((IMatchingParser) this).TryMatch(scan);
            else m = Parse(scan);

            if (m.Success)
            {
                scan.ClearFailures();
            }
            else
            {
                scan.AddFailure(this, scan.Offset);
            }
            return m;
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:32,代码来源:Parser.cs

示例6: TryMatch

        public override ParserMatch TryMatch(IScanner scan)
        {
            // save scanner state
            int offset = scan.Offset;

            // apply the first parser
            var m = LeftParser.Parse(scan);

            // rewind
            scan.Seek(offset);

            // apply the second parser
            var m2 = RightParser.Parse(scan);

            // pick the longest result
            if (m.Success || m2.Success)
            {
                if (m2.Length >= m.Length)
                {
                    scan.Seek(m2.Offset + m2.Length);
                    return m2;
                }
                scan.Seek(m.Offset + m.Length);
                return m;
            }

            // rewind to point of failure
            scan.Seek(offset);
            return scan.NoMatch;
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:30,代码来源:Union.cs

示例7: Register

        public Register(IBasket basket, IDisplay display, IScanner scanner)
        {
            logger = LoggerFactory.GetLogger();

            this.basket = basket;
            this.display = display;
            this.scanner = scanner;

            basket.OnAdd += display.AddProduct;
            basket.AddSuccess += scanner.FlashLed;
            basket.AddFail += scanner.FlashLed;
            basket.OnUpdate += display.UpdateProduct;
            basket.OnRemove += display.RemoveProduct;
            basket.OnUpdateTotalCost += display.UpdateTotalCost;
            basket.OnUpdateProductCount += display.UpdateProductCount;

            display.OnStartScan += scanner.Start;
            display.OnStopScan += scanner.Stop;
            display.OnClear += basket.Clear;

            scanner.OnRead += new OnReadHandler(scanner_OnRead);

            logger.Write("Register", LogLevel.INFO, "Register initialized");

            display.Display();
        }
开发者ID:wytsevisser,项目名称:wvt,代码行数:26,代码来源:Register.cs

示例8: TryMatch

        public override ParserMatch TryMatch(IScanner scan)
        {
            int offset = scan.Offset;

            var m = LeftParser.Parse(scan);

            int goodOffset = scan.Offset;

            if (!m.Success)
            {
                scan.Seek(offset);
                return scan.NoMatch;
            }

            // doing difference
            scan.Seek(offset);
            var m2 = RightParser.Parse(scan);
            if (m2.Success)
            {
                // fail: must match left but NOT right
                scan.Seek(offset);
                return scan.NoMatch;
            }

            // Good match
            scan.Seek(goodOffset);
            return m;
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:28,代码来源:Difference.cs

示例9: TryAccept

		/// <summary>
		/// Lookahead to determine if parser can be used to parse (does not consume input)
		/// </summary>
		/// <param name="scanner"></param>
		/// <returns></returns>
		internal ParserMatch TryAccept(IScanner scanner)
		{
			long offset = scanner.Offset;
			ParserMatch m = ParseMain(scanner);
			scanner.Offset = offset;
			return m;
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:12,代码来源:Parser.cs

示例10: ParseMain

		/// <summary>
		/// Inner parse method
		/// </summary>
		/// <param name="scanner">scanner</param>
		/// <returns>the match</returns>
		protected override ParserMatch ParseMain(IScanner scanner)
		{
			long offset = scanner.Offset;
			int len = 0;

			if (scanner.Peek() == '\r')    // CR
			{
				scanner.Read();
				++len;
			}

			if (scanner.Peek() == '\n')    // LF
			{
				scanner.Read();
				++len;
			}

			if (len>0)
			{
				ParserMatch m = ParserMatch.CreateSuccessfulMatch(scanner, offset, len);
				return m;
			}
			scanner.Seek(offset);
			return ParserMatch.CreateFailureMatch(scanner);
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:30,代码来源:EolParser.cs

示例11: MySqlColorizer

//        private IScanner scanner;
  //      private IVsTextLines buffer;
    //    private List<TokenInfo>[] tokenList;
      //  private string savedSqlText;

        public MySqlColorizer(LanguageService service, IVsTextLines buffer, IScanner scanner)
            : base(service, buffer, scanner)
        {
            (scanner as MySqlScanner).Colorizer = this;
//            this.scanner = scanner;
  //          this.buffer = buffer;
        }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:12,代码来源:MySqlColorizer.cs

示例12: Solve

        private static string Solve(IScanner scanner)
        {
            int numberOfPhoneNumbers = scanner.NextInt();
            Program.PhoneNode phoneBook = new Program.PhoneNode(String.Empty, false);
            string answer = null;

            for (int j = 0; j < numberOfPhoneNumbers; j++)
            {
                var no = scanner.Next();
                Debug.WriteLine("Processing: " + no);

                if (answer != null)
                    continue;

                var current = phoneBook;

                for (int index = 0; index < no.Length; index++)
                {
                    var digit = no[index] - '0';
                    if (current.Nodes[digit] == null)
                        current.Nodes[digit] = new PhoneNode(current.Id + digit, index == no.Length - 1);
                    else if (index == no.Length - 1 || current.Nodes[digit].IsStop)
                    {
                        // if this is my last digit and number already used - 'NO'
                        // if some other number finished here - 'NO'

                        // number already exists
                        answer = "NO";
                        break;
                    }
                    current = current.Nodes[digit];
                }
            }
            return answer ?? "YES";
        }
开发者ID:karpikpl,项目名称:phonelist,代码行数:35,代码来源:Program.cs

示例13: TryMatch

        public ParserMatch TryMatch(IScanner scan)
        {
            if (source == null) throw new Exception("Empty holding parser");
            if (! (source is IMatchingParser)) throw new Exception("Holding parser was non terminating");

            return (source as IMatchingParser).TryMatch(scan);
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:7,代码来源:Recursion.cs

示例14: BorrowController

        public BorrowController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer,
                                    IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO)
        {
            if(display == null) throw new ArgumentException("Display object was not provided to begin the application");
            if (reader == null) throw new ArgumentException("Reader object was not provided to begin the application");
            if (scanner == null) throw new ArgumentException("Scanner object was not provided to begin the application");
            if (printer == null) throw new ArgumentException("Printer object was not provided to begin the application");
            if (bookDAO == null) throw new ArgumentException("BookDAO object was not provided to begin the application");
            if (loanDAO == null) throw new ArgumentException("LoanDAO object was not provided to begin the application");
            if (memberDAO == null) throw new ArgumentException("MemberDAO object was not provided to begin the application");

            _display = display;
            _reader = reader;
            _scanner = scanner;
            _printer = printer;

            _bookDAO = bookDAO;
            _loanDAO = loanDAO;
            _memberDAO = memberDAO;

            _ui = new BorrowControl(this);

            _reader.Listener = this;
            _scanner.Listener = this;

            _bookList = new List<IBook>();
            _loanList = new List<ILoan>();

            _state = EBorrowState.CREATED;
        }
开发者ID:andrewtobin,项目名称:NewLibrary_CSharp,代码行数:30,代码来源:BorrowController.cs

示例15: TryMatch

        public ParserMatch TryMatch(IScanner scan)
        {
            int offset = scan.Offset;
            int len = 0;

            if (!scan.EndOfInput && scan.Peek() == '\r') // CR
            {
                scan.Read();
                len++;
            }

            if (!scan.EndOfInput && scan.Peek() == '\n') // LF
            {
                scan.Read();
                len++;
            }

            if (len > 0)
            {
                return scan.CreateMatch(this, offset, len);
            }

            scan.Seek(offset);
            return scan.NoMatch;
        }
开发者ID:i-e-b,项目名称:Phantom2,代码行数:25,代码来源:EndOfLine.cs


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