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

C# Parser类代码示例

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

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



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

示例1: HandleFriendStatus

        public void HandleFriendStatus(Parser packet)
        {
            var result = (ContactResult)packet.ReadByte();
            WriteLine("Result: " + result);

            var guid = packet.ReadGuid();
            WriteLine("GUID: " + guid);

            switch (result)
            {
                case ContactResult.FriendAddedOnline:
                case ContactResult.FriendAddedOffline:
                case ContactResult.Online:
                {
                    if (result != ContactResult.Online)
                    {
                        var note = packet.ReadCString();
                        WriteLine("Note: " + note);
                    }

                    ReadSingleContactBlock(packet, false);
                    break;
                }
            }
        }
开发者ID:Gintama,项目名称:VoragineTools,代码行数:25,代码来源:ContactHandler.cs


示例2: Process

    public void Process(BundleContext context, BundleResponse bundle)
    {
        if (bundle == null)
        {
            throw new ArgumentNullException("bundle");
        }

        context.HttpContext.Response.Cache.SetLastModifiedFromFileDependencies();

        var lessParser = new Parser();
        ILessEngine lessEngine = CreateLessEngine(lessParser);

        var content = new StringBuilder(bundle.Content.Length);

        foreach (FileInfo file in bundle.Files)
        {
            SetCurrentFilePath(lessParser, file.FullName);
            string source = File.ReadAllText(file.FullName);
            content.Append(lessEngine.TransformToCss(source, file.FullName));
            content.AppendLine();

            AddFileDependencies(lessParser);
        }

        bundle.ContentType = "text/css";
        bundle.Content = content.ToString();
    }
开发者ID:panchaldineshb,项目名称:GitHubRepository,代码行数:27,代码来源:LessMinify.cs


示例3: Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted

        public void Errors_of_type_MutuallyExclusiveSetError_are_properly_formatted()
        {
            // Fixture setup
            var help = new StringWriter();
            var sut = new Parser(config => config.HelpWriter = help);

            // Exercize system
            sut.ParseArguments<FakeOptionsWithTwoRequiredAndSets>(
                new[] { "--weburl=value.com", "--ftpurl=value.org" });
            var result = help.ToString();

            // Verify outcome
            result.Length.Should().BeGreaterThan(0);
            var lines = result.ToNotEmptyLines().TrimStringArray();
            lines[0].Should().StartWithEquivalent("CommandLine");
            lines[1].ShouldBeEquivalentTo("Copyright (c) 2005 - 2015 Giacomo Stelluti Scala");
            lines[2].ShouldBeEquivalentTo("ERROR(S):");
            lines[3].ShouldBeEquivalentTo("Option: 'weburl' is not compatible with: 'ftpurl'.");
            lines[4].ShouldBeEquivalentTo("Option: 'ftpurl' is not compatible with: 'weburl'.");
            lines[5].ShouldBeEquivalentTo("--weburl     Required.");
            lines[6].ShouldBeEquivalentTo("--ftpurl     Required.");
            lines[7].ShouldBeEquivalentTo("-a");
            lines[8].ShouldBeEquivalentTo("--help       Display this help screen.");
            lines[9].ShouldBeEquivalentTo("--version    Display version information.");
            // Teardown
        }
开发者ID:ekflame,项目名称:commandline,代码行数:26,代码来源:ParserTests.cs


示例4: Failed_verb_parsing_prints_particular_help_screen

        public void Failed_verb_parsing_prints_particular_help_screen()
        {
            string invokedVerb = null;
            object invokedVerbInstance = null;

            var options = new OptionsWithVerbsHelp();
            var testWriter = new StringWriter();
            ReflectionUtil.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new Parser(with => with.UseHelpWriter(testWriter));
            var result = parser.ParseArguments(new string[] { "clone", "--no_hardlinks" }, options,
                (verb, subOptions) =>
                    {
                        invokedVerb = verb;
                        invokedVerbInstance = subOptions;
                    });

            result.Should().BeFalse();

            var helpText = testWriter.ToString();
            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // Verify just significant output
            lines[5].Trim().Should().Be("--no-hardlinks    Optimize the cloning process from a repository on a local");
            lines[6].Trim().Should().Be("filesystem by copying files.");
            lines[7].Trim().Should().Be("-q, --quiet       Suppress summary message.");

            invokedVerb.Should().Be("clone");
            invokedVerbInstance.Should().Be(null);
        }
开发者ID:schallm,项目名称:commandline,代码行数:29,代码来源:VerbsHelpTextFixture.cs


示例5: GetPipeline

        public static PipelineNode GetPipeline(Parser theParser)
        {
            PipelineNode pipeline = null;

            if (theParser != null)
            {
                object objLeft = theParser.GetReductionSyntaxNode(0);
                object objRight = theParser.GetReductionSyntaxNode(2);

                if (objLeft is PipelineNode)
                {
                    pipeline = (PipelineNode)objLeft;
                    pipeline.AddItem(objRight as ASTNode);
                }
                else if (objRight is PipelineNode)
                {
                    pipeline = (PipelineNode)objRight;
                    pipeline.Insert(0, objLeft as ASTNode);
                }
            }

            if (pipeline == null)
            {
                pipeline = new PipelineNode(theParser);
                if (theParser != null)
                {
                    pipeline.AddItemFromParser(theParser, 0);
                    pipeline.AddItemFromParser(theParser, 2);
                }
            }

            return pipeline;
        }
开发者ID:JamesTryand,项目名称:pash,代码行数:33,代码来源:PipelineNode.cs


示例6: Rule

 public Rule(Parser parser, RuleType ruleType, Predicate<Parser> lookAhead, RuleDelegate evaluate)
 {
     _parser = parser;
     _ruleType = ruleType;
     _lookAhead = lookAhead;
     _evaluate = evaluate;
 }
开发者ID:Turbo87,项目名称:DGrok,代码行数:7,代码来源:Rule.cs


示例7: ElasticsearchOutput

        public ElasticsearchOutput(TimberWinR.Manager manager, Parser.ElasticsearchOutputParameters parameters, CancellationToken cancelToken)
            : base(cancelToken, "Elasticsearch")
        {
            _sentMessages = 0;
            _errorCount = 0;

            _parameters = parameters;
            _flushSize = parameters.FlushSize;
            _idleFlushTimeSeconds = parameters.IdleFlushTimeInSeconds;
            _protocol = parameters.Protocol;
            _timeout = parameters.Timeout;
            _manager = manager;
            _port = parameters.Port;
            _ssl = parameters.Ssl;
            _username = parameters.Username;
            _password = parameters.Password;
            _interval = parameters.Interval;
            _hosts = parameters.Host;
            _jsonQueue = new List<JObject>();
            _numThreads = parameters.NumThreads;
            _maxQueueSize = parameters.MaxQueueSize;
            _queueOverflowDiscardOldest = parameters.QueueOverflowDiscardOldest;
            _disablePing = !parameters.EnablePing;
            _pingTimeout = parameters.PingTimeout;

            for (int i = 0; i < parameters.NumThreads; i++)
            {
                Task.Factory.StartNew(ElasticsearchSender, cancelToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
            }
        }
开发者ID:bbqchickenrobot,项目名称:TimberWinR,代码行数:30,代码来源:Elasticsearch.cs


示例8: Module

        public void Module()
        {
            ModuleDeclaration moduleDeclaration = new Parser().Module(new Lexer("module Something 1.2.3 { }"));
            Assert.IsNotNull(moduleDeclaration);
            Assert.AreEqual("Something", moduleDeclaration.Name.ToString());
            Assert.IsNotNull(moduleDeclaration.Members);
            Assert.IsFalse(moduleDeclaration.Members.Any());
            Assert.AreEqual(moduleDeclaration.Version, Version.Parse("1.2.3"));

            moduleDeclaration = new Parser().Module(new Lexer("module Something 1.2.0 { a: Int32 }"));
            Assert.IsNotNull(moduleDeclaration);
            Assert.AreEqual("Something", moduleDeclaration.Name.ToString());
            Assert.AreEqual(moduleDeclaration.Version, Version.Parse("1.2.0"));
            Assert.IsNotNull(moduleDeclaration.Members);
            Assert.AreEqual(1, moduleDeclaration.Members.Count);
            Assert.AreEqual("a", moduleDeclaration.Members[0].Name.Components[0]);

            moduleDeclaration = new Parser().Module(new Lexer(@" module Something 1.0.0
            {
                    a: Int32
                    b: const 5
            }"));
            Assert.IsNotNull(moduleDeclaration);
            Assert.AreEqual("Something", moduleDeclaration.Name.ToString());
            Assert.AreEqual(moduleDeclaration.Version, Version.Parse("1.0.0"));
            Assert.IsNotNull(moduleDeclaration.Members);
            Assert.AreEqual(2, moduleDeclaration.Members.Count);
            Assert.AreEqual("a", moduleDeclaration.Members[0].Name.ToString());
            Assert.AreEqual("b", moduleDeclaration.Members[1].Name.ToString());
        }
开发者ID:Ancestry,项目名称:DotQL,代码行数:30,代码来源:ParserTests.cs


示例9: Identifier

 /// <summary>
 /// Parser for identifier starting with <paramref name="firstLetterParser"/> and continuing with <paramref name="tailLetterParser"/>
 /// </summary>
 public static Parser<string> Identifier(Parser<char> firstLetterParser, Parser<char> tailLetterParser)
 {
     return
         from firstLetter in firstLetterParser
         from tail in tailLetterParser.Many().Text()
         select firstLetter + tail;
 }
开发者ID:kentcb,项目名称:Sprache,代码行数:10,代码来源:Parse.Primitives.cs


示例10: Main

        private static void Main(string[] args)
        {
            /*
            if (args.Length != 1)
                exit("Usage: Simplecalc.exe filename");
            */
            using (StreamReader sr = new StreamReader(File.Open("test", FileMode.Open)))
            {
                // Read source
                Lexer lexer = new Lexer(sr);

                // Parse source
                Parser parser = new Parser(lexer);
                Start ast = null;

                try
                {
                    ast = parser.Parse();
                }
                catch (Exception ex)
                {
                    exit(ex.ToString());
                }

                // Print tree
                SimplePrinter printer = new SimplePrinter(true, ConsoleColor.White, ConsoleColor.Gray, ConsoleColor.Red, ConsoleColor.Blue);
                ast.Apply(printer);
            }

            exit("Done");
        }
开发者ID:stufkan,项目名称:SableEditor,代码行数:31,代码来源:Program.cs


示例11: CreateCombatLog

 public static CombatLog CreateCombatLog(string combatLog)
 {
     string hash = ComputeHash(combatLog);
     var logParser = new Parser();
     var log = logParser.Parse(new StringReader(combatLog));
     return CreateCombatLog(hash, log);
 }
开发者ID:dominiqueplante,项目名称:SWTOR.Parser,代码行数:7,代码来源:CombatLog.cs


示例12: Functions

        public void Functions()
        {
            var parser = new Parser(new Scanner("../../sources/for_unit_tests/functions.exs"));
            parser.DoPostParseProcessing = true;
            parser.Parse();

            var ast = parser.TopmostAst;
            var options = new ExpressoCompilerOptions{
                LibraryPaths = new List<string>{""},
                OutputPath = "../../test_executable",
                BuildType = BuildType.Debug | BuildType.Executable
            };
            var emitter = new CSharpEmitter(parser, options);
            ast.AcceptWalker(emitter, null);

            var asm = emitter.AssemblyBuilder;
            var main_method = asm.GetModule("main.exe")
                .GetType("ExsMain")
                .GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Static);
            Assert.AreEqual(main_method.Name, "Main");
            Assert.IsTrue(main_method.IsStatic);
            Assert.AreEqual(typeof(int), main_method.ReturnType);
            Assert.AreEqual(0, main_method.GetParameters().Length);
            //Assert.IsTrue(main_method.GetParameters().SequenceEqual(new []{typeof(string[])}));
            Console.Out.WriteLine("テスト実行");
            Console.Out.WriteLine(main_method.ToString());

            //main_method.Invoke(null, new object[]{});
        }
开发者ID:hazama-yuinyan,项目名称:Expresso,代码行数:29,代码来源:EmitterTests.cs


示例13: btnStart_Click

        private async void btnStart_Click(object sender, EventArgs e)
        {
            pbMain.Value = 0;

            var parser = new Parser(txtThread.Text);
            if (!parser.IsValid())
                return;

            ToggleGroupBoxes(false);
            TitleBuilder.Build(this, "Initializing");

            var threadData = await parser.BuildThreadData();
            var scraper = new Scraper(threadData, UpdateProgress);

            var files = await scraper.CollectFileURLs(cbWEBM.Checked, cbDuplicates.Checked);
            if (files == null)
                return;

            pbMain.Maximum = files.Count;

            await Task.WhenAll(files.Select(p => scraper.DownloadFileAsync(this, p, rbUID.Checked, txtPath.Text)));

            ToggleGroupBoxes(true);
            TitleBuilder.Build(this, "Completed", false);
        }
开发者ID:PavilionVI,项目名称:4chan-Scraper,代码行数:25,代码来源:frmMain.cs


示例14: ParseContext

        public ParseContext(ParseContext parent, Parser parser)
            : this(parent.Input, -1)
        {
            Parent = parent;
            Parser = parser;

            WhitespacePolicy = parent.WhitespacePolicy;

            var wsRule = parser as WhitespaceRuleParser;
            if (wsRule != null)
            {
                _whitespaceParsers = new HashSet<Parser>(parent._whitespaceParsers ?? Enumerable.Empty<Parser>())
                {
                    wsRule.WhitespaceParser
                };
            }
            else
            {
                _whitespaceParsers = parent._whitespaceParsers;
            }

            var policy = parser as WhitespacePolicyParser;
            if (policy != null) WhitespacePolicy = policy.Policy;

            InitialOffset = Offset = parent.WhitespacePolicy == WhitespacePolicy.Ignore
                ? SkipWhitespace(parent.Input, parent.Offset) : parent.Offset;
        }
开发者ID:Metapyziks,项目名称:ParseSharp,代码行数:27,代码来源:ParseContext.cs


示例15: GetParamsList

        public static ParamsListNode GetParamsList(Parser theParser)
        {
            ParamsListNode paramsList = null;

            if (theParser != null)
            {
                object objLeft = theParser.GetReductionSyntaxNode(0);
                object objRight = theParser.GetReductionSyntaxNode(1);

                if (objLeft is ParamsListNode)
                {
                    paramsList = (ParamsListNode)objLeft;
                    paramsList.AddParam(objRight);
                }
                else if (objRight is ParamsListNode)
                {
                    paramsList = (ParamsListNode)objRight;
                    paramsList.Insert(0, objLeft);
                }
            }

            if (paramsList == null)
            {
                paramsList = new ParamsListNode(theParser);

                if (theParser != null)
                {
                    paramsList.AddParamFromParser(theParser, 0);
                    paramsList.AddParamFromParser(theParser, 1);
                }
            }

            return paramsList;
        }
开发者ID:JamesTryand,项目名称:pash,代码行数:34,代码来源:ParamsListNode.cs


示例16: Create

        /// <summary>
        /// Reads a directive node.
        /// </summary>
        /// <param name="parser">The parser to read the directive node from.</param>
        /// <returns>The directive node.</returns>
        /// <exception cref="BadDataException">Read an invalid directive.</exception>
        /// <exception cref="MissingDataException">Closing directive node was missing.</exception>
        public static DirectiveNode Create(Parser parser)
        {
            var startLocation = parser.InputReader.Location.Clone();
            string line = parser.InputReader.ReadLine();

            foreach(var type in GetDirectiveTypes()) {
                foreach(var attr in type.GetCustomAttributes(typeof(DirectiveAttribute), true).OfType<DirectiveAttribute>()) {
                    var info = ParseDirectiveLine(parser, attr.NameExpression, line, startLocation);

                    if(info == null) {
                        continue;
                    }

                    using(info.ParametersReader) {
                        var node = CreateInstance(type, info);

                        if(node == null) {
                            continue;
                        }

                        node.ReadSubNodes(parser);

                        return node;
                    }
                }
            }

            throw new BadDataException("Unknown directive " + line, startLocation);
        }
开发者ID:peppy,项目名称:osq2osb,代码行数:36,代码来源:DirectiveNode.cs


示例17: HandleInitialSpells

        public void HandleInitialSpells(Parser packet)
        {
            ReadByte("Talent Spec");

            var spellsCount = Reader.ReadUInt16();
            AppendFormatLine("Spells count: {0}", spellsCount);

            for (var i = 0; i < spellsCount; ++i)
            {
                UInt32("SpellID");
                UInt16("slot");
            }

            var cooldownsCount = Reader.ReadUInt16();
            AppendFormatLine("Cooldowns count: {0}", cooldownsCount);

            for (var i = 0; i < cooldownsCount; ++i)
            {
                UInt32("spellId");
                UInt16("itemId");
                UInt32("category");
                UInt32("time1");
                UInt32("time2");
            }
        }
开发者ID:Gintama,项目名称:VoragineTools,代码行数:25,代码来源:SpellHandler.cs


示例18: HandleGuildBankUpdateTab

 public void HandleGuildBankUpdateTab(Parser packet)
 {
     UInt64("Guid)");
     CString("TabID");
     CString("Name");
     CString("Icon");
 }
开发者ID:Gintama,项目名称:VoragineTools,代码行数:7,代码来源:GuildHandler.cs


示例19: GenerateTest

 public void GenerateTest()
 {
     Assert.Inconclusive("TBA");
     //	#	Arrange.
     var sut = new Parser();
     sut.Generate();
 }
开发者ID:LosManos,项目名称:St4mpede,代码行数:7,代码来源:ParserTest.cs


示例20: UriTemplate

 public UriTemplate(string uriTemplate)
 {
     this.uriTemplate = uriTemplate;
     Parser parser = new Parser(uriTemplate);
     this.variableNames = parser.GetVariableNames();
     this.matchRegex = parser.GetMatchRegex();
 }
开发者ID:lite,项目名称:yebob_wp,代码行数:7,代码来源:UriTemplate.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ParserContext类代码示例发布时间:2022-05-24
下一篇:
C# ParsedDocument类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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