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


C# Parser类代码示例

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


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


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