本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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); });
}
示例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]);
}
示例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]);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}