| |||||||||||||||||
| Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
| Model\ObjectHandlerMethodCaller.cs | - | 100,0 % | 100,0 % | 100,0 % |
|
||||||||||||
| 1 | #region Copyright | |
| 2 | /* | |
| 3 | ShowX. Maps business objects into presentation layer. | |
| 4 | Copyright (C) 2005 Jesus Diaz. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public | |
| 8 | License as published by the Free Software Foundation; either | |
| 9 | version 2.1 of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with this library; if not, write to the Free Software | |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | For project details see: http://showx.sourceforge.net | |
| 21 | */ | |
| 22 | #endregion | |
| 23 | ||
| 24 | using System; | |
| 25 | using System.Collections; | |
| 26 | ||
| 27 | namespace ShowX.Model | |
| 28 | { | |
| 29 | /// <summary> | |
| 30 | /// ObjectHandlerProxy implements mapping to IObjectHandlerMethodCaller | |
| 31 | /// methods abstracting the construction of the handler. | |
| 32 | /// </summary> | |
| 33 | public abstract class ObjectHandlerMethodCaller : IObjectHandlerMethodCaller | |
| 34 | { | |
| 35 | /// <summary> | |
| 36 | /// Helper method to retrieve and build the Object Handler attached to a | |
| 37 | /// certain type. | |
| 38 | /// </summary> | |
| 39 | /// <param name="t">Type to get object handler.</param> | |
| 40 | /// <returns>An instance of the object handler attached to type t.</returns> | |
| 41 | protected abstract IObjectHandler BuildObjectHandlerFromType(Type t); | |
| 42 | ||
| 43 | #region IObjectHandlerMethodCaller methods | |
| 44 | ||
| 45 | /// <summary> | |
| 46 | /// Invoque the method UpdateX, for Type t, by using its Object Handler (OH). | |
| 47 | /// </summary> | |
| 48 | /// <remarks>The values | |
| 49 | /// array should compliant with the expected parameter of the method | |
| 50 | /// <see cref="IObjectHandler.UpdateX"/>. | |
| 51 | /// </remarks> | |
| 52 | /// <param name="t">Type to invoque method GetUpdateX by its OH. | |
| 53 | /// </param> | |
| 54 | /// <param name="context">Context in which occurs the operation (supplied by | |
| 55 | /// user via control properties)</param> | |
| 56 | /// <param name="values">Values to update an instance of t.</param> | |
| 57 | 2 | public void InvokeMethodGetUpdateX(Type t, object context, object[] values) |
| 58 | { | |
| 59 | 2 | BuildObjectHandlerFromType(t).UpdateX(context,values); |
| 60 | } | |
| 61 | ||
| 62 | /// <summary> | |
| 63 | /// Invoque the method GetXByID, for Type t, by using its Object Handler (OH). | |
| 64 | /// </summary> | |
| 65 | /// <param name="context">Context in wich occurs the operation.</param> | |
| 66 | /// <param name="t">Type to invoque method GetXByID, by using its OH. | |
| 67 | /// </param> | |
| 68 | /// <param name="xId">Unique identifier of the instance we want to get.</param> | |
| 69 | /// <returns>An instance of type t.</returns> | |
| 70 | 12 | public object InvokeMethodGetXByID(Type t, object context, int xId) |
| 71 | { | |
| 72 | 12 | return BuildObjectHandlerFromType(t).GetXByID(context,xId); |
| 73 | } | |
| 74 | ||
| 75 | /// <summary> | |
| 76 | /// Invoque the method DelX, for Type t, by using its Object Handler (OH). | |
| 77 | /// </summary> | |
| 78 | /// <param name="t">Type to invoque method DelX, by using its OH. | |
| 79 | /// </param> | |
| 80 | /// <param name="context">Context in wich occurs the operation.</param> | |
| 81 | /// <param name="xId">Unique identifier of the instance we want to delete. | |
| 82 | /// </param> | |
| 83 | 7 | public void InvokeMethodDelX(Type t, object context, int xId) |
| 84 | { | |
| 85 | 7 | BuildObjectHandlerFromType(t).DelXByID(context,xId); |
| 86 | } | |
| 87 | ||
| 88 | /// <summary> | |
| 89 | /// Invoque the method NewX, for Type t, by using its Object Handler (OH). | |
| 90 | /// </summary> | |
| 91 | /// <param name="t">Type to invoque method NewX. | |
| 92 | /// </param> | |
| 93 | /// <returns>The newly created instance of type t.</returns> | |
| 94 | 25 | public object InvokeMethodNewX(Type t) |
| 95 | { | |
| 96 | 25 | return BuildObjectHandlerFromType(t).NewX(); |
| 97 | } | |
| 98 | ||
| 99 | /// <summary> | |
| 100 | /// Invoque the method AddX, for Type t, by using its Object Handler (OH). | |
| 101 | /// </summary> | |
| 102 | /// <remarks> | |
| 103 | /// The values | |
| 104 | /// array should compliant with the expected parameter of the method | |
| 105 | /// <see cref="IObjectHandler.AddX"/> of the associated OH. | |
| 106 | /// </remarks> | |
| 107 | /// <param name="t">Type to invoque method AddX. | |
| 108 | /// </param> | |
| 109 | /// <param name="context">Context in which occurs the operation (supplied by | |
| 110 | /// user via control properties)</param> | |
| 111 | /// <param name="values">Values to build an instance of t. </param> | |
| 112 | 6 | public object InvokeMethodAddX(Type t, object context, object[] values) |
| 113 | { | |
| 114 | 6 | return BuildObjectHandlerFromType(t).AddX(context,values); |
| 115 | } | |
| 116 | ||
| 117 | /// <summary> | |
| 118 | /// Invoque the method GetAllX, for Type t, by using its Object Handler (OH). | |
| 119 | /// </summary> | |
| 120 | /// <param name="t">Type to invoque method GetAllX, by using its OH. | |
| 121 | /// </param> | |
| 122 | /// <param name="context">Context in which occurs the operation (supplied by | |
| 123 | /// user via control properties)</param> | |
| 124 | /// <returns>An ArrayList of instances of t.</returns> | |
| 125 | 90 | public ArrayList InvokeMethodGetAllX(Type t, object context) |
| 126 | { | |
| 127 | 90 | return BuildObjectHandlerFromType(t).GetAllX(context); |
| 128 | } | |
| 129 | ||
| 130 | ||
| 131 | #endregion | |
| 132 | } | |
| 133 | } | |
| 134 |
|
||||||||