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


C# Lexer.Parse方法代码示例

本文整理汇总了C#中Lextm.SharpSnmpLib.Mib.Lexer.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.Parse方法的具体用法?C# Lexer.Parse怎么用?C# Lexer.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lextm.SharpSnmpLib.Mib.Lexer的用法示例。


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

示例1: TestParse3

 public void TestParse3()
 {
     const string test = "::=BEGIN";
     Lexer lexer = new Lexer();
     StringReader reader = new StringReader(test);
     lexer.Parse(reader);
     Assert.AreEqual("::=", lexer.NextSymbol.ToString());
     Assert.AreEqual("BEGIN", lexer.NextSymbol.ToString());
 }       
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:9,代码来源:TestLexer.cs

示例2: TestMethod

 public void TestMethod()
 {
     Lexer lexer = new Lexer();
     lexer.Parse(new StringReader("{ iso org(3) dod(6) 1 }"));
     string parent;
     uint value;
     lexer.ParseOidValue(out parent, out value);
     Assert.AreEqual("iso.org(3).dod(6)", parent);
     Assert.AreEqual(1, value);
 }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:10,代码来源:TestConstructHelper.cs

示例3: TestParse

 public void TestParse()
 {
     Lexer lexer = new Lexer();
     MemoryStream m = new MemoryStream(Resources.SNMPv2_SMI);
     using (StreamReader reader = new StreamReader(m))
     {
         lexer.Parse(reader);
         reader.Close();
     }
     Assert.AreEqual(909, lexer.SymbolCount);
 }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:11,代码来源:TestLexer.cs

示例4: TestMethod1

        public void TestMethod1()
        {
            Lexer lexer = new Lexer();
            lexer.Parse(new StringReader("{ iso(1) std(0) iso8802(8802) ieee802dot1(1)" + Environment.NewLine +
"     ieee802dot1mibs(1) 1 }"));
            string parent;
            uint value;
            lexer.ParseOidValue(out parent, out value);
            Assert.AreEqual("iso(1).std(0).iso8802(8802).ieee802dot1(1).ieee802dot1mibs(1)", parent);
            Assert.AreEqual(1, value);
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:11,代码来源:TestConstructHelper.cs

示例5: TestException

        public void TestException()
        {
            Lexer lexer = new Lexer();
            MemoryStream m = new MemoryStream(Resources.fivevarbinds);
            using (StreamReader reader = new StreamReader(m))
            {
                lexer.Parse("temp.txt", reader);
                reader.Close();
            }

            new MibDocument(lexer);
        }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:12,代码来源:TestMibDocument.cs

示例6: TestOverlappingRanges3

        public void TestOverlappingRanges3()
        {
            const string test = "SomeEnum ::= INTEGER (8 | 8 | 31 .. 60 )";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Integer);

            Assert.Throws<MibException>(() => new IntegerType("module", "name", lexer));
        }
开发者ID:bleissem,项目名称:sharpsnmplib,代码行数:12,代码来源:TestIntegerType.cs

示例7: Test

        public void Test()
        {
            const string test = "SomeIp ::= IpAddress";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.IpAddress);

            IpAddressType i = new IpAddressType("module", "name", lexer);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:12,代码来源:TestIpAddressType.cs

示例8: TestEnumerable

        public void TestEnumerable()
        {
            const string test = "SomeEnum ::= Counter64";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Counter64);

            Counter64Type i = new Counter64Type("module", "name", lexer);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:12,代码来源:TestCounter64Type.cs

示例9: TestNegative

        public void TestNegative()
        {
            const string test = "SomeEnum ::= OCTET STRING ( SIZE (8 | -5 .. 20 | 31 .. 60 ))";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Octet);
            lexer.GetNextSymbol().Expect(Symbol.String);

            Assert.Throws<MibException>(delegate { new OctetStringType("module", "name", lexer); });
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:13,代码来源:TestOctetStringType.cs

示例10: Test

        public void Test()
        {
            const string test = "SomeEnum ::= BITS {first(1), second(2)}";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Bits);

            BitsType i = new BitsType("module", "name", lexer);
            Assert.AreEqual("first(1)", i[1]);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:13,代码来源:TestBitsType.cs

示例11: TestEnumerable

        public void TestEnumerable()
        {
            const string test = "SomeEnum ::= INTEGER {first(1), second(2)}";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Integer);

            IntegerType i = new IntegerType("module", "name", lexer);
            Assert.IsTrue(i.IsEnumeration);
            Assert.AreEqual("first(1)", i[1]);
        }
开发者ID:bleissem,项目名称:sharpsnmplib,代码行数:14,代码来源:TestIntegerType.cs

示例12: TestEmpty

 public void TestEmpty()
 {
     // issue 4978
     Lexer lexer = new Lexer();
     MemoryStream m = new MemoryStream(Resources.empty);
     using (StreamReader reader = new StreamReader(m))
     {
         lexer.Parse(reader);
         reader.Close();
     }
     MibDocument file = new MibDocument(lexer);
     Assert.AreEqual("SNMPV2-CONF", file.Modules[0].Name);
     Assert.AreEqual(0, file.Modules[0].Dependents.Count);
     Assert.AreEqual(0, file.Modules[0].Entities.Count);
 }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:15,代码来源:TestMibDocument.cs

示例13: TestHttpMib

        public void TestHttpMib()
        {
            // issue 4978
            Lexer lexer = new Lexer();
            MemoryStream m = new MemoryStream(Resources.httpmib);
            using (StreamReader reader = new StreamReader(m))
            {
                lexer.Parse(reader);
                reader.Close();
            }

            MibDocument file = new MibDocument(lexer);
            Assert.AreEqual("HTTPSERVER-MIB", file.Modules[0].Name);
            Assert.AreEqual(0, file.Modules[0].Dependents.Count);
            Assert.AreEqual(0, file.Modules[0].Entities.Count);
        }        
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:16,代码来源:TestMibDocument.cs

示例14: TestSNMPv2_PDU

 // TODO: [Test]
 public void TestSNMPv2_PDU()
 {
     Lexer lexer = new Lexer();
     MemoryStream m = new MemoryStream(Resources.SNMPV2_PDU);
     using (StreamReader reader = new StreamReader(m))
     {
         lexer.Parse(reader);
         reader.Close();
     }
     MibDocument file = new MibDocument(lexer);
     Assert.AreEqual("SNMPv2-PDU", file.Modules[0].Name);
     Assert.AreEqual(5, file.Modules[0].Dependents.Count);
     Assert.AreEqual(55, file.Modules[0].Entities.Count);
     IEntity node = file.Modules[0].Entities[54];
     Assert.AreEqual("casConfigGroup", node.Name);
     Assert.AreEqual(2, node.Value);
     Assert.AreEqual("casMIBGroups", node.Parent);
 }
开发者ID:moljac,项目名称:MonoMobile.SharpSNMP,代码行数:19,代码来源:TestMibDocument.cs

示例15: TestRanges

        public void TestRanges()
        {
            const string test = "SomeEnum ::= INTEGER (8 |10 ..20| 31..60 )";
            Lexer lexer = new Lexer();
            StringReader reader = new StringReader(test);
            lexer.Parse(reader);
            string name = lexer.GetNextSymbol().ToString();
            lexer.GetNextSymbol().Expect(Symbol.Assign);
            lexer.GetNextSymbol().Expect(Symbol.Integer);

            IntegerType i = new IntegerType("module", "name", lexer);
            Assert.IsFalse(i.IsEnumeration);
            Assert.IsTrue(i.Contains(8));
            Assert.IsTrue(i.Contains(10));
            Assert.IsTrue(i.Contains(15));
            Assert.IsTrue(i.Contains(20));
            Assert.IsTrue(i.Contains(35));
            Assert.IsFalse(i.Contains(4));
            Assert.IsFalse(i.Contains(-9));
            Assert.IsFalse(i.Contains(25));
            Assert.IsFalse(i.Contains(61));
        }
开发者ID:bleissem,项目名称:sharpsnmplib,代码行数:22,代码来源:TestIntegerType.cs


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