public static AcnPacket Create(AcnRootLayer rootLayer, Type packetType) { AcnPacket packet = (AcnPacket)Activator.CreateInstance(packetType); packet.Root = rootLayer; return(packet); }
public static AcnPacket ReadTcpPacket(AcnBinaryReader data) { AcnRootLayer rootLayer = new AcnRootLayer(); rootLayer.ReadData(data, true); return(ReadPacket(rootLayer, data));; }
/// <summary> /// Creates the specified root layer. /// </summary> /// <param name="rootLayer">The root layer.</param> /// <param name="reader">The reader.</param> /// <returns></returns> public AcnPacket Create(AcnRootLayer rootLayer, AcnBinaryReader reader) { AcnPacket packet = (AcnPacket)Activator.CreateInstance(typeof(TPacketType)); packet.Root = rootLayer; packet.ReadData(reader); return(packet); }
public static AcnPacket ReadPacket(AcnRootLayer header, AcnBinaryReader data) { AcnPacket packet = AcnPacket.Create(header); if (packet != null) { packet.Root = header; packet.ReadData(data); } return(packet); }
public static AcnPacket Build(AcnRootLayer header) { Type packetType; if (packetStore.TryGetValue(new PacketKey(header.ProtocolId), out packetType)) { AcnPacket packet = (AcnPacket)Activator.CreateInstance(packetType); return(packet); } return(null); }
public static AcnPacket Build(AcnRootLayer header, AcnBinaryReader data) { IPacketBuilder packetType; if (factory.TryGetBuilder(new PacketKey(header.ProtocolId), out packetType)) { AcnPacket packet = packetType.Create(header, data); return(packet); } return(null); }
/// <summary> /// Creates the specified root layer. /// </summary> /// <param name="rootLayer">The root layer.</param> /// <param name="reader">The reader.</param> /// <returns></returns> public AcnPacket Create(AcnRootLayer rootLayer, AcnBinaryReader reader) { long startPosition = reader.BaseStream.Position; PduHeader pduHeader = new PduHeader(); pduHeader.ReadPdu(reader); IPacketBuilder builder; if (TryGetBuilder(new PacketKey(pduHeader.Vector), out builder)) { reader.BaseStream.Seek(startPosition, System.IO.SeekOrigin.Begin); return(builder.Create(rootLayer, reader)); } return(null); }
public static AcnPacket Create(AcnRootLayer header) { return(AcnPacketFactory.Build(header)); }
public AcnPacket(int protocolId) { Root = new AcnRootLayer(); Root.ProtocolId = protocolId; }
/// <summary> /// Creates an ACN packet from the header information and the recieved data. /// </summary> /// <param name="header">The header.</param> /// <param name="data">The data.</param> /// <returns>The created ACN packet, may be cast to the correct packet type.</returns> public static AcnPacket Create(AcnRootLayer header, AcnBinaryReader data) { return(AcnPacketFactory.Build(header, data)); }
/// <summary> /// Reads a single packet from the data stream and returns the created packet information. This version assumes the header /// information has already been read and so starts at the PDU layer. /// </summary> /// <remarks> /// This will create the correct packet class from the registerd packet formats in the packet factory. /// </remarks> /// <param name="data">The recieved packet data.</param> /// <returns>The packet information, cast to the desired packet type.</returns> public static AcnPacket ReadPacket(AcnRootLayer header, AcnBinaryReader data) { return(AcnPacket.Create(header, data)); }