public StringFilter ToUpper() { Equal = Equal?.ToUpper(); NotEqual = NotEqual?.ToUpper(); Contain = Contain?.ToUpper(); NotContain = NotContain?.ToUpper(); StartWith = StartWith?.ToUpper(); NotStartWith = NotStartWith?.ToUpper(); EndWith = EndWith?.ToUpper(); NotEndWith = NotEndWith?.ToUpper(); return(this); }
public static void CreateFilter(object sender, object selectedItem) { if (selectedItem is FilterCollectionViewModel filterCollectionViewModel) { CreateFilter(sender, filterCollectionViewModel.Parent); return; } var button = (Button)sender; var type = (string)button.CommandParameter; FilterBase entity; switch (type) { case nameof(ActiveOn): entity = ActiveOn.New("0001-01-01"); break; case nameof(ActiveWithin): entity = ActiveWithin.New("0001-01-01,0001-01-01"); break; case nameof(OfType): entity = OfType.New("TypeName"); break; case nameof(NotOfType): entity = NotOfType.New("TypeName"); break; case nameof(Contain): entity = Contain.New("Property", "Value"); break; case nameof(NotContain): entity = NotContain.New("Property", "Value"); break; case nameof(EqualTo): entity = EqualTo.New("Property", "Value"); break; case nameof(NotEqualTo): entity = NotEqualTo.New("Property", "Value"); break; case nameof(GreaterThan): entity = GreaterThan.New("Property", "Value"); break; case nameof(LessThan): entity = LessThan.New("Property", "Value"); break; case nameof(GreaterThanEqualTo): entity = GreaterThanEqualTo.New("Property", "Value"); break; case nameof(LessThanEqualTo): entity = LessThanEqualTo.New("Property", "Value"); break; case nameof(Between): entity = Between.New("Property", "0001-01-01", "0001-01-01"); break; case nameof(WithinArray): entity = WithinArray.New("Property", "ValueA,ValueB,ValueC"); break; case nameof(NotWithinArray): entity = NotWithinArray.New("Property", "ValueA,ValueB,ValueC"); break; case nameof(IsNull): entity = IsNull.New("Property"); break; case nameof(IsNotNull): entity = IsNotNull.New("Property"); break; case nameof(IsNullOrGreaterThan): entity = IsNullOrGreaterThan.New("Property", "Value"); break; case nameof(IsNullOrGreaterThanEqualTo): entity = IsNullOrGreaterThanEqualTo.New("Property", "Value"); break; case nameof(IsNullOrLessThan): entity = IsNullOrLessThan.New("Property", "Value"); break; case nameof(IsNullOrLessThanEqualTo): entity = IsNullOrLessThanEqualTo.New("Property", "Value"); break; case nameof(StartsWith): entity = StartsWith.New("Property", "Value"); break; case nameof(EndsWith): entity = EndsWith.New("Property", "Value"); break; case nameof(TakeFirst): entity = TakeFirst.New(1); break; case nameof(OfDerivedType): entity = OfDerivedType.New("TypeName"); break; case nameof(NotOfDerivedType): entity = NotOfDerivedType.New("TypeName"); break; default: throw new ArgumentOutOfRangeException(); } FilterViewModel viewModel; FilterCollectionViewModel viewModelCollection; if (selectedItem is GroupViewModel entityGroupViewModel) { entityGroupViewModel.IsExpanded = true; entityGroupViewModel.Element.Filters.Add(entity); viewModelCollection = entityGroupViewModel.Children.OfType <FilterCollectionViewModel>().First(); viewModel = new FilterViewModel(entity, viewModelCollection); viewModelCollection.Children.Add(viewModel); } else if (selectedItem is OutputViewModel outputViewModel) { if (!(outputViewModel.Element is AggregateOutputBase elementAsAggregate)) { return; } outputViewModel.IsExpanded = true; elementAsAggregate.Filters.Add(entity); viewModelCollection = outputViewModel.Children.OfType <FilterCollectionViewModel>().First(); viewModel = new FilterViewModel(entity, viewModelCollection); viewModelCollection.Children.Add(viewModel); } else { return; } viewModelCollection.IsExpanded = true; viewModel.IsSelected = true; viewModel.IsExpanded = true; }