Developer forum

Forum » Development » Setting default in configurable add-in

Setting default in configurable add-in

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

How do you set defaults for properties of a configurable add-in? I tried setting them in the constructor of an AddressValidatorProvider like this:

public MyAddressValidatorProvider()
{
  ApiUrl = "http://my.url";
}

But then the user defined values are no longer applied and I see my defaults again when editing the add-in. Is there a way to detect if the add-in is configured for the first time? Or can I handle this some other way?

Imar


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Imar,

Due to the way property values are set on ConfigurableAddIn objects, you need to specify default values on the property instead of in your constructor.

- Jeppe

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Great, thanks, that did the trick. In my case, I had to convert my automatic properties to properties with a backing field, and then assign a default value to the private field as I am using C# pre 6.0.

Thanks!

Imar

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

That's one of the few places where VB was actually ahead of C#. Definitely a great addition to C# 6.0 :)

Glad you got it working :)

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yep, totally!

 
Nicolai Høeg Pedersen
Reply

{VB rocks}

Oh, and some more characters you do not need {{{{{{{}}}}}}}}}};;;;;;;;;;;;;

 

You must be logged in to post in the forum