# DeviceAtlas Device Detection API Config #
DeviceAtlas DeviceApi Config class provides options to customize the API
behavior in terms of memory use, caching, performance and device properties.
### Settings (Config Class Attributes) ###
* [Cache Settings](#cache_settings)
* [Include User-Agent Properties](#include_ua_props)
* [Include Language Properties](#include_lang_props)
* [Return NULL When There Are No Properties](#return_null_when_no_properties)
* [Client-side Cookie Name](#cookie_name)
#### Cache Settings ####
An internal cache can be used to gain performance. The number of entries can be
changed. Note that if it set to zero, the cache is disabled.
**Config methods**
```
MaxCacheEntries
MaxCacheEntries =
```
**Default value**
4096
#### Include User-Agent Properties ####
Boolean value to enable/disable the addition of User-Agent properties to the
detection. They are also known as "dynamic" properties as they can be detected
on the fly by directly parsing the User-Agent.
Enabling this property will worsen API detection performance. If you don't need
these properties, then set it to false.
User-Agent/Dynamic properties: browserName, browserVersion,
browserRenderingEngine, osName, osVersion
**Config Methods**
```
IncludeUaProps
IncludeUaProps = true/false
```
**Default Value**
true
#### Include Language Properties ####
Boolean value to enable/disable the addition of client's language and locale
preferences to the device property set.
If you don't need these properties, then set it to false.
Language properties: language, languageLocale
**Config Methods**
```
IncludeLangProps
IncludeLangProps = true/false
```
**Default Value**
true
#### Return NULL When There Are No Properties ####
Boolean value to make the API either return NULL if the property set to return
is empty, or a Properties object with no values inside.
**Config Methods**
```
ReturnNullWhenNoProperties
ReturnNullWhenNoProperties = true/false
```
**Default Value**
false
#### Client-side Cookie Name ####
Name of the cookie where the Client-side properties will be saved in.
When using getProperties() method in a web application (DeviceApiWeb), the
detection will automatically use the content of this cookie, if it exists.
If you want the Client-side properties to be used add the DeviceAtlas client
side component (JavaScript lib) to your web-site pages.
When the User-Agent or HTTP headers are passed manually to getProperties(), the
Client-side properties can be also manually passed to this method as second
parameter.
Note that this config is only used as an argument of getProperties().
If you set the cookie name to NULL, then the Client-side properties cookie will
be ignored.
**Config methods**
```
CookieName
CookieName = cookieName
```
**Default value**
"DAPROPS"
### How It Works ###
Translating into code how the API settings are used, it is as simple as having
an instance of the mobi.mtld.da.device.Config class into the
mobi.mtld.da.device.DeviceApi object and the respective Config public methods
to check the wished settings and make the API work according to them.
#### Use Of the Default Settings ####
When a new instance of the mobi.mtld.da.device.DeviceApi class is created,
internally another instance of the mobi.mtld.da.device.Config class is generated
with the default settings.
```csharp
deviceApi = new DeviceApi();
```
#### Use Of Custom Settings ####
In order to use custom settings, it is required to explicitly create a
Config object, set the settings and pass it to the DeviceApi instance.
```csharp
/* Preferred method */
config = new Config();
config.MaxCacheEntries = 1024;
config.IncludeUaProps = false;
deviceApi = new DeviceApi(config);
```
```csharp
/* Alternative method */
deviceApi = new DeviceApi();
config = new Config();
config.IncludeUaProps = false;
deviceApi.setConfig(config);
```
### Example Of Use Case ###
For the scenario your system works, it is highly recommended to configure the
API with the most convenient settings in order to enhance performance, memory
footprint and, in general, provide a better user experience.
```csharp
/* Reduce response time and memory footprint for a web application */
config = new Config();
// Set the number of maximum entries held in the internal cache.
config.MaxCacheEntries = 256;
// Boost API performance by ignoring dynamic properties if they are not part of
// the property set you expect.
config.IncludeUaProps = false;
// Ignore language and locale properties if they are not needed.
config.IncludeLangProps = false;
// Finally set the config to our new instance of the DeviceAtlas API.
deviceApi = new DeviceApi(config);
```
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_ Copyright (c) DeviceAtlas Limited 2022. All Rights Reserved. https://deviceatlas.com _