本文整理汇总了C#中Oid.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Oid.ToString方法的具体用法?C# Oid.ToString怎么用?C# Oid.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oid
的用法示例。
在下文中一共展示了Oid.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDecode
public void TestDecode()
{
const string hex = "4a7067c30a57000000008ecb";
var oid = new Oid(hex);
Assert.AreEqual(hex, oid.ToString());
}
示例2: GetNext
public void GetNext(Oid Ooid)
{
//we return the next so we "translate" the mib returns from the Get method
switch (Ooid.ToString())
{
case "1.3.2.5":
responsePacket.Pdu.VbList.Add(Ooid, new Counter32(metalGear.sysUpTime));
Debug.Log("SysUp request");
break;
case "1.3.2.5.1":
responsePacket.Pdu.VbList.Add(Ooid, new OctetString(metalGear.location));
Debug.Log("location request");
break;
case "1.3.2.5.2":
responsePacket.Pdu.VbList.Add(Ooid, new Counter32((uint)metalGear.moveToX));
Debug.Log("moveX request");
break;
case "1.3.2.5.3":
responsePacket.Pdu.VbList.Add(Ooid, new Counter32((uint)metalGear.moveToY));
Debug.Log("moveY request");
break;
case "1.3.2.5.4":
responsePacket.Pdu.VbList.Add(Ooid, new Counter32((uint)metalGear.lookAt));
Debug.Log("LookAt request");
break;
// -------------------------------------------- Weapon Table --------------------//
#region weapon table
case "1.3.2.5.6":
case "1.3.2.5.6.1":
responsePacket.Pdu.VbList.Add(Ooid, new Integer32(metalGear.machineGunAmmo));
Debug.Log("MG Ammo request");
break;
case "1.3.2.5.6.1.1":
responsePacket.Pdu.VbList.Add(Ooid, new Integer32(metalGear.machineGunDamage));
Debug.Log("MG Damage request");
break;
case "1.3.2.5.6.2":
responsePacket.Pdu.VbList.Add(Ooid, new Integer32(metalGear.missileLauncherAmmo));
Debug.Log("Missiles Ammo request");
break;
case "1.3.2.5.6.2.1":
responsePacket.Pdu.VbList.Add(Ooid, new Integer32(metalGear.missileLauncherDamage));
Debug.Log("Missiles Damage request");
break;
case "1.3.2.5.6.3":
responsePacket.Pdu.VbList.Add(Ooid, new Integer32(metalGear.railGunAmmo));
Debug.Log("Railgun Ammo request");
break;
case "1.3.2.5.6.3.1":
responsePacket.Pdu.VbList.Add(Ooid, new Integer32(metalGear.railGunDamage));
Debug.Log("Railgun Damage request");
break;
#endregion
// -------------------------------------------- Weapon Table END --------------------//
case "1.3.2.5.6.3.2":
responsePacket.Pdu.VbList.Add(Ooid, new Counter32((uint)metalGear.nukeState));
Debug.Log("nukeState request");
break;
case "1.3.2.5.7":
responsePacket.Pdu.VbList.Add(Ooid, new Counter32((uint)metalGear.nukeCounter));
Debug.Log("nukeLaunch request");
break;
// -------------------------------------------- enemies Table --------------------//
#region enemies table
case "1.3.2.5.8":
case "1.3.2.5.9":
// -------------------------------------------- --------------------//
case "1.3.2.5.9.1":
Debug.Log("HEERE enemy 1");
//in here we have to return the next node of the mib if it isnt outside of the mib root
if (metalGear.targetSize.Count <= 0)
{
if(Ooid.ToString().CompareTo("1.3.2.5.9.1") == 1){
Debug.Log("Wroing OID");
responsePacket.Pdu.ErrorStatus = 1; // error
break;
}
responsePacket.Pdu.VbList.Add(Ooid, new Counter32((uint)metalGear.radarState));
break;
}
responsePacket.Pdu.VbList.Add(Ooid, new OctetString("X:" + metalGear.positionXEnemies[0].ToString() + "Y:" + metalGear.positionYEnemies[0].ToString()));
Debug.Log("radarTable enemy positionrequest");
break;
case "1.3.2.5.9.1.1":
if (metalGear.targetSize.Count <= 0)
{
Debug.Log("Wroing OID");
responsePacket.Pdu.ErrorStatus = 1; // error
break;
}
//.........这里部分代码省略.........
示例3: ProcessSetRequest
/// <summary>
/// Process a received SNMP SetRequest
/// </summary>
/// <param name="Ooid"></param>
/// <param name="valuePair"></param>
public void ProcessSetRequest(Oid Ooid, Vb valuePair)
{
switch (Ooid.ToString())
{
case "1.3.2.5.1":
Debug.Log("SysUp set request -- error read only");
break;
case "1.3.2.5.2":
Debug.Log("location set request -- error read only");
break;
case "1.3.2.5.3":
metalGear.moveToX = int.Parse(valuePair.Value.ToString());
Debug.Log("moveX set request");
break;
case "1.3.2.5.4":
metalGear.moveToY = int.Parse(valuePair.Value.ToString());
Debug.Log("moveY set request");
break;
case "1.3.2.5.5":
metalGear.lookAt = (uint)int.Parse(valuePair.Value.ToString());
Debug.Log("LookAt set request");
break;
/*case "1.3.2.5.6":
Debug.Log("weapontable request");
break;
*/
case "1.3.2.5.7":
Debug.Log("nukeState set request --read only");
break;
case "1.3.2.5.8":
Debug.Log("nukeLaunch set request --read only");
break;
case "1.3.2.5.9":
Debug.Log("radarTable request");
break;
case "1.3.2.5.10":
Debug.Log("radarState set request --read only");
break;
case "1.3.2.5.11":
Debug.Log("cameraTable request");
break;
case "1.3.2.5.12":
metalGear.selectedCamera = (uint)int.Parse(valuePair.Value.ToString());
Debug.Log("selectedCamera request");
break;
case "1.3.2.5.13":
Debug.Log("bodyTable request");
break;
case "1.3.2.5.14":
metalGear.selectedTarget = int.Parse(valuePair.Value.ToString());
Debug.Log("selectedTarget set request");
break;
case "1.3.2.5.15":
metalGear.selectdGun = int.Parse(valuePair.Value.ToString());
Debug.Log("selectedGun set request");
break;
case "1.3.2.5.16":
metalGear.attacking = int.Parse(valuePair.Value.ToString());
Debug.Log("attacking request");
break;
case "1.3.2.5.17":
Debug.Log("under attacking set request error - read only");
break;
default:
Debug.Log("Wroing OID");
responsePacket.Pdu.ErrorStatus = 1; // no error
break;
}
}
示例4: TestFormatJ
public void TestFormatJ()
{
const string hex = "4a7067c30a57000000008ecb";
var oid = new Oid(hex);
Assert.AreEqual("\"" + hex + "\"", oid.ToString("J"));
}
示例5: TestQuoteCharacters
public void TestQuoteCharacters()
{
var val = new Oid(@"""4a7067c30a57000000008ecb""");
try
{
new Oid(val.ToString());
}
catch(ArgumentException)
{
Assert.Fail("Creating an Oid from the json representation should not fail.");
}
}
示例6: TestNewOidFromToString
public void TestNewOidFromToString()
{
const string hex = "4B458B95D114BE541B000000";
var firstOid = new Oid(hex);
var secondOid = new Oid(firstOid.ToString());
Assert.AreEqual(firstOid.ToString(), secondOid.ToString());
}