public static AcnPacket Create(AcnRootLayer rootLayer, Type packetType) { AcnPacket packet = (AcnPacket)Activator.CreateInstance(packetType); packet.Root = rootLayer; return(packet); }
/// <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); }
public static void WriteTcpPacket(AcnPacket packet, AcnBinaryWriter data) { packet.Root.WriteData(data, true); packet.WriteData(data); packet.Root.WriteLength(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)); }