/// <summary> /// Create a list of filters for a data frame /// </summary> /// <param name="frame">The data frame</param> /// <returns>The list of filters</returns> public static IEnumerable <DataFrameFilterFactory> CreateFilter(DataFrame frame) { if (frame.IsBasic) { BinaryDataFrameFilterFactory filter = new BinaryDataFrameFilterFactory(); filter.Match = frame.ToArray(); filter.Path = "/"; filter.SearchMode = DataFrameFilterSearchMode.Equals; return(new DataFrameFilterFactory[] { filter }); } else { return(CreateFilter(frame.Root)); } }
/// <summary> /// Get a filter for a particular DataValue /// </summary> /// <param name="value">The data value to create the filter</param> /// <returns>The filter factory</returns> public static DataFrameFilterFactory CreateFilter(DataValue value) { SetDataFrameFilterFactory ret; if (value.Value is byte[]) { ret = new BinaryDataFrameFilterFactory() { Match = value.Value as byte[] }; } else { ret = new StringDataFrameFilterFactory() { Match = value.Value.ToString() }; } ret.Path = value.Path; ret.SearchMode = DataFrameFilterSearchMode.Equals; return(ret); }
private IDataFrameFilter CreateFilter() { SetDataFrameFilterFactory factory; FilterMode mode = (FilterMode)comboBoxMode.SelectedItem; if (mode == FilterMode.Binary) { factory = new BinaryDataFrameFilterFactory() { Match = GeneralUtils.HexToBinary(textBoxValue.Text) }; } else if(mode == FilterMode.Regex) { factory = new RegexDataFrameFilterFactory() { CaseSensitive = checkBoxCaseSensitive.Checked, Match = textBoxValue.Text, StringEncoding = (StringDataFrameFilterFactory.FilterStringEncoding)comboBoxEncoding.SelectedItem }; } else if(mode == FilterMode.String) { factory = new StringDataFrameFilterFactory() { CaseSensitive = checkBoxCaseSensitive.Checked, Match = textBoxValue.Text, StringEncoding = (StringDataFrameFilterFactory.FilterStringEncoding)comboBoxEncoding.SelectedItem }; } else { throw new ArgumentException(CANAPE.Properties.Resources.FindPacketForm_SelectMode); } factory.Path = textBoxPath.Text; factory.SearchMode = DataFrameFilterSearchMode.Contains; return factory.CreateFilter(); }
private static DataFrameFilterFactory GetFilterForValue(DataValue value) { SetDataFrameFilterFactory ret; if (value.Value is byte[]) { ret = new BinaryDataFrameFilterFactory() { Match = value.Value as byte[] }; } else { ret = new StringDataFrameFilterFactory() { Match = value.Value.ToString() }; } ret.Path = value.Path; ret.SearchMode = DataFrameFilterSearchMode.Equals; return ret; }
/// <summary> /// Create a list of filters for a data frame /// </summary> /// <param name="frame">The data frame</param> /// <returns>The list of filters</returns> public static IEnumerable<DataFrameFilterFactory> CreateFilter(DataFrame frame) { if (frame.IsBasic) { BinaryDataFrameFilterFactory filter = new BinaryDataFrameFilterFactory(); filter.Match = frame.ToArray(); filter.Path = "/"; filter.SearchMode = DataFrameFilterSearchMode.Equals; return new DataFrameFilterFactory[] { filter }; } else { return CreateFilter(frame.Root); } }