public void WriteMatchesToStream <T>(NetStream stream, byte flag) where T : IInvItem, IFlagChecker { stream.WriteInt(0); int origPos = stream.Position; int count = 0; for (int i = 0; i < inv.Count; i++) { if (inv[i] is T) { IFlagChecker checker = inv[i] as IFlagChecker; if (!checker.FlagsEqual(flag)) { continue; } count++; stream.WriteUInt(inv[i].DbId); stream.WriteInt(inv[i].Quantity); inv[i].WriteAdditional(stream); } } if (count == 0) { return; } int pos = stream.Position; stream.Position = origPos; stream.WriteInt(count); stream.Position = pos; }
public FlagsDetailsController(IFlagChecker flagChecker) { this.flagChecker = flagChecker; }