private void FiltersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Filter = FilterProvider.CreateNewFilterFromDescription((string)FiltersComboBox.SelectedItem); var textFilter = Filter as ITextFilter; if (textFilter != null) { FlagColumnDef.Width = new GridLength(0); FilterText.Text = textFilter.Text; return; } var textFilterWithFlag = Filter as ITextFilterWithFlag; if (textFilterWithFlag != null) { FlagColumnDef.Width = new GridLength(180); FilterFlag.Content = textFilterWithFlag.FlagDescription; FilterText.Text = textFilterWithFlag.Text; return; } throw new NotSupportedException($"Unexpected filter type: {Filter.GetType().FullName}"); }
public static string GetCallBySearchFilter(SearchFilter filter, string baseUrl) { NameValueCollection myCollection = new NameValueCollection(); Dictionary <string, string> myDictionary = new Dictionary <string, string>(); Type myType = filter.GetType(); IList <PropertyInfo> props = new List <PropertyInfo>(myType.GetProperties()); foreach (PropertyInfo prop in props) { object propValue = prop.GetValue(filter, null); var value = (propValue == null) || (propValue.Equals(0)) ? null : propValue.ToString(); myCollection.Add(prop.Name.ToLower(), value); } var url = Request.GetCall(Request.Client.BaseUrl.AbsoluteUri, baseUrl); return(UrlBuilder.BuildUri(url, myCollection).Query); }
/// <summary> /// Search all clans by criteria. /// </summary> /// <param name="searchFilter">SearchFilter with your criteria to search clans.</param> /// <returns></returns> public SearchClan GetClans(SearchFilter searchFilter) { NameValueCollection myCollection = new NameValueCollection(); Type myType = searchFilter.GetType(); IList <PropertyInfo> props = new List <PropertyInfo>(myType.GetProperties()); foreach (PropertyInfo prop in props) { object propValue = prop.GetValue(searchFilter, null); var value = (propValue == null) || (propValue.Equals(0)) || (propValue.Equals(WarFrequency.undefined)) ? null : propValue.ToString(); myCollection.Add(prop.Name.ToLower(), value); } var url = Request.GetCall(Request.Client.BaseUrl.AbsoluteUri, API_URL_CLANS); var call = UrlBuilder.BuildUri(url, myCollection); var myClans = Request.GetResponse <SearchClan>(API_URL_CLANS, call.Query); return(myClans); }