private static string GetSearchInQueryValue(SearchIn searchIn) { switch (searchIn) { case SearchIn.Title: return("title"); case SearchIn.Description: return("description"); case SearchIn.TitleAndDescription: return("title,description"); default: throw new NotSupportedException($"SearchIn {searchIn} is not supported"); } }
/// <summary> /// Returns all types that are used in definition of a given type. /// </summary> public static IEnumerable <IType> AllReferencedTypes(this IType type, SearchIn searchIn = SearchIn.All) { var foundTypes = new HashSet <IType>(new TypeComparer()); if (searchIn.HasFlag(SearchIn.Properties) && (type is IHaveProperties typeWithProperties)) { InspectProperties(foundTypes, typeWithProperties.Properties); } if (searchIn.HasFlag(SearchIn.Methods) && (type is IHaveMethods typeWithtMethods)) { InspectMethods(foundTypes, typeWithtMethods.Methods); } if (searchIn.HasFlag(SearchIn.Fields) && (type is IHaveFields typeWithFields)) { InspectFields(foundTypes, typeWithFields.Fields); } if (type is IClass @class) { if (searchIn.HasFlag(SearchIn.BaseClass)) { if (@class.HasBaseClass) { InspectType(foundTypes, @class.BaseClass); } } } if (foundTypes.Contains(type)) { foundTypes.Remove(type); } return(foundTypes.ToList()); }
/// <summary> /// Initializes a new instance of the search input. /// </summary> /// <param name="options">Represents the search input options.</param> /// <param name="searchString">Represents the text to search for.</param> /// <param name="searchIn">Represents the fields in which to search for the given text.</param> /// <param name="filter">Represents the filters to be applied to the results.</param> /// <param name="sortBy">Represents the field based which to sort the results.</param> /// <param name="sortDirection">Represents the direction in which to sort the results.</param> /// <param name="itemsPerPage">Represents the number of items to be displayed at one time, on a single page.</param> /// <param name="currentPage">Represents the current page of the search.</param> public SearchInputViewModel(SearchOptionsViewModel options, string id = null, string searchString = null, IEnumerable <string> searchIn = null, IEnumerable <string> filter = null, string sortBy = null, string sortDirection = null, int?itemsPerPage = null, int?currentPage = 1) { // Check the search options for possible errors. if (options.Filter == null || options.ItemsPerPage == null || options.SearchIn == null || options.SortBy == null || options.SortDirection == null) { // Throw an exception. throw new ArgumentException(); } // Assign the search options. Options = options; // Check if the given parameters are the default ones. NeedsRedirect = searchIn == null || filter == null || string.IsNullOrEmpty(sortBy) || !Options.SortBy.ContainsKey(sortBy) || string.IsNullOrEmpty(sortDirection) || !Options.SortDirection.ContainsKey(sortDirection) || itemsPerPage == null || itemsPerPage.Value < 1; // Get the default values for those that are null or invalid. searchString = string.IsNullOrEmpty(searchString) ? string.Empty : searchString; searchIn = searchIn ?? Enumerable.Empty <string>(); filter = filter ?? Enumerable.Empty <string>(); sortBy = string.IsNullOrEmpty(sortBy) || !Options.SortBy.ContainsKey(sortBy) ? Options.SortBy.FirstOrDefault().Key : sortBy; sortDirection = string.IsNullOrEmpty(sortDirection) || !Options.SortDirection.ContainsKey(sortDirection) ? Options.SortDirection.FirstOrDefault().Key : sortDirection; itemsPerPage = itemsPerPage == null || itemsPerPage.Value < 1 ? Options.ItemsPerPage.FirstOrDefault().Key : itemsPerPage.Value; currentPage = currentPage == null || currentPage.Value < 1 ? 1 : currentPage.Value; // Define the properties. Id = id; SearchString = searchString; SortBy = sortBy; SortDirection = sortDirection; ItemsPerPage = itemsPerPage.Value; CurrentPage = currentPage.Value; SearchIn = searchIn.Intersect(Options.SearchIn.Keys); Filter = filter.Intersect(Options.Filter.Keys); // Check if there is a search string applied, but there are no values selected to search in. if (!string.IsNullOrEmpty(SearchString) && !SearchIn.Any()) { // Select all of them. SearchIn = Options.SearchIn.Keys; } }
public Menu CreateOptionsMenu () { Menu menu = new Menu (); MenuItem searchInMenu = new MenuItem (GettextCatalog.GetString ("_Search in")); Menu sub = new Menu (); searchInMenu.Submenu = sub; Gtk.RadioMenuItem original = null, translated = null, both = null; GLib.SList group = new GLib.SList (IntPtr.Zero); original = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Original")); group = original.Group; original.ButtonPressEvent += delegate { original.Activate (); }; sub.Append (original); translated = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Translated")); translated.ButtonPressEvent += delegate { translated.Activate (); }; group = translated.Group; sub.Append (translated); both = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Both")); both.ButtonPressEvent += delegate { both.Activate (); }; sub.Append (both); switch (DoSearchIn) { case SearchIn.Both: both.Activate (); break; case SearchIn.Original: original.Activate (); break; case SearchIn.Translated: translated.Activate (); break; } menu.Append (searchInMenu); both.Activated += delegate { if (DoSearchIn != SearchIn.Both) { DoSearchIn = SearchIn.Both; UpdateFromCatalog (); menu.Destroy (); } }; original.Activated += delegate { if (DoSearchIn != SearchIn.Original) { DoSearchIn = SearchIn.Original; UpdateFromCatalog (); menu.Destroy (); } }; translated.Activated += delegate { if (DoSearchIn != SearchIn.Translated) { DoSearchIn = SearchIn.Translated; UpdateFromCatalog (); menu.Destroy (); } }; Gtk.CheckMenuItem regexSearch = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Regex search")); regexSearch.Active = RegexSearch; regexSearch.ButtonPressEvent += delegate { RegexSearch = !RegexSearch; UpdateFromCatalog (); }; menu.Append (regexSearch); Gtk.CheckMenuItem caseSensitive = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Case sensitive")); caseSensitive.Active = IsCaseSensitive; caseSensitive.ButtonPressEvent += delegate { IsCaseSensitive = !IsCaseSensitive; UpdateFromCatalog (); }; menu.Append (caseSensitive); Gtk.CheckMenuItem wholeWordsOnly = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Whole words only")); wholeWordsOnly.Active = IsWholeWordOnly; wholeWordsOnly.Sensitive = !RegexSearch; wholeWordsOnly.ButtonPressEvent += delegate { IsWholeWordOnly = !IsWholeWordOnly; UpdateFromCatalog (); }; menu.Append (wholeWordsOnly); menu.ShowAll (); return menu; }
static POEditorWidget () { isCaseSensitive = PropertyService.Get ("GettetAddin.Search.IsCaseSensitive", false); isWholeWordOnly = PropertyService.Get ("GettetAddin.Search.IsWholeWordOnly", false); regexSearch = PropertyService.Get ("GettetAddin.Search.RegexSearch", false); searchIn = PropertyService.Get ("GettetAddin.Search.SearchIn", SearchIn.Both); }
static StringEditorOptions() { isCaseSensitive = PropertyService.Get ("NETResourcesAddin.Search.IsCaseSensitive", false); isWholeWordOnly = PropertyService.Get ("NETResourcesAddin.Search.IsWholeWordOnly", false); regexSearch = PropertyService.Get ("NETResourcesAddin.Search.RegexSearch", false); searchIn = PropertyService.Get ("NETResourcesAddin.Search.SearchIn", SearchIn.All); }
void ReleaseDesignerOutlets() { if (ActionBar != null) { ActionBar.Dispose(); ActionBar = null; } if (AddressOK != null) { AddressOK.Dispose(); AddressOK = null; } if (BottomConstraint != null) { BottomConstraint.Dispose(); BottomConstraint = null; } if (BottomSeparator != null) { BottomSeparator.Dispose(); BottomSeparator = null; } if (DistanceFilters != null) { DistanceFilters.Dispose(); DistanceFilters = null; } if (DistanceFiltersOpenClose != null) { DistanceFiltersOpenClose.Dispose(); DistanceFiltersOpenClose = null; } if (DistanceLimit != null) { DistanceLimit.Dispose(); DistanceLimit = null; } if (DistanceLimitInput != null) { DistanceLimitInput.Dispose(); DistanceLimitInput = null; } if (DistanceSourceAddress != null) { DistanceSourceAddress.Dispose(); DistanceSourceAddress = null; } if (DistanceSourceAddressLabel != null) { DistanceSourceAddressLabel.Dispose(); DistanceSourceAddressLabel = null; } if (DistanceSourceAddressText != null) { DistanceSourceAddressText.Dispose(); DistanceSourceAddressText = null; } if (DistanceSourceCurrent != null) { DistanceSourceCurrent.Dispose(); DistanceSourceCurrent = null; } if (DistanceSourceCurrentLabel != null) { DistanceSourceCurrentLabel.Dispose(); DistanceSourceCurrentLabel = null; } if (DistanceUnitText != null) { DistanceUnitText.Dispose(); DistanceUnitText = null; } if (FilterLayout != null) { FilterLayout.Dispose(); FilterLayout = null; } if (ListType != null) { ListType.Dispose(); ListType = null; } if (ListView != null) { ListView.Dispose(); ListView = null; } if (ListViewMap != null) { ListViewMap.Dispose(); ListViewMap = null; } if (LoaderCircle != null) { LoaderCircle.Dispose(); LoaderCircle = null; } if (LoaderCircleLeftConstraint != null) { LoaderCircleLeftConstraint.Dispose(); LoaderCircleLeftConstraint = null; } if (LoadNext != null) { LoadNext.Dispose(); LoadNext = null; } if (LoadPrevious != null) { LoadPrevious.Dispose(); LoadPrevious = null; } if (MapSatellite != null) { MapSatellite.Dispose(); MapSatellite = null; } if (MapStreet != null) { MapStreet.Dispose(); MapStreet = null; } if (MapView != null) { MapView.Dispose(); MapView = null; } if (MenuAbout != null) { MenuAbout.Dispose(); MenuAbout = null; } if (MenuChatList != null) { MenuChatList.Dispose(); MenuChatList = null; } if (MenuChatListBg != null) { MenuChatListBg.Dispose(); MenuChatListBg = null; } if (MenuChatListBgCorner != null) { MenuChatListBgCorner.Dispose(); MenuChatListBgCorner = null; } if (MenuContainer != null) { MenuContainer.Dispose(); MenuContainer = null; } if (MenuHelpCenter != null) { MenuHelpCenter.Dispose(); MenuHelpCenter = null; } if (MenuIcon != null) { MenuIcon.Dispose(); MenuIcon = null; } if (MenuLayer != null) { MenuLayer.Dispose(); MenuLayer = null; } if (MenuLocation != null) { MenuLocation.Dispose(); MenuLocation = null; } if (MenuLogIn != null) { MenuLogIn.Dispose(); MenuLogIn = null; } if (MenuLogOut != null) { MenuLogOut.Dispose(); MenuLogOut = null; } if (MenuRegister != null) { MenuRegister.Dispose(); MenuRegister = null; } if (MenuSettings != null) { MenuSettings.Dispose(); MenuSettings = null; } if (NoResult != null) { NoResult.Dispose(); NoResult = null; } if (OpenFilters != null) { OpenFilters.Dispose(); OpenFilters = null; } if (OpenSearch != null) { OpenSearch.Dispose(); OpenSearch = null; } if (OrderBy != null) { OrderBy.Dispose(); OrderBy = null; } if (RefreshDistance != null) { RefreshDistance.Dispose(); RefreshDistance = null; } if (ResultSet != null) { ResultSet.Dispose(); ResultSet = null; } if (RippleMain != null) { RippleMain.Dispose(); RippleMain = null; } if (RippleRefreshDistance != null) { RippleRefreshDistance.Dispose(); RippleRefreshDistance = null; } if (RoundBottom != null) { RoundBottom.Dispose(); RoundBottom = null; } if (SearchIn != null) { SearchIn.Dispose(); SearchIn = null; } if (SearchLayout != null) { SearchLayout.Dispose(); SearchLayout = null; } if (SearchTerm != null) { SearchTerm.Dispose(); SearchTerm = null; } if (Snackbar != null) { Snackbar.Dispose(); Snackbar = null; } if (SnackBottomConstraint != null) { SnackBottomConstraint.Dispose(); SnackBottomConstraint = null; } if (SnackTopConstraint != null) { SnackTopConstraint.Dispose(); SnackTopConstraint = null; } if (SortBy_LastActiveDate != null) { SortBy_LastActiveDate.Dispose(); SortBy_LastActiveDate = null; } if (SortBy_RegisterDate != null) { SortBy_RegisterDate.Dispose(); SortBy_RegisterDate = null; } if (SortBy_ResponseRate != null) { SortBy_ResponseRate.Dispose(); SortBy_ResponseRate = null; } if (SortByCaption != null) { SortByCaption.Dispose(); SortByCaption = null; } if (StatusBar != null) { StatusBar.Dispose(); StatusBar = null; } if (StatusImage != null) { StatusImage.Dispose(); StatusImage = null; } if (StatusText != null) { StatusText.Dispose(); StatusText = null; } if (UseGeoContainer != null) { UseGeoContainer.Dispose(); UseGeoContainer = null; } if (UseGeoNo != null) { UseGeoNo.Dispose(); UseGeoNo = null; } if (UseGeoNoLabel != null) { UseGeoNoLabel.Dispose(); UseGeoNoLabel = null; } if (UseGeoYes != null) { UseGeoYes.Dispose(); UseGeoYes = null; } if (UseGeoYesLabel != null) { UseGeoYesLabel.Dispose(); UseGeoYesLabel = null; } if (UserSearchList != null) { UserSearchList.Dispose(); UserSearchList = null; } }