Optional parameters

Optional parameters

This question is answered

Hey.

I need to create for certain widgets that we are developing, a method whose parameters can be accessed from "velocity" as optional parameters, as can be verified in the documentation.

example:

#set($groupResponse = $core_v2_group.Get("%{Id = $idArg, Key = $keyArg, ParentGroupId = $parentGroupIdArg}"))

I tried nullable parameter, with default value, ​​as "param", class instance etc. all are considered as required parameters.

thanks

Verified Answer
  • Our objects pass in a dictionary that can contain or not contain data depending on your use case:
     
    public void DoSomething(IDictionary options)
    {
                    If(options[“key”] != null)
                                    doSomethingElse();
    }
     
    You are responsible for enforcing whether or not something is required(in the dictionary or not)
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: nazario [mailto:bounce-nazario@communities.telligent.com]
    Sent: Wednesday, May 09, 2012 11:10 AM
    To: discussion_evolution@communities.telligent.com
    Subject: [Telligent Evolution Platform Discussion] Optional parameters
     

    Hey.

    I need to create for certain widgets that we are developing, a method whose parameters can be accessed from "velocity" as optional parameters, as can be verified in the documentation.

    example:

    #set($groupResponse = $core_v2_group.Get("%{Id = $idArg, Key = $keyArg, ParentGroupId = $parentGroupIdArg}"))

    I tried nullable parameter, with default value, ​​as "param", class instance etc. all are considered as required parameters.

    thanks

  • To document the parameters the IDictionary can support, you can use the DocumentationAttribute in the Telligent.Evolution.Extensibility.Version1 namespace.  You can apply multiple attributes to the dictionary.  For each optional parameter, the attribute supports the name, type, description, list of options, and default.  Here's the signature for the method in your screenshot:

    using Telligent.Evolution.Extensibility.Version1;

    [Documentation("...")]

    public PagedList<TaggedContent> ListTaggedContent(IList<string> tags, [

       Documentation(Name = "PageIndex", Type = typeof(int), Description = "...", Default = 0),

       Documentation(Name = "PageSize", Type = typeof(int), Description = "...", Default = 20),

       Documentation(Name = "GroupId", Type = typeof(int)) ]

       IDictionary options)

    {

    }

All Replies
  • Our objects pass in a dictionary that can contain or not contain data depending on your use case:
     
    public void DoSomething(IDictionary options)
    {
                    If(options[“key”] != null)
                                    doSomethingElse();
    }
     
    You are responsible for enforcing whether or not something is required(in the dictionary or not)
    Patrick Mason
    Development Lead- Extensibility
    o: 214.420.1329
    telligent.com
     
    From: nazario [mailto:bounce-nazario@communities.telligent.com]
    Sent: Wednesday, May 09, 2012 11:10 AM
    To: discussion_evolution@communities.telligent.com
    Subject: [Telligent Evolution Platform Discussion] Optional parameters
     

    Hey.

    I need to create for certain widgets that we are developing, a method whose parameters can be accessed from "velocity" as optional parameters, as can be verified in the documentation.

    example:

    #set($groupResponse = $core_v2_group.Get("%{Id = $idArg, Key = $keyArg, ParentGroupId = $parentGroupIdArg}"))

    I tried nullable parameter, with default value, ​​as "param", class instance etc. all are considered as required parameters.

    thanks

  • thank you very much for the quick and accurate response. With the type IDictionary can pass optional parameters, but it would be useful to identify the name of each parameter expected with the purpose of better documentation.

    Preferably something like this:

    Instead of this:

    Although in both cases you can pass the same number of parameters.

    Thanks again.

  • To document the parameters the IDictionary can support, you can use the DocumentationAttribute in the Telligent.Evolution.Extensibility.Version1 namespace.  You can apply multiple attributes to the dictionary.  For each optional parameter, the attribute supports the name, type, description, list of options, and default.  Here's the signature for the method in your screenshot:

    using Telligent.Evolution.Extensibility.Version1;

    [Documentation("...")]

    public PagedList<TaggedContent> ListTaggedContent(IList<string> tags, [

       Documentation(Name = "PageIndex", Type = typeof(int), Description = "...", Default = 0),

       Documentation(Name = "PageSize", Type = typeof(int), Description = "...", Default = 20),

       Documentation(Name = "GroupId", Type = typeof(int)) ]

       IDictionary options)

    {

    }