55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
// /**
|
|
// * File: OctetString.cs
|
|
// * Author: haraldwolff
|
|
// *
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
// *
|
|
// *
|
|
// **/
|
|
using System;
|
|
using System.Text;
|
|
namespace ln.snmp.types
|
|
{
|
|
public class OctetString : Variable
|
|
{
|
|
public string StringValue { get; set; }
|
|
|
|
public OctetString()
|
|
:base(new Identifier(IdentifierClass.UNIVERSAL, false, 4))
|
|
{
|
|
}
|
|
|
|
public OctetString(String text)
|
|
:this()
|
|
{
|
|
StringValue = text;
|
|
}
|
|
|
|
public override byte[] Bytes {
|
|
get => Encoding.UTF8.GetBytes(StringValue);
|
|
set => StringValue = Encoding.UTF8.GetString(value);
|
|
}
|
|
public override object Value {
|
|
get => StringValue;
|
|
set => StringValue = value as string;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return String.Format("[OctetString StringValue={0}]", StringValue);
|
|
}
|
|
|
|
public static implicit operator String(OctetString octetString)
|
|
{
|
|
return octetString.StringValue;
|
|
}
|
|
|
|
public static implicit operator OctetString(String text)
|
|
{
|
|
return new OctetString(text);
|
|
}
|
|
|
|
}
|
|
}
|