コード例 #1
0
 void IConsumePipeBuilder.AddFilter <T>(IFilter <ConsumeContext <T> > filter)
 {
     _filter.AddFilter(filter);
 }
コード例 #2
0
        public Options()
        {
            CustomFilters = new DynamicFilter();
            //prepare standard filters
            CheckedFilters.Add(FilterName.Address);
            CheckedFilters.Add(FilterName.Port);
            CheckedFilters.Add(FilterName.Service);
            CheckedFilters.Add(FilterName.Size);
            CheckedFilters.Add(FilterName.Time);
            CheckedFilters.Add(FilterName.Custom);
            //service map with proto names and ports
            ServiceMap = Constants.GetDefaultServiceMap();
            XElement rootXml = null;

            try
            {
                rootXml = XElement.Load(DynamicFilter.WorkingDir + cFileName);
            }
            catch
            {
                return;
            }
            //load filters
            try
            {
                List <XElement> filters = rootXml.Element("filters").Elements("filter").ToList();
                foreach (XElement fil in filters)
                {
                    if (CustomFilters.BuildFilter(fil.Attribute("text").Value))
                    {
                        CustomFilters.AddFilter(fil.Attribute("name").Value);
                    }
                }
            }
            catch {}
            //load aliases
            try
            {
                List <XElement> aliases = rootXml.Element("aliases").Elements("alias").ToList();
                foreach (XElement al in aliases)
                {
                    try
                    {
                        string ip = al.Attribute("ip").Value;
                        IPAddress.Parse(ip);
                        Aliases[ip] = al.Attribute("name").Value;
                    }
                    catch { }
                }
            }
            catch { }
            //load locals
            try
            {
                List <XElement> locals = rootXml.Element("locals").Elements("local").ToList();
                foreach (XElement loc in locals)
                {
                    IPRange range = new IPRange();
                    if (range.Parse(loc.Attribute("range").Value))
                    {
                        Locals.Add(range);
                    }
                }
            }
            catch { }
        }