1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.ActiveRecordSupport
18 using Castle
.MonoRail
.Framework
;
21 /// Extends the <see cref="SmartDispatcherController"/>
22 /// with ActiveRecord specific functionality
24 public class ARSmartDispatcherController
: SmartDispatcherController
27 /// Initializes a new instance of the <see cref="ARSmartDispatcherController"/> class.
29 public ARSmartDispatcherController() : base(new ARDataBinder())
34 /// Binds the object using the posted values.
36 /// <param name="from">Defines where the parameters should be obtained from.</param>
37 /// <param name="targetType">Type of the target.</param>
38 /// <param name="prefix">The prefix.</param>
39 /// <param name="excludedProperties">The excluded properties.</param>
40 /// <param name="allowedProperties">The allowed properties.</param>
41 /// <param name="autoLoad">The auto load behavior.</param>
42 /// <returns></returns>
43 protected object BindObject(ParamStore
from, Type targetType
, String prefix
, String excludedProperties
, String allowedProperties
, AutoLoadBehavior autoLoad
)
45 SetAutoLoadBehavior(autoLoad
);
47 return BindObject(from, targetType
, prefix
, excludedProperties
, allowedProperties
);
53 /// <param name="from">Defines where the parameters should be obtained from.</param>
54 /// <param name="targetType">Type of the target.</param>
55 /// <param name="prefix">The prefix.</param>
56 /// <param name="autoLoad">The auto load behavior.</param>
57 /// <returns></returns>
58 protected object BindObject(ParamStore
from, Type targetType
, String prefix
, AutoLoadBehavior autoLoad
)
60 SetAutoLoadBehavior(autoLoad
);
61 return BindObject(from, targetType
, prefix
);
64 protected void BindObjectInstance(object instance
, ParamStore
from, String prefix
, AutoLoadBehavior autoLoad
)
66 SetAutoLoadBehavior(autoLoad
);
67 BindObjectInstance(instance
, from, prefix
);
70 protected void BindObjectInstance(object instance
, String prefix
, AutoLoadBehavior autoLoad
)
72 SetAutoLoadBehavior(autoLoad
);
73 BindObjectInstance(instance
, ParamStore
.Params
, prefix
);
76 protected void SetAutoLoadBehavior(AutoLoadBehavior autoLoad
)
78 ARDataBinder binder
= (ARDataBinder
) Binder
;
79 binder
.AutoLoad
= autoLoad
;