private void ProtoMapChanged(object sender, ProtoMapChangeArgs protoMapChangeArgs)
        {
            var findItem =
                ProtobufHelper.ProtoItems.FirstOrDefault(protoItem => protoItem.Value.Contains(protoMapChangeArgs.MessageTyp));

            if (findItem.Value == null)
            {
                return;
            }
            ProtocolItem protocolItem = new ProtocolItem()
            {
                ProtoFile   = findItem.Key,
                MessageType = protoMapChangeArgs.MessageTyp
            };

            ProtobufHelper.UpdateItem(protocolItem, protoMapChangeArgs.URL, protoMapChangeArgs.IsReq);
        }
Exemplo n.º 2
0
        public static void UpdateItem(ProtocolItem item, string path, bool isReq)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }
            if (item == null)
            {
                return;
            }
            var mapItem = ProtocolMap.Maps.FirstOrDefault(i => path.Equals(i.URL, StringComparison.CurrentCultureIgnoreCase)) ?? new MapItem()
            {
                URL = path
            };

            if (isReq)
            {
                if (item.Equals(mapItem.Request))
                {
                    return;
                }
                mapItem.Request = item;
            }
            else
            {
                if (item.Equals(mapItem.Response))
                {
                    return;
                }
                mapItem.Response = item;
            }
            if (!ProtocolMap.Maps.Contains(mapItem))
            {
                ProtocolMap.Maps.Add(mapItem);
            }

            SaveMap();
        }