public static PacketEncodingBuilder CreateDefaultBuilder()
        {
            var setupActions = new List <Func <EncodingDecorator, EncodingDecorator> >();
            var builder      = new PacketEncodingBuilder(setupActions);

            return(builder);
        }
Example #2
0
        public static PacketEncodingBuilder WithStringProperty(this PacketEncodingBuilder mapItemBuilder, byte propertySize)
        {
            mapItemBuilder.AddDecorate(item => new PropertyPacketEncoding <string>(item, propertySize,
                                                                                   (packet) => System.Text.Encoding.UTF8.GetBytes(packet.Property),
                                                                                   (bytes, packet) => packet.Property = System.Text.Encoding.UTF8.GetString(bytes)));

            return(mapItemBuilder);
        }
Example #3
0
 public static PacketEncodingBuilder WithProperty <T>(this PacketEncodingBuilder mapItemBuilder, byte propertySize, Func <IPropertyPacket <T>, byte[]> Encode, Action <byte[], IPropertyPacket <T> > Decode)
 {
     mapItemBuilder.AddDecorate(item => new PropertyPacketEncoding <T>(item, propertySize, Encode, Decode));
     return(mapItemBuilder);
 }
Example #4
0
 public static PacketEncodingBuilder WithHeader(this PacketEncodingBuilder mapItemBuilder, byte[] header)
 {
     mapItemBuilder.AddDecorate(item => new HeaderPacketEncoding(item, header));
     return(mapItemBuilder);
 }
Example #5
0
 public static PacketEncodingBuilder WithUnixTimeEpoch(this PacketEncodingBuilder mapItemBuilder)
 {
     mapItemBuilder.AddDecorate(item => new UnixTimeEpochPacketEncoding(item));
     return(mapItemBuilder);
 }
Example #6
0
 public static PacketEncodingBuilder WithDescendant <T>(this PacketEncodingBuilder mapItemBuilder) where T : IDescendantPacket, new()
 {
     mapItemBuilder.AddDecorate(item => new DescendantPacketEncoding <T>(item));
     return(mapItemBuilder);
 }
Example #7
0
 public static PacketEncodingBuilder WithAncestorGeneric <T>(this PacketEncodingBuilder mapItemBuilder, T id, Type packetType)
 {
     mapItemBuilder.AddDecorate(item => new AncestorGenericPacketEncodingDecorator <T>(item, id, packetType));
     return(mapItemBuilder);
 }
Example #8
0
 public static PacketEncodingBuilder WithDescendant <T>(this PacketEncodingBuilder mapItemBuilder, IEnumerable <EncodingDecorator> encodingsList) where T : IDescendantPacket, new()
 {
     mapItemBuilder.AddDecorate(item => new DescendantPacketEncoding <T>(item, encodingsList));
     return(mapItemBuilder);
 }
Example #9
0
 public static PacketEncodingBuilder WithDescendant <T>(this PacketEncodingBuilder mapItemBuilder, IEnumerable <PacketEncodingBuilder> encodingBuiledersList) where T : IDescendantPacket, new()
 {
     mapItemBuilder.AddDecorate(item => new DescendantPacketEncoding <T>(item, encodingBuiledersList.Select(o => o.Build()).ToList()));
     return(mapItemBuilder);
 }
Example #10
0
 public static PacketEncodingBuilder WithDescendantFlag <T>(this PacketEncodingBuilder mapItemBuilder, bool containLength = false) where T : IListDescendantPacket, new()
 {
     mapItemBuilder.AddDecorate(item => new DescendantFlagPacketEncoding <T>(item, containLength));
     return(mapItemBuilder);
 }
Example #11
0
 public static PacketEncodingBuilder WithDescendantFlag <T>(this PacketEncodingBuilder mapItemBuilder, IEnumerable <PacketEncodingBuilder> encodingBuiledersList, bool containLength = false) where T : IListDescendantPacket, new()
 {
     mapItemBuilder.AddDecorate(item => new DescendantFlagPacketEncoding <T>(item, encodingBuiledersList.Select(o => o.Build()).ToList(), containLength));
     return(mapItemBuilder);
 }
 public static PacketEncodingBuilder WithProperty(this PacketEncodingBuilder mapItemBuilder, byte propertySize)
 {
     mapItemBuilder.AddDecorate(item => new PropertyPacketEncoding(item, propertySize));
     return(mapItemBuilder);
 }