public void ProcessPacket(Packet packet) { // Cache type of packet Type packetType = packet.GetType(); // Each variable has multiple links variableEntriesList.ForEach(delegate(VariableEntry entry) { // Variable can link only to single property of a packet hence only single check PacketPropertyVariableLink link = GetVariableLinkToPacket(entry.variable, packetType); if (null != link) { // Find first reachable packet property value ObjectReflectionProcessor processor = new ObjectReflectionProcessor(delegate(object o) { // Property value found - save it entry.Value = o; // Always stop iteration return(true); }); processor.IterateObjectTreePathValues(packet, link.PacketClassMemberPath.members, PacketPropertyValueFilterForm.RECURSIVE_SEARCH_DEPTH); } }); }
/// <summary> /// Determines whether a packet is ignored by this instance of checker. (Generic interface implementation.) /// </summary> /// <param name="packetToCheck">The value to check.</param> /// <returns> /// <c>true</c> if value is ignored; otherwise, <c>false</c>. /// </returns> public bool IsPacketIgnored(Packet packetToCheck) { bool isIgnored; // Filter by packet type if (entry.packetClass.type != null && !entry.packetClass.type.IsAssignableFrom(packetToCheck.GetType())) { isIgnored = true; } else { int depth = (entry.isRecursive ? PacketPropertyValueFilterForm.RECURSIVE_SEARCH_DEPTH : 1); // isIgnored = IsPacketIgnored(packet, classProperty.members, depth); // Check every reachable value ObjectReflectionProcessor processor = new ObjectReflectionProcessor(delegate(object o) { // Continue the search while we find at least single value which is not ignored bool ret = !IsPacketIgnoredImpl(o, value); return(ret); }); isIgnored = !processor.IterateObjectTreePathValues(packetToCheck, entry.classProperty.members, depth); } return(isIgnored); }