本文整理汇总了C#中Integer32类的典型用法代码示例。如果您正苦于以下问题:C# Integer32类的具体用法?C# Integer32怎么用?C# Integer32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Integer32类属于命名空间,在下文中一共展示了Integer32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Header
/// <summary>
/// Initializes a new instance of the <see cref="Header"/> class.
/// </summary>
/// <param name="messageId">The message id.</param>
/// <param name="maxMessageSize">Size of the max message.</param>
/// <param name="securityBits">The flags.</param>
/// <param name="securityModel">The security model.</param>
/// <remarks>If you want an empty header, please use <see cref="Empty"/>.</remarks>
public Header(Integer32 messageId, Integer32 maxMessageSize, OctetString securityBits, Integer32 securityModel)
{
if (messageId == null)
{
throw new ArgumentNullException("messageId");
}
if (maxMessageSize == null)
{
throw new ArgumentNullException("maxMessageSize");
}
if (securityBits == null)
{
throw new ArgumentNullException("securityBits");
}
if (securityModel == null)
{
throw new ArgumentNullException("securityModel");
}
_messageId = messageId;
_maxSize = maxMessageSize;
_flags = securityBits;
_securityModel = securityModel;
}
示例2: SetRequestPdu
/// <summary>
/// Creates a <see cref="SetRequestPdu"/> instance with all contents.
/// </summary>
/// <param name="requestId">The request id.</param>
/// <param name="errorStatus">Error status</param>
/// <param name="errorIndex">Error index</param>
/// <param name="variables">Variables</param>
private SetRequestPdu(Integer32 requestId, Integer32 errorStatus, Integer32 errorIndex, IList<Variable> variables)
{
RequestId = requestId;
ErrorStatus = errorStatus;
ErrorIndex = errorIndex;
Variables = variables;
_varbindSection = Variable.Transform(Variables);
}
示例3: InformRequestPdu
/// <summary>
/// Creates a <see cref="InformRequestPdu"/> instance for discovery.
/// </summary>
/// <param name="requestId">The request id.</param>
public InformRequestPdu(int requestId)
{
Enterprise = null;
RequestId = new Integer32(requestId);
_time = new TimeTicks(0);
Variables = new List<Variable>();
_varbindSection = Variable.Transform(Variables);
}
示例4: GetRequestPdu
public GetRequestPdu(int requestId, ErrorCode errorStatus, int errorIndex, IList<Variable> variables)
{
RequestId = new Integer32(requestId);
ErrorStatus = new Integer32((int)errorStatus);
ErrorIndex = new Integer32(errorIndex);
Variables = variables;
_varbindSection = Variable.Transform(variables);
}
示例5: TestNegative2
public void TestNegative2()
{
// bug 7217 http://sharpsnmplib.codeplex.com/workitem/7217
Integer32 i = new Integer32(-250);
var result = DataFactory.CreateSnmpData(i.ToBytes());
Assert.AreEqual(SnmpType.Integer32, result.TypeCode);
Assert.AreEqual(-250, ((Integer32)result).ToInt32());
}
示例6: TestNegative
public void TestNegative()
{
const int i = -2147418240;
Integer32 data = new Integer32(i);
byte[] bytes = data.ToBytes();
Integer32 other = (Integer32)DataFactory.CreateSnmpData(bytes);
Assert.AreEqual(i, other.ToInt32());
}
示例7: ResponsePdu
/// <summary>
/// Creates a <see cref="ResponsePdu"/> with all contents.
/// </summary>
/// <param name="requestId">The request ID.</param>
/// <param name="errorStatus">Error status.</param>
/// <param name="errorIndex">Error index.</param>
/// <param name="variables">Variables.</param>
public ResponsePdu(int requestId, ErrorCode errorStatus, int errorIndex, IList<Variable> variables)
{
RequestId = new Integer32(requestId);
ErrorStatus = new Integer32((int)errorStatus);
ErrorIndex = new Integer32(errorIndex);
Variables = variables;
_varbindSection = Variable.Transform(variables);
////_raw = ByteTool.ParseItems(_sequenceNumber, _errorStatus, _errorIndex, _varbindSection);
}
示例8: TestToInt32
public void TestToInt32()
{
const int result = -26955;
byte[] expected = new byte[] {0x96, 0xB5};
Integer32 test = new Integer32(expected);
Assert.AreEqual(result, test.ToInt32());
Assert.AreEqual(255, new Integer32(new byte[] {0x00, 0xFF}).ToInt32());
}
示例9: GetNextRequestPdu
private GetNextRequestPdu(Integer32 requestId, Integer32 errorStatus, Integer32 errorIndex, IList<Variable> variables)
{
RequestId = requestId;
ErrorStatus = errorStatus;
ErrorIndex = errorIndex;
Variables = variables;
_varbindSection = Variable.Transform(variables);
////_raw = ByteTool.ParseItems(_seq, _errorStatus, _errorIndex, _varbindSection);
}
示例10: GetBulkRequestPdu
private GetBulkRequestPdu(Integer32 requestId, Integer32 nonRepeaters, Integer32 maxRepetitions, IList<Variable> variables)
{
RequestId = requestId;
ErrorStatus = nonRepeaters;
ErrorIndex = maxRepetitions;
Variables = variables;
_varbindSection = Variable.Transform(variables);
////_raw = ByteTool.ParseItems(_seq, _nonRepeaters, _maxRepetitions, _varbindSection);
}
示例11: TestNegative3
public void TestNegative3()
{
// #7240
const int i = -237053658;
Integer32 data = new Integer32(i);
byte[] bytes = data.ToBytes();
Assert.AreEqual(6, bytes.Length);
var exception = Assert.Throws<ArgumentException>(() => DataFactory.CreateSnmpData(new byte[] { 0x02, 0x05, 0xFF, 0xF1, 0xDE, 0xD9, 0x26 }));
Assert.AreEqual("truncation error for 32-bit integer coding\r\nParameter name: length", exception.Message);
}
示例12: TestToBytes
public void TestToBytes()
{
byte[] bytes = new byte[] {0x02, 0x02, 0x96, 0xB5};
Integer32 test = new Integer32(-26955);
Assert.AreEqual(bytes, test.ToBytes());
Assert.AreEqual(new byte[] {0x02, 0x02, 0x00, 0xFF}, new Integer32(255).ToBytes());
Assert.AreEqual(6, new Integer32(2147483647).ToBytes().Length);
}
示例13: TrapPdu
/// <summary>Constructor</summary>
public TrapPdu()
{
_asnType = (byte)PduType.Trap;
_enterprise = new Oid();
_agentAddr = new IpAddress();
_generic = new Integer32();
_specific = new Integer32();
_timeStamp = new TimeTicks();
_variables = new VbCollection();
}
示例14: TestConstructor
public void TestConstructor()
{
Integer32 test = new Integer32(100);
Assert.AreEqual(100, test.ToInt32());
Integer32 test2 = new Integer32(new byte[] {0x00});
Assert.AreEqual(0, test2.ToInt32());
Integer32 test3 = new Integer32(new byte[] {0xFF});
Assert.AreEqual(-1, test3.ToInt32());
}
示例15: TrapV2Pdu
public TrapV2Pdu(int requestId, ObjectIdentifier enterprise, uint time, IList<Variable> variables)
{
Enterprise = enterprise;
RequestId = new Integer32(requestId);
_time = new TimeTicks(time);
Variables = variables;
IList<Variable> full = new List<Variable>(variables);
full.Insert(0, new Variable(new uint[] { 1, 3, 6, 1, 2, 1, 1, 3, 0 }, _time));
full.Insert(1, new Variable(new uint[] { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }, Enterprise));
_varbindSection = Variable.Transform(full);
}