Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Components / Binder / Castle.Components.Binder / IDataBinder.cs
bloba5c7d0076ba00abafd858c94917f2a2554733e98
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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.Components.Binder
17 using System;
18 using Castle.Components.Validator;
20 public delegate void BinderHandler(object instance, String prefix, Node node);
22 /// <summary>
23 /// Defines the contract for a data binder implementation approach.
24 /// </summary>
25 public interface IDataBinder
27 bool CanBindParameter(Type desiredType, String paramName, CompositeNode treeRoot);
29 bool CanBindObject(Type targetType, String prefix, CompositeNode treeRoot);
31 object BindParameter(Type targetType, String paramName, CompositeNode treeRoot);
33 /// <summary>
34 /// Create an instance of the specified type and binds the properties that
35 /// are available on the datasource.
36 /// </summary>
37 /// <param name="targetType">The target type. Can be an array</param>
38 /// <param name="prefix">The obligatory prefix that distinguishes it on the datasource</param>
39 /// <param name="treeRoot">A hierarchycal representation of flat data</param>
40 /// <returns>an instance of the specified target type</returns>
41 object BindObject(Type targetType, String prefix, CompositeNode treeRoot);
43 /// <summary>
44 /// Create an instance of the specified type and binds the properties that
45 /// are available on the datasource respecting the white and black list
46 /// </summary>
47 /// <param name="targetType">The target type. Can be an array</param>
48 /// <param name="prefix">The obligatory prefix that distinguishes it on the datasource</param>
49 /// <param name="excludedProperties">A list of comma separated values specifing the properties that should be ignored</param>
50 /// <param name="allowedProperties">A list of comma separated values specifing the properties that should not be ignored</param>
51 /// <param name="treeRoot">A hierarchycal representation of flat data</param>
52 /// <returns>an instance of the specified target type</returns>
53 object BindObject(Type targetType, String prefix, String excludedProperties, String allowedProperties, CompositeNode treeRoot);
55 /// <summary>
56 /// Binds the properties that are available on the datasource to the specified object instance.
57 /// </summary>
58 /// <param name="instance">The target instance.</param>
59 /// <param name="prefix">The obligatory prefix that distinguishes it on the datasource</param>
60 /// <param name="treeRoot">A hierarchycal representation of flat data</param>
61 /// <returns>an instance of the specified target type</returns>
62 void BindObjectInstance(object instance, String prefix, CompositeNode treeRoot);
64 /// <summary>
65 /// Binds the properties that
66 /// are available on the datasource respecting the white and black list
67 /// </summary>
68 /// <param name="instance">The target type.</param>
69 /// <param name="prefix">The obligatory prefix that distinguishes it on the datasource</param>
70 /// <param name="excludedProperties">A list of comma separated values specifing the properties that should be ignored</param>
71 /// <param name="allowedProperties">A list of comma separated values specifing the properties that should not be ignored</param>
72 /// <param name="treeRoot">A hierarchycal representation of flat data</param>
73 /// <returns>an instance of the specified target type</returns>
74 void BindObjectInstance(object instance, String prefix, String excludedProperties, String allowedProperties, CompositeNode treeRoot);
76 /// <summary>
77 /// Represents the databind errors
78 /// </summary>
79 ErrorList ErrorList { get; }
81 /// <summary>
82 /// Gets the validation error summary.
83 /// </summary>
84 /// <param name="instance">The instance.</param>
85 ErrorSummary GetValidationSummary(object instance);
87 /// <summary>
88 /// Exposes the <see cref="IBinderTranslator"/> implementation
89 /// if one was provided
90 /// </summary>
91 IBinderTranslator Translator { get; set; }
93 /// <summary>
94 /// Exposes the <see cref="IConverter"/> implementation
95 /// </summary>
96 IConverter Converter { get; set; }
98 /// <summary>
99 /// Gets or sets the validator runner instance.
100 /// </summary>
101 /// <value>The validator instance.</value>
102 ValidatorRunner Validator { get; set; }
104 /// <summary>
105 /// Invoked before the data binder implementation starts to
106 /// work on a class instance
107 /// </summary>
108 event BinderHandler OnBeforeBinding;
110 /// <summary>
111 /// Invoked after the data binder implementation starts to
112 /// work on a class instance
113 /// </summary>
114 event BinderHandler OnAfterBinding;