Skip to content

Extensibility

MisterHoker edited this page Mar 6, 2021 · 2 revisions

Extensibility

QueryNinja is build with ability to extend current capabilities of filtering and ordering without much efforts.
All extensibility built around QueryNinja.Core package. All Sources and Targets inherits and use Extensibility defined in the core.

How to create own IQueryComponent?

To create own QueryComponent you have to inherit this interface.
Ideally, you might want to register your QueryComponent inside QueryNinjaExtensions.Configure.RegisterComponent.

QueryNinjaExtensions.Configure.RegisterComponent<YourFilter>();

This is needed because some Source and Targets might need to know existing QueryComponents to siplifdy interaction.

P.S. AspNetCore Source use known QueryComponents to build factories in runtime.

How to create own IDefaultFilter?

By default, all Sources and Targets allow to register user-defined IDefaultFilter without significant efforts.
More on that in Queryable source and AspNetCore Target documentations.

To create own IDefaultFilter you have to define your Operations enum for your filter and implement interface.
Make sure that your Operations enum members does not overlap with other IDefaultFilters you are using.

Sample can be found in the repository for DatabaseFunctions

Also, IDefaultFilter should be registered in:

QueryNinjaExtensions.Configure.RegisterComponent<YourFilter>();

How to enable own IQueryComponent in existing Sources and Targets?

To enable custom IQueryComponent in extensions you will have to implement specific descendant of IQueryComponentExtension that belongs to desired Source or Target. More on that in Queryable source and AspNetCore Target documentations.

How to create own Source?

There are only few rules to create own Source:

  • Your sources should provide valid instances of IQuery interfaces. Default implementaiton can be taken from QueryNinja.Core.
  • If you plan to contribute your Source, make sure you've implemented simplified way of registering for IDefaultFilter.

How to create own Target?