Rockford Lhotka
    CTO at Magenic
    Author, speaker, software architect
    Creator of the CSLA .NET framework

Home
Blog
CSLA .NET
Magenic
Speaking
Publications
About me
Contact me

Login

Version 3.0 change log

 

This document is the change log for version 3.0 of CSLA .NET.

 

Changes and Enhancements:

 

Csla - DataPortal  (070223-C#/VB)

Add a WCF data portal channel. This has the same structure as the existing channels (remoting, enterprise services, web services), but uses WCF as the network transport. To this end, there’s both a client-side proxy (Csla.DataPortalClient.WcfProxy) and a server-side host (Csla.Server.Hosts.WcfPortal).

 

You can see an example of using this new channel in the ProjectTracker app. Notice the new WcfHost web site, which hosts the server-side component, and the changes to the App.config file for PTWin. Those same config changes can be used by PTWeb as well, or any other client environment.

 

Csla - DataPortal  (070424-C#/070504-VB)

Raise a static/Shared DataPortalInitInvoke event from the client-side DataPortal. This event is raised immediately before the data portal context is initialized, which means that the event handler can do things like ensure that Csla.ApplicationContext.User contains a valid value. This is required to support WPF, where it is otherwise impossible to set the thread’s principal object to a valid value in certain cases.

 

Csla - Serialization (070227-C#/VB)

Add support for the WCF NetDataContractSerializer, and thereby for the DataContract and DataMember attributes. It is now possible to specify, in your app.config or web.config, that you want to use the NetDataContractSerializer rather than the BinaryFormatter for cloning and n-level undo.

 

This does not affect the pre-existing data portal channels! If you decorate your objects with DataContract/DataMember then you must use the WCF data portal channel, as it is the only channel that also supports those attributes. The local data portal channel also works, as it doesn’t serialize the objects.

 

There is a new config file option that goes in the <appSettings> block: CslaSerializationFormatter. The allowed values are BinaryFormatter or NetDataContractSerializer. The default (if you don’t supply the value) is BinaryFormatter, thus providing backward compatibility.

 

Csla\Wpf – IdentityConverter (070227-C#/VB)

Add a WPF value converter that implements the identity converter. This means it is a converter that returns the same value it is provided at all times. While this may seem silly, it is actually critical, because the only way to ensure that WPF data binding properly updates UI fields as they change is by associating some value converter with every data bound UI field. In cases where you do want to convert the value, using a specific value converter is fine. But in cases where you would normally not convert the value, the IdentityConverter should be used. The result is that no conversion takes place, but data binding will properly update the UI as values are changed in your objects.

 

Usage in a page is generally like this:

<Page x:Class="PTWpf.ProjectEdit"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:csla="clr-namespace:Csla.Wpf;assembly=Csla" 

    Title="Project Edit"

    >

  <Page.Resources>

    <csla:IdentityConverter x:Key="IdentityConverter" />

  </Page.Resources>

          <TextBox Name="NameTextBox" 

           Text="{Binding Name,

           Converter={StaticResource IdentityConverter}}">

          </TextBox>

 

 

Csla\Wpf – Validator (070301-C#/070504-VB)

Renamed on 070621

Add a Validator control to support Windows Forms ErrorProvider-like behaviors to WPF. Usage in a page is generally like this:

 

<Page x:Class="PTWpf.ProjectEdit"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:csla="clr-namespace:Csla.Wpf;assembly=Csla" 

    Title="Project Edit"

    >

      <csla:Validator>

        <StackPanel>

          <TextBox Name="NameTextBox" 

           Text="{Binding Name,

           Converter={StaticResource IdentityConverter}}">

          </TextBox>

        </StackPanel>

      </csla:ValidationPanel>

 

Csla\Wpf – CslaDataProvider (070301-C#/070504-VB)

Add a CslaDataProvider control to support WPF data binding through XAML. This control allows a CSLA-style object’s type, factory method and parameters to that method to be specified through XAML markup. In some cases this allows the creation of a CSLA-style business object without the need to write any code.

 

Usage in a page is generally like this:

<Page x:Class="PTWpf.ProjectEdit"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:csla="clr-namespace:Csla.Wpf;assembly=Csla" 

    xmlns:system="clr-namespace:System;assembly=mscorlib"

    xmlns:src="clr-namespace:WindowsApplication1" 

    Title="Project Edit"

    >

  <Page.Resources>

      <csla:CslaDataProvider x:Key="PersonList"

                             ObjectType="{x:Type src:PersonList}"

                             FactoryMethod="GetList"

                             IsAsynchronous="False"

                             ManageLifetime=”False”>

        <csla:CslaDataProvider.FactoryParameters>

          <system:String>Test</system:String>

        </csla:CslaDataProvider.FactoryParameters>

      </csla:CslaDataProvider>

  </Page.Resources>

      <DockPanel DataContext="{Binding Source={StaticResource PersonList}}">

      </DockPanel>

 

Csla\Wpf – Authorizer (070301-C#/070504-VB)

Renamed 070621

Moved NotVisibleMode to be an attached property 070629

Add an Authorizer control for WPF to support the use of Csla.Security.IAuthorizeReadWrite. This panel control automatically reacts to whether the user is authorized to read/write each property data bound to the controls inside the panel.

 

If the user is not authorized to read a control, that control is hidden (not visible, but with space allocated on the display). If the user is not authorized to write to a control, and that control has an IsReadOnly property, that property is set to true. Otherwise IsEnabled is set to false.

 

Usage in a page is generally like this:

 

<Page x:Class="PTWpf.ProjectEdit"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:csla="clr-namespace:Csla.Wpf;assembly=Csla" 

    Title="Project Edit"

    >

      <csla:Authorizer>

        <StackPanel>

          <TextBox Name="NameTextBox" 

           Text="{Binding Name,

           Converter={StaticResource IdentityConverter}}">

          </TextBox>

        </StackPanel>

      </csla:Authorizer>

 

You can also set a NotVisibleMode property on a per-control basis:

 

<Page x:Class="PTWpf.ProjectEdit"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:csla="clr-namespace:Csla.Wpf;assembly=Csla" 

    Title="Project Edit"

    >

      <csla:Authorizer>

        <StackPanel>

          <TextBox Name="NameTextBox"
           csla:Authorizer.NotVisibleMode=”Collapsed”

           Text="{Binding Name,

           Converter={StaticResource IdentityConverter}}">

          </TextBox>

        </StackPanel>

      </csla:Authorizer>

 

 

Csla\Validation – RuleArgs (070304-C#/VB)

Add two new constructor overloads to RuleArgs, making it easier to set the initial default Severity and StopProcessing values. It is important to realize that the same RuleArgs object is used for all rule invocations! This means that if the rule method changes the Severity or StopProcessing  property values, the changed values become the “default”. For this reason, these constructors should only be used for rule methods that do not explicitly set e.Severity or e.StopProcessing.

 

Csla\Validation – RuleDescription (070312-C#/VB)

Add a RuleDescription class that contains the code to parse a rule:// URI. While not strictly necessary, this class should simplify the use of the rule:// URIs returned from ValidationRules.

 

Csla\Validation – CommonRules (070312-C#/VB)

Add a StringMinLength validation rule.

 

Csla\Validation – CommonRules (070312-C#/VB)

Change RegExMatch rule method so it supports null values. There are three options available: automatically return true, automatically return false or convert the null value to an empty string and execute the regular expression.

 

Csla – BusinessListBase (070312-C#/VB)

Change the remove and set functionality so the to-be-deleted child object is removed from the list and added to the deletedList before the ListChanged event is raised. This allows the UI to handle the ListChanged event, knowing that the collection is in its final state at the point the event is being handled.

 

Csla\Wpf – DataDecoratorBase (070315-C#/070504-VB)

Renamed 070621

The DataDecoratorBase handles detection of changes to the underlying DataContext, related data object and any property or list changed events raised by that data object. All these changes are provided to subclasses through a set of abstract virtual methods. The Validator, Authorizer and ObjectStatus are now subclasses of this base panel.

 

Csla\Wpf – ObjectStatus (070313-C#/070504-VB)

Renamed 070621

Add ObjectStatus control to wrap and expose a BusinessBase object’s IsDirty, IsNew, IsDeleted, IsValid and IsSavable properties in a manner that can be consumed by WPF data binding.

 

Csla\Validation – DecoratedRuleArgs (070313-C#/070501-VB)

Add a DecoratedRuleArgs class, which is a subclass of RuleArgs. This class contains a Dictionary<string, object> to store arbitrary name/value parameters. The idea is that a rule method can accept a DecoratedRuleArgs class and pull custom parameters from this dictionary, thus eliminating the need to create a custom RuleArgs subclass for each rule method. The purpose behind this is to simplify code generation. Code generation is hard to implement with custom RuleArgs subclasses, but DRA provides a very standardized mechanism for passing arbitrary parameters to a rule method.

 

Csla\Validation – CommonRules (070313-C#/070501-VB)

The rule methods in CommonRules now accept a DecoratedRuleArgs class, rather than their specific strongly-typed RuleArgs subclasses. Their RuleArgs subclasses are now subclasses of DecoratedRuleArgs. This change was done in a way that preserves backward compatibility, but now allows the direct use of DecoratedRuleArgs to call the common rules if you want to avoid the strongly-typed subclasses entirely. The reason for this, is that it simplifies some code generation scenarios.

 

Csla\Validation – RuleArgs & CommonRules (070313-C#/070501-VB)

Add a PropertyFriendlyName value to RuleArgs so a business object can optionally specify a friendly name for the property being validated. This friendly name should be used in the broken rule description string. RuleArgs now has a static/Shared helper method to get the correct property name, falling back to PropertyName if PropertyFriendlyName is not set.

 

The rule methods in CommonRules now make use of PropertyFriendlyName if it is provided.

 

Csla\Validation – CommonRules (070313-C#/070501-VB)

Add a Format property to the RuleArgs subclasses used by the MinValue and MaxValue common rule methods. If this value is supplied, it is used to format the min and max values in the output string generated if the rule is broken.

 

Csla\Templates - SwitchableObject (070315-C#/VB)

Add Insert/Update/DeleteSelf methods to the template.

 

Csla\Templates – DynamicRootList & DynamicRoot (070315-C#/VB)

Add a DynamicRoot template to avoid confusion in the templates. Change DynamicRootList to contain DynamicRoot objects. Add code to DynamicRootList to support dynamic addition of new objects to the list.

 

Csla – BusinessListBase (070315-C#/070501-VB)

Add ISavable property to BusinessListBase.

 

Csla\Core – IEditableCollection (070315-C#/070501-VB)

Add IsValid, IsDirty and ISavable properties.

 

Csla - BusinessListBase (070410-C#/VB)

Include PropertyDescriptor for changed property when raising ListChanged event after deserialization.

 

Csla - BusinessListBase (070424-C#/VB)

When undoing changes where a deleted item is undeleted, remove that item from the deleted list before adding it to the active list. This way, when the item is added to the active list and the ListChanged event is raised, the item is already gone from the deleted list and so the collection's IsDirty property will be correct when the event is handled.

 

Csla - NameValueListBase (070501-C#/VB)

Add GetKey() and GetValue() methods to make it easier to translate from key to value or value to key in code.

 

Csla – SmartDate (070501-C#/VB)

Add TryParse() methods to SmartDate.

 

Csla – SmartDate (070501-C#/VB)

If Key is null in the CompareTo() method, return -1. This should provide better parity with the DateTime type.

 

Csla\Core – BusinessBase (070501-C#/VB)

Add protected DisableIEditableObject property so it is possible to turn off the IEditableObject interface methods. If this is done, Windows Forms data binding can no longer automatically interact with n-level undo, and the UI developer must make all the method calls manually.

 

Csla\Validation – ValidationRules (070501-C#/VB)

In the CheckRules() method, if stopProcessing comes back as true then short-circuiting occurs, which is good. However, the stopProcessing value was left as true in the RuleArgs object, and so subsequent calls would also short-circuit even if they shouldn’t. The stopProcessing value is now reset to false in this case.

 

Csla – SortedBindingList/FilteredBindingList (070501-C#/VB)

Include e.PropertyDescriptor when re-raising the ListChanged event from the source list.

 

Csla – SortedBindingList/FilteredBindingList (070501-C#/VB)

Add property to allow access to the source list against which this list is a view.

 

Csla – Authorization/BusinessBase/ReadOnlyBase (070501-VB/070622-C#)

Add CanExecuteMethod() to BusinessBase and ReadOnlyBase. This method works like CanReadProperty() and CanWriteProperty(), but is used to authorize the execution of arbitrary methods. Implementing this behavior required changes to many classes in Csla\Security to store per-instance and per-type lists of allowed/denied roles for each method.

 

Csla\Validation – ValidationRules (070502-C#/VB)

Catch any exceptions that occur when a rule method is invoked and throw a more detailed ValidationException that shows the property and rule name, and includes the original exception as an InnerException.

 

Csla – EditableRootListBase (070505-C#/VB)

Include PropertyDescriptor for changed property when raising ListChanged event after deserialization.

 

Csla – BusinessListBase (070518-C#/VB)

Fix some issues with SetItem and n-level undo behaviors for children in lists.

 

SetItem now properly configures the newly added item by ensuring that its EditLevel and EditLevelAdded values are both correct.

 

When a child is deleted from the list, its edit level is lowered to match the list (if necessary). This resolves an issue with data binding in a grid, where the child is the currently selected item in the grid (because its edit level would have been elevated in that case).

 

Csla – Core\BusinessBase (070518-C#/VB)

EditLevelAdded is now NotUndoable, which it should have been all along. This change means that the value is controlled as expected.

 

Csla – N-Level Undo (numerous classes) (070521-C#/VB)

Enhanced CopyState(), UndoChanges() and AcceptChanges() methods to check the parent’s edit level and throw an exception if there’s a mismatch. The purpose of this change is to help identify and debug situations where manual or data binding invocation of n-level undo gets out of sync.

 

Csla – NameValueListBase (070524-C#/VB)

Override ToString() to return the Value property of each item in the list.

 

Csla – N-Level Undo (numerous classes) (070525-C#/VB)

Add ISupportUndo interface and rework the existing interfaces a bit so IUndoableObject is no longer in the main inheritance tree for the public interfaces.

 

This was done because the recent IUndoableObject interface changes to error check edit levels made UI framework development overly difficult. Rearranging the interfaces this new way is both cleaner and resolves the complexity for UI frameworks.

 

Csla – BusinessBase (070529-C#/VB)

The Save() method now only throws a ValidationException if the object is invalid and is not marked for deletion. In other words, invalid objects can now be deleted.

 

Csla\Web – CslaDataSource (070601-C#/VB)

The combobox contents in the Configure CslaDataSource dialog are now sorted.

 

Csla – Data portal (070606-C#/VB)

Change how the client-side data portal generates the message when it throws a DataPortalException, so it now properly handles the case that the server exception is not a Csla.Server.DataPortalException.

 

Csla (070606-C#/VB)

Globally change how SecurityException exceptions are thrown, so the Action property is set explicitly. This works around an issue where the WCF NetDataContractSerializer was unable to serialize the SecurityException objects.

 

Csla (070612-C#/VB)

Add support for a NET20 symbol. If this symbol is defined in the project’s build then all dependencies on .NET 3.0 are eliminated from the build (so all support for WCF and WPF are gone). This allows a developer to build Csla.dll on a machine where the .NET 3.0 runtime is not installed. This NET20 symbol is not defined by default.

 

Csla\Wpf - CslaDataProvider (070619-C#/VB)

Add support for Save and Undo RoutedCommands in XAML. A command source (like a Button) can set its CommandTarget to the CommandManager property of the CslaDataProvider to execute these two commands on the CslaDataProvider control.

 

Csla - DataPortal  (070620-C#/VB)

Add a ReleaseProxy() method to the client-side DataPortal class. This method releases the cached proxy object, so the next data portal call will create a new proxy instance. An application can use this method, during runtime, to force recreation of the proxy in the case that the data portal’s configuration has been changed. Note however, that System.Configuration caches all configuration settings, so changing configuration “on the fly” isn’t a trivial matter regardless.

 

Csla\DataPortal – WcfProxy (070620-C#/VB)

Add a protected EndPoint property to WcfProxy. A subclass can use this property to override the default endpoint name of WcfDataPortal.

 

Csla\Wpf – DataDecoratorBase (070621-C#/VB)

Reverse change to inherit from StackPanel rather than Decorator. So now DataDecoratorBase (new name) inherits from Decorator. The subclasses were all renamed too (see above).

 

Csla – BusinessListBase (070630-C#/VB)

Implement INotifyCollectionChanged interface.

 

Csla\Wpf – DataDecoratorBase (070630-C#/VB)

Honor events from only one of IBindingList or INotifyPropertyChanged, giving preference to INotifyPropertyChanged. This avoids double event handling for lists that implement both interfaces (like BusinessListBase).

 

Csla\Validation – CommonRules (070709-C#/VB)

Add overrides with friendName parameter to all custom event args classes.

 

 

Known issues:

CslaDataSource

When adding CslaDataSource to a page by choosing to “add a new data source” from within the GridView or DetailsView controls the data source control will not function properly in the designer, though it will appear on the page. (This is due to a bug in Visual Studio in terms of how it loads the control into memory, and I’ve discussed it with Microsoft.)

The workaround is to switch the designer to Source view and back after adding the new
CslaDataSource control to a page. This will force the designer to reload the control, making it act properly within the designer.

 

As before, you can add a CslaDataSource to the page by dragging it directly from the Toolbox, or by typing in the tag manually. Both of these techniques work immediately with no known issues.

 

Wish List items complete:

 

1.    In BusinessListBase, in the PropertyChanged event handler for child objects, the new ListChanged event should include a PropertyDescriptor for the child property that was changed. (appears resolved in version 2.1, so may no longer be an issue) (in 3.0)

2.    Add a FormatString property to the MinValue and MaxValue rule method args, and use that value when formatting the e.Description output as per this forum thread. (in 3.0)

3.    Add GetItem(key) and GetItem(value) methods to NVLB so it is easy to get the actual list item by either key or value. (in 3.0)

4.    Add "friendly property name" to RuleArgs, and use it for generating output if its length is >0. Also maybe use a custom attribute on the property to specify the friendly name - harder to make data-driven, but nicer for hand-coded classes  (in 3.0)

5.    Add a TryParse() method to SmartDate. (in 3.0)

6.    Add a switch to BusinessBase so it is possible to disable IEditableObject, forcing manual use of n-level undo. (in 3.0)

7.    Fix bug in SortedBindingList.CompareTo() to deal with a null Key value as per this thread. (in 3.0)

8.    Add helper class to easily parse the rule:// URI format. (in 3.0)

9.    Create a DecoratedRuleArgs that exposes a Dicationary<string, object>. The idea is that rule methods could be constructed to use arbitrary parameters passed through this name/value mechanism, so a custom RuleArgs class isn't required for every rule method. This is a trade-off between explicit coding and ease of use, but that's a choice individual rule method authors can make as they choose. (in 3.0)

10. Change the regex validation rule to better handle null values (from this forum thread). (in 3.0)

11. Add a constructor for RuleArgs that accepts severity as per this thread. (in 3.0)

12. Add Csla.ValidationRules.CommonRules.MinLength rule method. (in 3.0)

13. Add a property to SortedBindingList and FilteredBindingList to return a reference to the original list object. (in 3.0)

14. Add Insert()/Update()/DeleteSelf() implementations to switchable template. (in 3.0)

15. Include property descriptor in ListChanged event in SortedBindingList and FilteredBindingList as per this thread. (in 3.0)

16. Reset the RuleArgs.StopProcessing flag to false in CheckRules() so subsequent runs won't accidentally stop processing. (in 3.0)

17. Add a CanExecute() method (like CanReadProperty()) as per this thread.  (in 3.0)

18. Throw more descriptive exception when an exception occurs in a validation rule, as per this thread. (in 3.0)

19. If parent.CancelEdit() is called when a child has a higher edit level than the parent an exception should be thrown. I think this can be done efficiently by passing the parent's edit level as a parameter to the children when the call is cascaded from the parent. If a child's edit level doesn't match, it can throw the exception. This would help avoid (or at least detect) a common bug when using Windows Forms data binding in parent-child scenarios.

 

 

(Updated 7/9/2007 12:06:24 PM)