title: Can a DynamicParameter rely on the values of other DynamicParameters?
body: <p>I have a <code>GetDynamicParameters()</code> on cmdlet <code>Get-DateSlain</code> that does something like this:</p>
  
  <pre><code>    public object GetDynamicParameters()
      {
          List&lt;string&gt; houseList = {"Stark", "Lannister", "Tully"};
  
          var attributes = new Collection&lt;Attribute&gt;
              {
                  new ParameterAttribute
                  {
                      HelpMessage = "Enter a house name",
                  },
                  new ValidateSetAttribute(houseList.ToArray()),
              };
  
          if (!this.ContainsKey("House"))
          {
              this.runtimeParameters.Add("House", new RuntimeDefinedParameter("House", typeof(string), attributes));
          }
      }
  </code></pre>
  
  <p>And this works as expected - users can type <code>Get-DateSlain -House</code>, and tab through the available houses.  However, once a house is chosen, I want to be able to narrow down the results to characters in that house.  Furthermore, if it's house 'Stark', I want to allow a <code>-Wolf</code> parameter. So to implement (some value validity checks removed for brevity):</p>
  
  <pre><code>    public object GetDynamicParameters()
      {
          if (this.runtimeParameters.ContainsKey("House"))
          {
              // We already have this key - no need to re-add. However, now we can add other parameters
              var house = this.runtimeParameters["House"].Value.ToString();
              if (house == "Stark")
              {
                  List&lt;string&gt; characters = { "Ned", "Arya", "Rob" };
                  var attributes = new Collection&lt;Attribute&gt;
                  {
                      new ParameterAttribute
                      {
                          HelpMessage = "Enter a character name",
                      },
                      new ValidateSetAttribute(characters.ToArray()),
                  };
  
                  this.runtimeParameters.Add("Character", new RuntimeDefinedParameter("Character", typeof(string), attributes));
  
                  List&lt;string&gt; wolves = { "Shaggydog", "Snow", "Lady" };
                  var attributes = new Collection&lt;Attribute&gt;
                  {
                      new ParameterAttribute
                      {
                          HelpMessage = "Enter a wolf name",
                      },
                      new ValidateSetAttribute(wolves.ToArray()),
                  };
  
                  this.runtimeParameters.Add("Wolf", new RuntimeDefinedParameter("Wolf", typeof(string), attributes));
              }
              else if (house == "Lannister")
              {
                  List&lt;string&gt; characters = { "Jaimie", "Cersei", "Tywin" };
                  // ...
              }
              // ...
  
              return this.runtimeParameters;
          }
  
          List&lt;string&gt; houseList = {"Stark", "Lannister", "Tully"};
  
          var attributes = new Collection&lt;Attribute&gt;
          {
              new ParameterAttribute
              {
                  HelpMessage = "Enter a house name",
              },
              new ValidateSetAttribute(houseList.ToArray()),
          };
  
          this.runtimeParameters.Add("House", new         RuntimeDefinedParameter("House", typeof(string), attributes));
      }
  </code></pre>
  
  <p>This looks like it should work, but it doesn't. The <code>GetDynamicParameters</code> function is only called once, and that is before a value is supplied to <code>this.runtimeParameters["House"]</code>. Since it doesn't re-evaluate after that value is filled in, the additional field(s) are never added, and any logic in <code>ProcessRecord</code> that relies on these fields will fail.</p>
  
  <p>So - is there a way to have multiple dynamic parameters that rely on each other?</p>