Refector (available for download at http://www.aisto.com/roeder/dotnet/) is a utility that allows you to look at the properties available on an interface. For example, if you are wanting to display a property of an Item on the ItemForm, but don't know how it is spelled, you can do the following:
- Start Reflector
- File | Open BirdDogSoftware.Interfaces.dll (this is in the bin directory of your web site)
- Click the plus signs on BirdDogSoftware.Interfaces until you see a long list
- Scroll down to IItem and click the plus sign, you will see a list of all the available properties
In some cases the property you want may be the property of another object that is related. For example, if you want to display Quantity On Hand for a paticular Item, you have a couple of options:
- Item.Qty_On_Hand - This displays the total Quantity On Hand for this Item at all locations
- Item.Location("LA").Qty_On_Hand - This displays the Quantity On Hand for the LA location
- Item.Locations - This allows you to bind a List Control (Grid, Repeater, ListBox) to the collection of ItemLocations for this item
The key when looking at the display in Reflector is noticing the 'Type' of the property. Item.Qty_On_Hand is a Double (a floating point number), whereas Item.Location is an IItemLocation and requires a parameter called Loc (which you can see at the bottom of Reflector when you click on Location). Since IItemLocation is another complex Type like IItem, in Reflector you can click on IItemLocation at the bottom of the screen and Reflector will show you the properties of it. Item.Locations is another complex type, but this time it is an IItemLocationCollection. Anytime you see the word 'Collection' at the end of a type, that lets you know that this type will hold 0 to many objects of the type before the word 'Collection'. So, in this case, we know when we reference Item.Locations we will get an object that has 0 or more IItemLocation objects in it. The easiest way to deal with these objects is to bind them to some kind of List control. You can also reference them directly by Index, ie Item.Locations(0) will return the first IItemLocation.
In some cases the interface you are looking at may be composed of other interfaces. For example, when looking at ICustomer, you will notice there is no Name property, which seems odd since displaying Customer.Name is legal throughout the web site. The issue is that ICustomer inherits from IParty. You can tell this in Reflector by clicking on ICustomer and looking at the bottom of the screen. Notice that Reflector says "public interface ICustomer : IParty" and that IParty is clickable. Click on IParty and Reflector will take you to its' definition, where all of its' properties are available.
Another special case is Enumerations. These are numeric values that have been assigned text descriptions easily readable by humans. An example of this is the InvoiceMethod property on ICustomer. When viewing this property in Reflector, notice that its' type is InvoiceMethods. If you click on this property and look down at the bottom you will see that InvoiceMethods is clickable. Click on InvoiceMethods and Reflector takes you to its' definition. Click on the plus sign and you will see all the available values. Enumerations can be bound to a display control like any other simple property: Customer.InvoiceMethod, however to set them (on the BillTo.aspx page, for example), use the syntax Customer.InvoiceMethod = ICustomer.InvoiceMethods.eMail.