public LdapMessage( BigInteger messageId, IProtocolOp protocolOp ) { MessageId = messageId; ProtocolOp = protocolOp; }
private void PopulateOperationTypeMapper() { IEnumerable <Type> types = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsClass where typeof(IProtocolOp).IsAssignableFrom(t) select t; types.ToList().ForEach(t => { IProtocolOp protocolOp = (IProtocolOp)FormatterServices.GetUninitializedObject(t); int tag = protocolOp.GetTag(); OperationTypeMapper.Add(tag, t); }); }
public LdapMessage TryParsePacket(byte[] input) { AsnReader reader = new AsnReader(input, AsnEncodingRules.BER); AsnReader sequenceReader = reader.ReadSequence(); BigInteger messageId = sequenceReader.ReadInteger(); TagClass tagClass = sequenceReader.PeekTag().TagClass; int tagValue = sequenceReader.PeekTag().TagValue; if (tagClass != TagClass.Application) { throw new ArgumentException("Input type is expected to be " + TagClass.Application + " but was " + tagClass); } IProtocolOp message = DecodeApplicationData(tagValue, sequenceReader, input); return(new LdapMessage(messageId, message)); }