views:

110

answers:

1

I've already done many configs where dictionaries are passed into services in the <parameters> block.

But what I find myself needing right now is to build a NameValueCollection (allowing multiple entries with the same key) or a Collection of KeyValuePair objects.

The reason for this is im not using this dictionary to look up b when given a, im basically using it to pass in a Tuple (pair) of (a,b) to be used later in code.

Im kind of new to castle windor and I was wondering how i would go about making a List of KeyValuePair's injected, or a NameValueCollection injected.

What i need is something that looks like this:

<component
    id="Shipper.Air"
    service="CheckoutSystem.Shipping.IShipper, Components"
    type="CheckoutSystem.Shipping.ConditionalShipper, Components">
    <parameters>
      <id>8AED4A27-B5C2-46ad-BEDE-58DCB38F60DA</id>
      <MustSatisfy>True</MustSatisfy>
      <Shippers>
        <dictionary>
          <item key="Ups">${Shipper.UpsAir}</item>
          <item key="CanadaPost">${Shipper.CanadaPostAir}</item>
        </dictionary>
      </Shippers>
      <Conditions>
        <NameValueCollection> <!-- START Example -->
          <item key="Ups">$(ShipperCondition.HeavyItems}</item>
          <item key="CanadaPost">${ShipperCondition.FarNorth}</item>
          <item key="Ups">${ShipperCondition.Default}</item>
        </NameValueCollection> <!-- END Example -->
      </Conditions>
    </parameters>
  </component>