public override void Encode(Asn1BerOutputStream outs, bool explicitTagging) { int num; if (((Value.Length < 2) || (Value[0] > 2)) || ((Value[0] != 2) && (Value[1] > 0x27))) { throw new Exception("Asn1InvalidObjectIdException"); } var len = 1; for (num = 2; num < Value.Length; num++) { len += Asn1RunTime.GetIdentBytesCount(Value[num]); } if (explicitTagging) { outs.EncodeTag(Tag); } outs.EncodeLength(len); var ident = (Value[0] * 40) + Value[1]; outs.EncodeIdentifier(ident); for (num = 2; num < Value.Length; num++) { outs.EncodeIdentifier(Value[num]); } }
public override void Encode(Asn1BerOutputStream outs, bool explicitTagging) { var bytes = Encoding.UTF8.GetBytes(Value); if (explicitTagging) { outs.EncodeTag(Tag); } outs.EncodeLength(bytes.Length); outs.Write(bytes); }
public override void Encode(Asn1BerOutputStream outs, bool explicitTagging) { if (explicitTagging) { outs.EncodeTag(Tag); } if (Value == 0.0) { outs.EncodeLength(0); } else if (Value == double.NegativeInfinity) { outs.EncodeIntValue(MinusInfinity, true); } else if (Value == double.PositiveInfinity) { outs.EncodeIntValue(PlusInfinity, true); } else { var len = 1; var num2 = BitConverter.DoubleToInt64Bits(Value); var num3 = ((num2 >> RealIso6093Mask) == 0L) ? 1 : -1; var num4 = ((int)((num2 >> 0x34) & 0x7ffL)) - 0x433; var w = (num4 == 0) ? ((num2 & 0xfffffffffffffL) << 1) : ((num2 & 0xfffffffffffffL) | 0x10000000000000L); if (w != 0L) { var bits = TrailingZerosCnt(w); w = Asn1Util.UrShift(w, bits); num4 += bits; len += Asn1Util.GetUlongBytesCount(w); } else { len++; } var num7 = RealBinary; if (num3 == -1) { num7 |= PlusInfinity; } var bytesCount = Asn1Util.GetBytesCount(num4); len += bytesCount; switch (bytesCount) { case RealExplen2: break; case RealExplen3: num7 |= 1; break; case RealExplenLong: num7 |= 2; break; default: num7 |= 3; len++; break; } outs.EncodeLength(len); outs.WriteByte((byte)num7); if ((num7 & 3) == 3) { outs.EncodeIntValue(bytesCount, false); } outs.EncodeIntValue(num4, false); outs.EncodeIntValue(w, false); } }