Example #1
0
		public Filters()
		{
			VideoInputDevices = new FilterCollection(FilterCategory.VideoInputDevice);
			AudioInputDevices = new FilterCollection(FilterCategory.AudioInputDevice);
			VideoCompressors = new FilterCollection(FilterCategory.VideoCompressorCategory);
			AudioCompressors = new FilterCollection(FilterCategory.AudioCompressorCategory);
		}
		public void WithNoFilterOrSortShouldContainAllModelItems()
		{
			var filtered = new FilterCollection<DataItem>(model);
			Assert.AreEqual(model.Count, filtered.Count);
			for (var i = 0; i < model.Count; ++i)
				Assert.AreSame(model[i], filtered[i]);
		}
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     // reader.Read();
     var result = new FilterCollection(serializer.Deserialize<Filter[]>(reader));
     //reader.Read();
     return result;
 }
		public void SortDescendingShouldSortCorrectly()
		{
			var filtered = new FilterCollection<DataItem>(model);
			filtered.Sort = GridViewUtils.SortItemsDescending;
			Assert.AreEqual(model.Count, filtered.Count);
			for (var i = 0; i < model.Count; ++i)
				Assert.AreSame(model[model.Count - 1 - i], filtered[i]);
		}
		public void WithOddItemFilterShouldContainOddModelItems()
		{
			var filtered = new FilterCollection<DataItem>(model);
			filtered.Filter = GridViewUtils.KeepOddItemsFilter;
			Assert.AreEqual(model.Count / 2, filtered.Count);
			for (var i = 0; i < model.Count / 2; ++i)
				Assert.AreSame(model[i * 2 + 1], filtered[i]);
		}
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="filterData">The data to be filtered</param>
        /// <param name="filterCollection">The filtercollectio to be applied to</param>
        /// <param name="filterMethod">The filtermethod</param>
        /// <param name="callback">The callback for successfull filtering</param>
        public FilterCommand(DatabaseDataSet filterData, FilterCollection filterCollection, FilterMethod filterMethod, CommandFinishedDelegate callback)
            : base(Priority.Low, callback)
        {
            this.filterData = filterData;
            this.filterCollection = filterCollection;
            this.filterMethod = filterMethod;

            this.description = "Filter file " + this.filterData.AbsoluteFileName;
        }
      public void Constructor_Collection_AddsFilters()
      {
         FilterCollection<int> filters = new FilterCollection<int>();
         Filter<int> filter = new Mock<Filter<int>>().Object;
         filters.Add(filter);

         FilterCollection<int> filtersCopy = new FilterCollection<int>(filters);
         Assert.AreEqual(1, filtersCopy.Count);
         Assert.IsTrue(filtersCopy.Contains(filter));
      }
      public void Add_Filter_RaisesFilterAddedEvent()
      {
         int filterAddedEventRaised = 0;
         FilterCollection<int> filters = new FilterCollection<int>();
         filters.FilterAdded += (sender, args) => filterAddedEventRaised++;

         filters.Add(new Mock<Filter<int>>().Object);

         Assert.AreEqual(1, filterAddedEventRaised);
      }
      public void Clear_ClearsCollection()
      {
         FilterCollection<int> filters = new FilterCollection<int>();
         Filter<int> filter = new Mock<Filter<int>>().Object;

         filters.Clear();

         Assert.IsTrue(filters.IsEmpty());
         Assert.IsFalse(filters.Contains(filter));
      }
		public void SortWithEvenItemsBeforeOddItemsShouldSortCorrectly()
		{
			var filtered = new FilterCollection<DataItem>(model);
			filtered.Sort = GridViewUtils.SortEvenItemsBeforeOdd;
			Assert.AreEqual(model.Count, filtered.Count);
			for (var i = 0; i < model.Count / 2; ++i)
				Assert.AreSame(model[i * 2], filtered[i]);
			for (var i = 0; i < model.Count / 2; ++i)
				Assert.AreSame(model[i * 2 + 1], filtered[model.Count / 2 + i]);
		}
Example #11
0
        public void AddService_SetsOrder()
        {
            // Arrange
            var collection = new FilterCollection();

            // Act
            var added = collection.AddService(typeof(MyFilter), 17);

            // Assert
            Assert.Equal(17, Assert.IsAssignableFrom<IOrderedFilter>(added).Order);
        }
		public void SortWithEvenItemsBeforeOddItemsAndWithFilterShouldSortAndFilterCorrectly()
		{
			var filtered = new FilterCollection<DataItem>(model);
			filtered.Sort = GridViewUtils.SortEvenItemsBeforeOdd;
			filtered.Filter = GridViewUtils.KeepFirstHalfOfItemsFilter;
			Assert.AreEqual(model.Count / 2, filtered.Count);
			for (var i = 0; i < model.Count / 4; ++i)
				Assert.AreSame(model[i * 2], filtered[i]);
			for (var i = 0; i < model.Count / 4; ++i)
				Assert.AreSame(model[i * 2 + 1], filtered[model.Count / 4 + i]);
		}
        private void ConfigureFilters(ContainerBuilder builder)
        {
            var filters = new FilterCollection();
            builder.Register(filters).ExternallyOwned();
            builder.RegisterTypesAssignableTo<IActionFilter>().FactoryScoped();
            builder.RegisterTypesAssignableTo<IAuthorizationFilter>().FactoryScoped();

            filters.Apply<DecorateModelWithViewResult>().Always();
            filters.Apply<AddMessageToViewData>().When(action => action.ActionInstance is Controllers.Home.Index);
            //alternatively:
            //filters.Apply<AddMessageToViewData>().ForTypesAssignableTo<Controllers.Home.Index>();
        }
Example #14
0
        public static bool Init()
        {
            if (!Directory.Exists(SettingsFolder))
                Directory.CreateDirectory(SettingsFolder);

            InitSettingsCollections();
            InitHistory();

            SelectedFilter = FilterCollections.FirstOrDefault().Value;

            return true;
        }
        public ActivationNetworkSystem(string name, System.IO.FileInfo info)
            : base()
        {
            serializableObject = new SerializableObject<ActivationNetworkSystem>(this);
            sinapseDocument = new SinapseDocument(name, info);

            Preprocess = new FilterCollection();
            Postprocess = new FilterCollection();

            this.Name = name;
            this.HasChanges = true;
        }
Example #16
0
        public void AddService_UsesServiceFilterAttribute()
        {
            // Arrange
            var collection = new FilterCollection();

            // Act
            var added = collection.AddService(typeof(MyFilter));

            // Assert
            var serviceFilter = Assert.IsType<ServiceFilterAttribute>(added);
            Assert.Equal(typeof(MyFilter), serviceFilter.ServiceType);
            Assert.Same(serviceFilter, Assert.Single(collection));
        }
Example #17
0
        public void Add_UsesTypeFilterAttribute()
        {
            // Arrange
            var collection = new FilterCollection();

            // Act
            var added = collection.Add(typeof(MyFilter));

            // Assert
            var typeFilter = Assert.IsType<TypeFilterAttribute>(added);
            Assert.Equal(typeof(MyFilter), typeFilter.ImplementationType);
            Assert.Same(typeFilter, Assert.Single(collection));
        }
Example #18
0
      private static Boolean ContainsColorTagsFilter(FilterCollection<IMaxNode> collection)
      {
         foreach (Filter<IMaxNode> filter in collection)
         {
            if (filter is ColorTagsFilter)
               return true;

            FilterCombinator<IMaxNode> combinator = filter as FilterCombinator<IMaxNode>;
            if (combinator != null && ContainsColorTagsFilter(combinator.Filters))
               return true;
         }

         return false;
      }
      public void Add_FilterTwice_OnlyAddsOnce()
      {
         int filterAddedEventRaised = 0;
         FilterCollection<int> filters = new FilterCollection<int>();
         filters.FilterAdded += (sender, args) => filterAddedEventRaised++;
         Filter<int> filter = new Mock<Filter<int>>().Object;

         filters.Add(filter);
         filters.Add(filter);

         Assert.AreEqual(1, filters.Count);
         Assert.IsTrue(filters.Contains(filter));
         Assert.AreEqual(1, filterAddedEventRaised);
      }
Example #20
0
 static Filters()
 {
   VideoInputDevices = new FilterCollection(FilterCategory.VideoInputDevice, true);
   AudioInputDevices = new FilterCollection(FilterCategory.AudioInputDevice, true);
   VideoCompressors = new FilterCollection(FilterCategory.VideoCompressorCategory, true);
   AudioCompressors = new FilterCollection(FilterCategory.AudioCompressorCategory, true);
   LegacyFilters = new FilterCollection(FilterCategory.LegacyAmFilterCategory, true);
   AudioRenderers = new FilterCollection(FilterCategory.AudioRendererDevice, true);
   WDMEncoders = new FilterCollection(FilterCategory.AM_KSEncoder, true);
   WDMcrossbars = new FilterCollection(FilterCategory.AM_KSCrossBar, true);
   WDMTVTuners = new FilterCollection(FilterCategory.AM_KSTvTuner, true);
   BDAReceivers = new FilterCollection(FilterCategory.AM_KS_BDA_RECEIVER_COMPONENT, true);
   AllFilters = new FilterCollection(FilterCategory.ActiveMovieCategory, true);
 }
        public void Setup()
        {
            filters = new FilterCollection();

            locator = new FakeServiceLocator();
            locator.Add(filters);
            locator.Add<IActionMethodSelector>(new DefaultActionMethodSelector());

            context = TestHelper.RequestContext();
            context.RouteData.Values.Add("action","test");

            action = new TestAction();
            adaptor = new ControllerAdaptor(action, locator) { TempDataProvider = new NullTempDataProvider() };
        }
Example #22
0
 public MvcOptions()
 {
     CacheProfiles = new Dictionary<string, CacheProfile>(StringComparer.OrdinalIgnoreCase);
     Conventions = new List<IApplicationModelConvention>();
     Filters = new FilterCollection();
     FormatterMappings = new FormatterMappings();
     InputFormatters = new FormatterCollection<IInputFormatter>();
     OutputFormatters = new FormatterCollection<IOutputFormatter>();
     ModelBinderProviders = new List<IModelBinderProvider>();
     ModelBindingMessageProvider = new ModelBindingMessageProvider();
     ModelMetadataDetailsProviders = new List<IMetadataDetailsProvider>();
     ModelValidatorProviders = new List<IModelValidatorProvider>();
     ValueProviderFactories = new List<IValueProviderFactory>();
 }
Example #23
0
        public void Add_ThrowsOnNonIFilter()
        {
            // Arrange
            var collection = new FilterCollection();

            var expectedMessage =
                $"The type '{typeof(NonFilter).FullName}' must derive from " +
                $"'{typeof(IFilterMetadata).FullName}'." + Environment.NewLine +
                "Parameter name: filterType";

            // Act & Assert
            var ex = Assert.Throws<ArgumentException>(() => { collection.Add(typeof(NonFilter)); });

            // Assert
            Assert.Equal(expectedMessage, ex.Message);
        }
Example #24
0
        public static FilterCollection WithNumberFilters(this FilterCollection filters)
        {
            filters.AddFilter("abs", Abs);
            filters.AddFilter("at_least", AtLeast);
            filters.AddFilter("at_most", AtMost);
            filters.AddFilter("ceil", Ceil);
            filters.AddFilter("divided_by", DividedBy);
            filters.AddFilter("floor", Floor);
            filters.AddFilter("minus", Minus);
            filters.AddFilter("modulo", Modulo);
            filters.AddFilter("plus", Plus);
            filters.AddFilter("round", Round);
            filters.AddFilter("times", Times);

            return(filters);
        }
Example #25
0
        public void SortWithEvenItemsBeforeOddItemsAndWithFilterShouldSortAndFilterCorrectly()
        {
            var filtered = new FilterCollection <DataItem>(model);

            filtered.Sort   = GridViewUtils.SortEvenItemsBeforeOdd;
            filtered.Filter = GridViewUtils.KeepFirstHalfOfItemsFilter;
            Assert.AreEqual(model.Count / 2, filtered.Count);
            for (var i = 0; i < model.Count / 4; ++i)
            {
                Assert.AreSame(model[i * 2], filtered[i]);
            }
            for (var i = 0; i < model.Count / 4; ++i)
            {
                Assert.AreSame(model[i * 2 + 1], filtered[model.Count / 4 + i]);
            }
        }
Example #26
0
        public void SortWithEvenItemsBeforeOddItemsShouldSortCorrectly()
        {
            var model    = GridViewUtils.CreateModel();
            var filtered = new FilterCollection <DataItem>(model);

            filtered.Sort = GridViewUtils.SortEvenItemsBeforeOdd;
            Assert.AreEqual(model.Count, filtered.Count);
            for (var i = 0; i < model.Count / 2; ++i)
            {
                Assert.AreSame(model[i * 2], filtered[i]);
            }
            for (var i = 0; i < model.Count / 2; ++i)
            {
                Assert.AreSame(model[i * 2 + 1], filtered[model.Count / 2 + i]);
            }
        }
Example #27
0
    public static void TargetPackage(ITaskContext context)
    {
        FilterCollection installBinFilters = new FilterCollection();

        installBinFilters.Add(new RegexFileFilter(@".*\.xml$"));
        installBinFilters.Add(new RegexFileFilter(@".svn"));

        context.Tasks().PackageTask("builds")
        .AddDirectoryToPackage("FlubuExample", "FlubuExample", false, new RegexFileFilter(@"^.*\.(svc|asax|aspx|config|js|html|ico|bat|cgn)$").NegateFilter())
        .AddDirectoryToPackage("FlubuExample\\Bin", "FlubuExample\\Bin", false, installBinFilters)
        .AddDirectoryToPackage("FlubuExample\\Content", "FlubuExample\\Content", true)
        .AddDirectoryToPackage("FlubuExample\\Images", "FlubuExample\\Images", true)
        .AddDirectoryToPackage("FlubuExample\\Scripts", "FlubuExample\\Scripts", true)
        .AddDirectoryToPackage("FlubuExample\\Views", "FlubuExample\\Views", true)
        .ZipPackage("FlubuExample.zip")
        .Execute(context);
    }
Example #28
0
		public void Setup()
		{
			TestUtils.Invoke(() =>
			{
				grid = new GridView();
				// Some platforms need at least one column for selection to work
				grid.Columns.Add(new GridColumn { HeaderText = "Text", DataCell = new TextBoxCell("Id") });
				model = GridViewUtils.CreateModel();

				// create our filtered collection
				filtered = new FilterCollection<DataItem>(model);
				filtered.Change = () => grid.SelectionPreserver;
				grid.DataStore = filtered;
				grid.SelectionChanged += (s, e) => selectionChangedCount++;
				selectionChangedCount = 0;
			});
		}
        public void When_action_returns_object_should_be_decorated_with_modelresult()
        {
            context.RouteData.Values.Add("controller", "Index");
            context.RouteData.Values.Add("action", "Test");

            var filter = new FilterInterceptsModel();
            var filters = new FilterCollection();
            filters.Apply<FilterInterceptsModel>().Always();
            locator.Add(filter);
            locator.Add(filters);

            adaptor = new ControllerAdaptor(new TestActionReturnsModel(), locator) { TempDataProvider = new NullTempDataProvider() };

            Execute();

            filter.Model.ShouldNotBeNull();
        }
Example #30
0
        public void Setup()
        {
            filters = new FilterCollection();

            locator = new FakeServiceLocator();
            locator.Add(filters);
            locator.Add <IActionMethodSelector>(new DefaultActionMethodSelector());

            context = TestHelper.RequestContext();
            context.RouteData.Values.Add("action", "test");

            action  = new TestAction();
            adaptor = new ControllerAdaptor(action, locator)
            {
                TempDataProvider = new NullTempDataProvider()
            };
        }
Example #31
0
        public void Sort()
        {
            var original = new List <FilterEntry>
            {
                new FilterEntry("192.168.1.7", "192.168.1.253"),
                new FilterEntry("6.0.0.1", "6.255.255.254"),
                new FilterEntry("3.0.0.0", "3.255.255.255")
            };

            var result = FilterCollection.Sort(original);

            Assert.AreEqual(3, result.Count);

            Assert.AreEqual(new FilterEntry("3.0.0.0", "3.255.255.255"), result[0]);
            Assert.AreEqual(new FilterEntry("6.0.0.1", "6.255.255.254"), result[1]);
            Assert.AreEqual(new FilterEntry("192.168.1.7", "192.168.1.253"), result[2]);
        }
Example #32
0
 /// <summary>
 /// Calls the AddFilters method of the plugins.
 /// </summary>
 public void AddFilters(FilterCollection filters)
 {
     lock (pluginLock)
     {
         foreach (PluginLogic pluginLogic in plugins)
         {
             try
             {
                 pluginLogic.AddFilters(filters);
             }
             catch (Exception ex)
             {
                 log.WriteError(ex, WebPhrases.ErrorInPlugin, nameof(AddFilters), pluginLogic.Code);
             }
         }
     }
 }
Example #33
0
        private void UpdateFilteringInfo(FilterCollection filters, dynamic newArenaElement)
        {
            var filteringInfo = new JArray();

            foreach (var filter in filters)
            {
                var filterElement = new JObject();
                foreach (var atribute in filter.Attributes)
                {
                    filterElement.Add(new JProperty(atribute.Name, new JValue(atribute.Value)));
                }

                filteringInfo.Add(filterElement);
            }

            newArenaElement.filteringInfo = filteringInfo;
        }
Example #34
0
        public static FilterCollection WithMiscFilters(this FilterCollection filters)
        {
            filters.AddFilter("default", Default);
            filters.AddFilter("date", Date);
            filters.AddFilter("format_date", FormatDate);
            filters.AddFilter("raw", Raw);
            filters.AddFilter("compact", Compact);
            filters.AddFilter("url_encode", UrlEncode);
            filters.AddFilter("url_decode", UrlDecode);
            filters.AddFilter("strip_html", StripHtml);
            filters.AddFilter("escape", Escape);
            filters.AddFilter("escape_once", EscapeOnce);
            filters.AddFilter("handle", Handleize);
            filters.AddFilter("handleize", Handleize);

            return(filters);
        }
Example #35
0
        public QuestionList(MainWindow main)
        {
            InitializeComponent();

            Main = main;
            Main.GameStateChanged += Main_GameStateChanged;

            filterCollection = new FilterCollection <Question <ScummState>, ScummState>(
                Questions.Values,
                Filter,
                null
                );

            diffCollection = new DiffingCollection <Question <ScummState> >(filterCollection);

            QuestionListBox.ItemsSource = diffCollection;
        }
Example #36
0
        public void RemoveFromParentWhileFilteredShouldBeRemoved()
        {
            var model = GridViewUtils.CreateModel();

            var filtered = new FilterCollection <DataItem>(model);

            filtered.Filter = GridViewUtils.KeepOddItemsFilter;
            filtered.Sort   = GridViewUtils.SortItemsDescending;

            NotifyCollectionChangedEventArgs changeArgs = null;

            filtered.CollectionChanged += (sender, e) => changeArgs = e;

            var itemToRemove1 = model[10];

            Assert.AreEqual(-1, filtered.IndexOf(itemToRemove1), "#1-1 Item should NOT be in the filtered collection");
            changeArgs = null;
            model.RemoveAt(10);
            Assert.IsNull(changeArgs, "#1-2 Change should not have been triggered");
            Assert.AreEqual(-1, filtered.IndexOf(itemToRemove1), "#1-3 Item should NOT be in the filtered collection");

            var itemToRemove2 = model[10];

            Assert.AreEqual(44, filtered.IndexOf(itemToRemove2), "#2-1 Item should be in the filtered collection");
            changeArgs = null;
            model.Remove(itemToRemove2);
            Assert.AreEqual(-1, filtered.IndexOf(itemToRemove2), "#2-2 Item should NOT be in the filtered collection");

            // verify change notification
            Assert.IsNotNull(changeArgs, "#3-1 Change should have been triggered");
            Assert.AreEqual(NotifyCollectionChangedAction.Remove, changeArgs.Action, "#3-2 Item should have triggered a remove notification");
            Assert.AreEqual(44, changeArgs.OldStartingIndex, "#3-3 Index of remove notification is incorrect");
            Assert.IsNotEmpty(changeArgs.OldItems, "#3-4 Old items of change event should not be empty");
            Assert.AreEqual(11, ((DataItem)changeArgs.OldItems[0]).Id, "#3-5 Old item of notification is not correct");


            filtered.Filter = null;
            Assert.AreEqual(NotifyCollectionChangedAction.Reset, changeArgs.Action, "#4 Changing filter should send a reset notification");
            filtered.Sort = null;

            // should be in the same inserted position in the source model
            Assert.AreEqual(-1, filtered.IndexOf(itemToRemove1), "#5-1 Item should NOT be in the filtered collection");
            Assert.AreEqual(-1, filtered.IndexOf(itemToRemove2), "#5-2 Item should NOT be in the filtered collection");
            Assert.AreEqual(model.Count, filtered.Count, "#5-3 Count in filtered does not match model");
        }
Example #37
0
        private async void ButtonCreateFilter_Click(object sender, RoutedEventArgs e)
        {
            var filter = TextBoxFilter.Text;

            if (string.IsNullOrWhiteSpace(filter))
            {
                var infoDialog = new InfoDialog("Das Feld fĆ¼r den gesuchten Wert muss ausgefĆ¼llt sein!");
                await infoDialog.ShowAsync();

                return;
            }

            var yesNoDialog = new YesNoDialog("Filter speichern?", "Soll der Filter fĆ¼r dieses Projekt gespeichert werden?" + Environment.NewLine + Environment.NewLine +
                                              "[Ja]              Der Filter wird gespeichert, wird unter 'Bekannte Filter' hinzugefĆ¼gt und ist fĆ¼r dieses Projekt jeder Zeit abrufbar" + Environment.NewLine + Environment.NewLine +
                                              "[Nein]          Der Filter wird unter 'Bekannte Filter' hinzugefĆ¼gt, ist jedoch nach Beenden dieser Sitzung nicht mehr verfĆ¼gbar" + Environment.NewLine +
                                              Environment.NewLine +
                                              "[Abbrechen] Der Filter wird nicht erstellt");
            await yesNoDialog.ShowAsync();

            if (yesNoDialog.Result != Dialogs.Core.Enums.YesNoDialogType.Abort && PlantOrder != null)
            {
                var selectedProperty = (ComboBoxFilterProperty.SelectedItem as ComboBoxItem).Tag.ToString();
                var selectedAction   = (ComboBoxFilterAction.SelectedItem as ComboBoxItem).Tag.ToString();

                var elementFilter = new ElementFilterModel()
                {
                    Action       = selectedAction,
                    PropertyName = selectedProperty,
                    Filter       = filter,
                    EmployeeId   = CurrentEmployee.EmployeeId,
                    PlantOrderId = PlantOrder.Id
                };

                FilterCollection.Add(elementFilter);
                TextBoxFilter.Text = string.Empty;
                FilterFlyout.Hide();
                Filter(selectedProperty, selectedAction, filter);
                FilterCollection.SelectedFilter = elementFilter;

                if (yesNoDialog.Result == Dialogs.Core.Enums.YesNoDialogType.Yes)
                {
                    elementFilter.FilterId = await Proxy.UpsertElementFilter(elementFilter);
                }
            }
        }
Example #38
0
        /// <summary>
        ///     Adds an filter item to the collection if it doesn't already exist.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <param name="value">The value.</param>
        /// ///
        /// <param name="order">Filter order</param>
        /// <returns>TCollection.</returns>
        public static FilterCollection TryAdd(this FilterCollection col, Type value, int?order = null)
        {
            if (col.Any(t => t.GetType() == value))
            {
                return(col);
            }

            if (order.HasValue)
            {
                col.Add(value, order.Value);
            }
            else
            {
                col.Add(value);
            }

            return(col);
        }
Example #39
0
 private void setAudioCompressor()
 {
     if (_capture != null)
     {
         FilterCollection fc = _filters.AudioCompressors;
         if (fc != null && fc.Count > 0)
         {
             foreach (Filter f in fc)
             {
                 if (string.Compare(_audioCompressor, f.Name, StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     _capture.AudioCompressor = f;
                     break;
                 }
             }
         }
     }
 }
Example #40
0
        public static FilterCollection WithColorFilters(this FilterCollection filters)
        {
            filters.AddFilter("color_to_rgb", ToRgb);
            filters.AddFilter("color_to_hex", ToHex);
            filters.AddFilter("color_to_hsl", ToHsl);
            filters.AddFilter("color_extract", ColorExtract);
            filters.AddFilter("color_modify", ColorModify);
            filters.AddFilter("color_brightness", CalculateBrightness);
            filters.AddFilter("color_saturate", ColorSaturate);
            filters.AddFilter("color_desaturate", ColorDesaturate);
            filters.AddFilter("color_lighten", ColorLighten);
            filters.AddFilter("color_darken", ColorDarken);
            filters.AddFilter("color_difference", GetColorDifference);
            filters.AddFilter("brightness_difference", GetColorBrightnessDifference);
            filters.AddFilter("color_contrast", GetColorContrast);

            return(filters);
        }
Example #41
0
        public void RemoveItemWhenSortedShouldRemoveCorrectItems()
        {
            var model    = GridViewUtils.CreateModel();
            var filtered = new FilterCollection <DataItem>(model);

            // sort in reverse
            filtered.Sort = (x, y) => y.Id.CompareTo(x.Id);

            // test removing from the filtered collection
            filtered.RemoveAt(80);
            Assert.IsFalse(filtered.Any(r => r.Id == 19), "Removing the 80th filtered row should remove item #19");
            Assert.IsFalse(model.Any(r => r.Id == 19), "Removing the 80th filtered row should remove item #19 from the model");

            // test removing from the model
            model.Remove(model.First(r => r.Id == 20));
            Assert.IsFalse(filtered.Any(r => r.Id == 20), "Removing Item #20 should no longer show up in the filtered collection");
            Assert.IsFalse(model.Any(r => r.Id == 20), "Removing Item #20 should no longer be in the model");
        }
Example #42
0
        public DefaultPageLoader(
            IActionDescriptorCollectionProvider actionDescriptorCollectionProvider,
            IEnumerable <IPageApplicationModelProvider> applicationModelProviders,
            IViewCompilerProvider viewCompilerProvider,
            ActionEndpointFactory endpointFactory,
            IOptions <RazorPagesOptions> pageOptions,
            IOptions <MvcOptions> mvcOptions)
        {
            _collectionProvider        = actionDescriptorCollectionProvider;
            _applicationModelProviders = applicationModelProviders
                                         .OrderBy(p => p.Order)
                                         .ToArray();

            _viewCompilerProvider = viewCompilerProvider;
            _endpointFactory      = endpointFactory;
            _conventions          = pageOptions.Value.Conventions ?? throw new ArgumentNullException(nameof(RazorPagesOptions.Conventions));
            _globalFilters        = mvcOptions.Value.Filters;
        }
Example #43
0
        // ä½æē”Øč”Øč¾¾å¼ę ‘čŽ·å¾—åŠØę€ę‹¼ęŽ„whereę”ä»¶
        private Expression <Func <SMT_PTContextView, bool> > GetWhereExpression(string filterItems, string field)
        {
            var items  = filterItems.Replace("ē©ŗē™½", string.Empty).Split(',');
            var filter = new List <Filter>();

            foreach (var item in items)
            {
                filter.Add(new Filter()
                {
                    Operation = Op.Equals, PropertyName = field, Value = item
                });
            }
            var filters = new FilterCollection {
                filter
            };

            return(LambdaExpressionBuilder.GetExpression <SMT_PTContextView>(filters));
        }
        public ActionResult RenewalsDetail(string searchTerm,
                                           DateTime?expiryStartDate,
                                           DateTime?expiryEndDate,
                                           [Bind(Prefix = "extraFilters[]")] string[] extraFilters,
                                           int skip                 = 0,
                                           int take                 = 10,
                                           string sortField         = "PolicyId",
                                           string sortDirection     = "ASC",
                                           bool inclDeclar          = false,
                                           bool applyProfileFilters = true)
        {
            var filterCollection = FilterCollection.BuildCollection(Request);

            var totalDisplayRecords = 0;
            var totalRecords        = 0;


            var renewalDetailList = this.PolicyModule.GetRenewalPoliciesDetailed(
                expiryStartDate.HasValue
                    ? expiryStartDate.Value
                    : DateTime.Today.AddDays(-7),
                expiryEndDate.HasValue
                    ? expiryEndDate.Value
                    : DateTime.Today.AddDays(30),
                searchTerm,
                !string.IsNullOrEmpty(sortField) ? sortField : "PolicyId",
                !string.IsNullOrEmpty(sortDirection) ? sortDirection.ToUpper() : "ASC",
                skip,
                take,
                applyProfileFilters,
                inclDeclar,
                filterCollection,
                out totalDisplayRecords,
                out totalRecords);

            return(new JsonNetResult
            {
                Data = new
                {
                    results = renewalDetailList,
                    total = totalRecords
                }
            });
        }
Example #45
0
    public void CreateDescriptor_AddsGlobalFiltersWithTheRightScope()
    {
        // Arrange
        var actionDescriptor = new PageActionDescriptor
        {
            ActionConstraints  = new List <IActionConstraintMetadata>(),
            AttributeRouteInfo = new AttributeRouteInfo(),
            FilterDescriptors  = new List <FilterDescriptor>(),
            RelativePath       = "/Foo",
            RouteValues        = new Dictionary <string, string>(),
            ViewEnginePath     = "/Pages/Foo",
        };
        var handlerTypeInfo      = typeof(TestModel).GetTypeInfo();
        var pageApplicationModel = new PageApplicationModel(actionDescriptor, handlerTypeInfo, new object[0])
        {
            PageType  = typeof(TestPage).GetTypeInfo(),
            ModelType = typeof(TestModel).GetTypeInfo(),
            Filters   =
            {
                Mock.Of <IFilterMetadata>(),
            },
        };
        var globalFilters = new FilterCollection
        {
            Mock.Of <IFilterMetadata>(),
        };

        // Act
        var compiledPageActionDescriptor = CompiledPageActionDescriptorBuilder.Build(pageApplicationModel, globalFilters);

        // Assert
        Assert.Collection(
            compiledPageActionDescriptor.FilterDescriptors,
            filterDescriptor =>
        {
            Assert.Same(globalFilters[0], filterDescriptor.Filter);
            Assert.Equal(FilterScope.Global, filterDescriptor.Scope);
        },
            filterDescriptor =>
        {
            Assert.Same(pageApplicationModel.Filters[0], filterDescriptor.Filter);
            Assert.Equal(FilterScope.Action, filterDescriptor.Scope);
        });
    }
Example #46
0
 DataColumn AddDateColumnPart(string name, Func <EntityType, DateColumn> column, Func <EntityType, int> getValue)
 {
     return(AddColumn <int>(column(_instance).Caption + " " + name,
                            getValue,
                            y => getValue(y),
                            (y, v) =>
     {
         var fc = new FilterCollection();
         if (v == null)
         {
             fc.Add(column(y).IsEqualTo(Date.Empty));
         }
         else
         {
             fc.Add(() => getValue(y) == (int)v);
         }
         return fc;
     }, y => Date.IsNullOrEmpty(column(y))));
 }
Example #47
0
        private static void FindExistingResultActionFilterAndThrow(FilterCollection filters, string who)
        {
            foreach (var objFilter in filters)
            {
                if (objFilter is not TypeFilterAttribute attr)
                {
                    continue;
                }

                if (!attr.ImplementationType.IsAssignableTo(typeof(EnsureResponseResultActionFilter)))
                {
                    continue;
                }

                throw new ArgumentException(
                          $"You have already added an {attr.ImplementationType.Name}, the {who} can not be used."
                          );
            }
        }
Example #48
0
        /// <summary>
        /// Registers the Fluid filters from the given type.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="sourceType">Type that contains the static methods to register.</param>
        public static void RegisterFiltersFromType(this FilterCollection collection, Type sourceType)
        {
            var methods = sourceType.GetMethods(BindingFlags.Public | BindingFlags.Static)
                          .Where(a =>
            {
                var p = a.GetParameters();

                return(p.Length == 3 &&
                       p[0].ParameterType == typeof(FluidValue) &&
                       p[1].ParameterType == typeof(FilterArguments) &&
                       p[2].ParameterType == typeof(TemplateContext));
            })
                          .ToList();

            foreach (var m in methods)
            {
                collection.AddFilter(m.Name, ( FilterDelegate )m.CreateDelegate(typeof(FilterDelegate)));
            }
        }
Example #49
0
        public static FilterCollection WithLiquidViewFilters(this FilterCollection filters)
        {
            filters.AddAsyncFilter("t", Localize);
            filters.AddAsyncFilter("html_class", HtmlClass);
            filters.AddAsyncFilter("new_shape", NewShape);
            filters.AddAsyncFilter("shape_string", ShapeString);
            filters.AddAsyncFilter("clear_alternates", ClearAlternates);
            filters.AddAsyncFilter("add_alternates", AddAlternates);
            filters.AddAsyncFilter("clear_classes", ClearClasses);
            filters.AddAsyncFilter("add_classes", AddClasses);
            filters.AddAsyncFilter("shape_type", ShapeType);
            filters.AddAsyncFilter("display_type", DisplayType);
            filters.AddAsyncFilter("shape_position", ShapePosition);
            filters.AddAsyncFilter("shape_tab", ShapeTab);
            filters.AddAsyncFilter("remove_item", RemoveItem);
            filters.AddAsyncFilter("set_properties", SetProperties);

            return(filters);
        }
Example #50
0
        public override void What <T>(TypedColumnBase <T> col, T val)
        {
            var tcol = col as TextColumn;

            if (tcol != null)
            {
                var fc = new FilterCollection();
                var e  = col.Entity as ENV.Data.Entity;
                if (e != null && e.DataProvider is ENV.Data.DataProvider.DynamicSQLSupportingDataProvider)
                {
                    fc.Add("{0} like {1}", col, "%" + val + "%");
                }
                else
                {
                    fc.Add(() => tcol.Value.Contains(val.ToString()));
                }
                result = fc;
            }
        }
Example #51
0
        /// <summary>
        ///     Adds a type to a <see cref="FilterCollection" /> if it doesn't already exist.
        /// </summary>
        /// <typeparam name="TType">The type of the t type.</typeparam>
        /// <param name="col">The col.</param>
        /// <param name="order">Filter order</param>
        /// <returns>FilterCollection.</returns>
        public static FilterCollection TryAdd <TType>(this FilterCollection col, int?order = null)
            where TType : IFilterMetadata
        {
            var vt = typeof(TType);

            if (col.All(t =>
            {
                // Yet more lameness, really should be able to do a simple test here...
                return(t switch
                {
                    TypeFilterAttribute tf => tf.ImplementationType != vt,
                    ServiceFilterAttribute sf => sf.ServiceType != vt,
                    FormatFilterAttribute ff => ff.GetType() != vt,
                    ResultFilterAttribute rs => rs.GetType() != vt,
                    ExceptionFilterAttribute ef => ef.GetType() != vt,
                    ActionFilterAttribute af => af.GetType() != vt,
                    _ => t.GetType() != vt
                });
            }
        public void LoadDocumentStrings()
        {
            //Read all of the document strings into our main collection and grid controls
            if (Document == null)
            {
                return;
            }
            m_collection.Clear();
            for (var i = 0; i < Document?.Strings.Count; i++)
            {
                m_collection.Add(new UserStringItem {
                    Key = Document?.Strings.GetKey(i), Value = Document?.Strings.GetValue(i)
                });
            }
            m_filter_collection = new FilterCollection <UserStringItem>(m_collection);
            Filter();

            UpdateStrings = false;
        }
        /// <summary>
        ///
        /// Find on a field value
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        IEntityInstanceEnumerator FindStuff(String name, String value)
        {
            FilterCollection fc    = _entityInst.GetFinderFilters();
            FilterCollection newfc = new FilterCollection();

            for (int i = 0; i < fc.Count; i++)
            {
                if (fc[i].GetType().FullName == "Microsoft.Office.Server.ApplicationRegistry.Runtime.WildcardFilter")
                {
                    if (string.IsNullOrEmpty(name) || (0 == string.Compare(fc[i].Name.ToLower(), name.ToLower())))
                    {
                        newfc.Add
                            (fc[i]);
                    }
                }
            }
            ((WildcardFilter)newfc[0]).Value = "%" + value + "%";
            return(_entityInst.FindFiltered(newfc, _lobInst));
        }
Example #54
0
        public void Setup()
        {
            TestUtils.Invoke(() =>
            {
                grid = new GridView();
                // Some platforms need at least one column for selection to work
                grid.Columns.Add(new GridColumn {
                    HeaderText = "Text", DataCell = new TextBoxCell("Id")
                });
                model = GridViewUtils.CreateModel();

                // create our filtered collection
                filtered               = new FilterCollection <DataItem>(model);
                filtered.Change        = () => grid.SelectionPreserver;
                grid.DataStore         = filtered;
                grid.SelectionChanged += (s, e) => selectionChangedCount++;
                selectionChangedCount  = 0;
            });
        }
Example #55
0
        internal ApiQuery(Api api, EntitySchema entity)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            _api   = api;
            Entity = entity;

            Filters = new FilterCollection();
            Expand  = new StringCollection();
            Order   = new QueryOrderCollection();
            Output  = OutputFormat.Compact;
        }
Example #56
0
        private void Initializer()
        {
            _Filter = new FilterCollection();

            _FilterType = FilterTypes.NoFilter;
            _Errors = new ErrorCollection();

            _TextFrames = new FramesCollection<TextFrame>();
            _UserTextFrames = new FramesCollection<UserTextFrame>();
            _PrivateFrames = new FramesCollection<PrivateFrame>();
            _TermOfUseFrames = new FramesCollection<TermOfUseFrame>();
            _TextWithLangFrames = new FramesCollection<TextWithLanguageFrame>();
            _SynchronisedTextFrames = new FramesCollection<SynchronisedText>();
            _AttachedPictureFrames = new FramesCollection<AttachedPictureFrame>();
            _EncapsulatedObjectFrames = new FramesCollection<GeneralFileFrame>();
            _PopularimeterFrames = new FramesCollection<PopularimeterFrame>();
            _AudioEncryptionFrames = new FramesCollection<AudioEncryptionFrame>();
            _LinkFrames = new FramesCollection<LinkFrame>();
            _DataWithSymbolFrames = new FramesCollection<DataWithSymbolFrame>();
            _UnknownFrames = new FramesCollection<BinaryFrame>();
        }
Example #57
0
        public void FilterCollectionTest()
        {
            byte[] source = new byte[]
            { 0X21, 0X58, 0X44, 0XAA, 0XDD, 0XDD, 0XDD, 0X0B, 0XAA, 0XAA, 0X22, 0X23, 0X24 };
            string pattern = "21 58 44";
            Filter f = new Filter(pattern);

            string pattern2 = "22 23 24";
            Filter f2 = new Filter(pattern2);

            string pattern3 = "dd dd dd";
            Filter f3 = new Filter(pattern3);

            FilterCollection fs = new FilterCollection();
            fs.Add(f);
            fs.Add(f2);
            fs.Add(f3);

            source = fs.Filt(source);
            string str = HexStringConverter.Default.ConvertToObject(source).ToString();
            Console.WriteLine(str);
            Assert.AreEqual(3, source.Length);
        }
      public void Contains_Type_ReturnsFiltersOfType()
      {
         FilterCollection<int> filters = new FilterCollection<int>();
         Filter<int> filterInt = new Mock<Filter<int>>().Object;
         Filter<double> filterDouble = new Mock<Filter<double>>().Object;
         filters.Add(filterInt);

         Assert.IsTrue(filters.Contains(filterInt.GetType()));
         Assert.IsFalse(filters.Contains(filterDouble.GetType()));
      }
      public void Clear_RaisesFiltersClearedEvent()
      {
         int filtersClearedEventRaised = 0;
         FilterCollection<int> filters = new FilterCollection<int>();
         filters.FiltersCleared += (sender, args) => filtersClearedEventRaised++;

         filters.Clear();

         Assert.AreEqual(1, filtersClearedEventRaised);
      }
      public void Add_Null_ThrowsException()
      {
         FilterCollection<int> filters = new FilterCollection<int>();

         filters.Add(null);
      }