Skip to main content
Home  ›  Blog

Custom DataSource API - EnsureConfigurationIsLoaded

If a DataSource is configurable, then configuration must parse tokens before accessing the values. This is done with EnsureConfigurationIsLoaded.

This is part of the new API for DataSources released in 2sxc 9.13.

How to use EnsureConfigurationIsLoaded

Here's a simple example of the PublishingFilter DataSources:

EnsureConfigurationIsLoaded in the PublishingFilter

// get the correct stream, depending on ShowDrafts
private IEnumerable<IEntity> GetList()
    Log.Add($"get incl. draft:{ShowDrafts}");
    var outStreamName = ShowDrafts 
        ? Constants.DraftsStreamName 
        : Constants.PublishedStreamName;
    return In[outStreamName].List;

This example needs ShowDrafts to be boolean (true/false), but the built-in token-template for it is [Settings:ShowDrafts||false]. This is why EnsureConfigurationIsLoaded() must be called first.

Advanced Use Cases

There are more things to discover in advanced scenarios. You can read about it in the Wiki on EnsureConfigurationIsLoaded.

Love from Switzerland,

Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler