more G-Labs products

Author Topic: Looping through Program Parameters  (Read 1474 times)

April 13, 2014, 12:54:50 PM
Read 1474 times

Jan

  • **
  • Information
  • Jr. Member
  • Posts: 34
Just a quick (and probably quite easy to answer) question:

I know that you can access program parameters by calling  Program.Parameter().

But you need to know the parameter name for that.

So my question would be: how do I create a loop in c# that runs through all available parameters or input fields of a program and checks or applies settings.

Thanks in advance,
jan

April 13, 2014, 03:17:50 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Usually a program should know parameter names and what to do with it.
Anyway you can get the instance of a program module like this:

Code: [Select]
var module = Modules.WithName("The Program Name").Get();
foreach(ModuleParameter p in module.Instance.Properties)
{
    //....
}

for details about ModuleParameter class see:

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Data/ModuleParameter.cs

Cheers,
g.

April 14, 2014, 01:12:48 AM
Reply #2

Jan

  • **
  • Information
  • Jr. Member
  • Posts: 34
Hey Gene,

as always, thanks for the quick response and the help!

Now that you explained this, it seems quite logical to create a local instance with the properties by calling the get() function. I'm slowly getting the details  ;)

Thanks again,
jan