Craig Sutherland: Considering XAML for Config for CruiseControl.NET
Interesting to see “From NetReflector to XAML” from Craig Sutherland detailing an exploration of using XAML for Config for CruiseControl.NET.
WPF’s XamlReader.Load vs System.Xaml’s XamlServices.Load()
CS: “although from what I understand WPF will still have its own implementation”
RR: WPF 4’s API XamlReader.Load’s goal is to be compatible, yet better, than the WPF 3 version of XamlReader.Load. This call does some special things for WPF (see Mike Shim’s “Use XamlReader.Load for WPF XAML (not XamlServices.Load)” for details. For Config scenarios, XamlServices.Load/Save would be ideal…that is what I do wth XamlPadSample as detailed in “Persistable View Models & XAML for Config”
Representing Time
Craig shows the use of a markupextension for Time: {Time 5} or {Time 30, Unit=Minutes}, etc…
A few options to consider (for Interval.Period, SubVersion.Timeout, Project.ModificationDelay, etc…) would be:
- Keep using the {Time} markupextension. Decent readability…
- Make those properties of type TimeSpan, which has a type converter that will convert to/from a string – see DoubleAnimation.Duration, for example:
<DoubleAnimation Storyboard.TargetName="MyAnimatedRectangle" Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever" />
- Keep those property of type Int32, but use a “A Type Converter Declared on a Property” (see “Strings to Things (or How XAML interprets Attribute Values”) to introduce a TypeConverter than knows how to convert a string representing a time to integers. Similar approach allows UIElement.Height/.Width use “1in”, “96px”, etc…