| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Configuration\Sql\Dynamic\Elements\SqlTag.cs | 100.0 % | 90.9 % | 88.9 % | 90.9 % |
|
1 | ||
2 | #region Apache Notice | |
3 | /***************************************************************************** | |
4 | * $Header: $ | |
5 | * $Revision: $ | |
6 | * $Date: $ | |
7 | * | |
8 | * iBATIS.NET Data Mapper | |
9 | * Copyright (C) 2004 - Gilles Bayon | |
10 | * | |
11 | * | |
12 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
13 | * you may not use this file except in compliance with the License. | |
14 | * You may obtain a copy of the License at | |
15 | * | |
16 | * http://www.apache.org/licenses/LICENSE-2.0 | |
17 | * | |
18 | * Unless required by applicable law or agreed to in writing, software | |
19 | * distributed under the License is distributed on an "AS IS" BASIS, | |
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
21 | * See the License for the specific language governing permissions and | |
22 | * limitations under the License. | |
23 | * | |
24 | ********************************************************************************/ | |
25 | #endregion | |
26 | ||
27 | using System; | |
28 | using System.Collections; | |
29 | using System.Xml.Serialization; | |
30 | ||
31 | using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Handlers; | |
32 | ||
33 | namespace IBatisNet.DataMapper.Configuration.Sql.Dynamic.Elements | |
34 | { | |
35 | /// <summary> | |
36 | /// SqlTag is a children element of dynamic Sql element. | |
37 | /// SqlTag represent any binary unary/conditional element (like isEmpty, isNull, iEquall...) | |
38 | /// or other element as isParameterPresent, isNotParameterPresent, iterate. | |
39 | /// </summary> | |
40 | [Serializable] | |
41 | public abstract class SqlTag : ISqlChild, IDynamicParent | |
42 | { | |
43 | ||
44 | #region Fields | |
45 | ||
46 | [NonSerialized] | |
47 | private string _prepend = string.Empty; | |
48 | [NonSerialized] | |
49 | private ISqlTagHandler _handler = null; | |
50 | [NonSerialized] | |
51 | private SqlTag _parent = null; | |
52 | [NonSerialized] | |
53 | private IList _children = new ArrayList(); | |
54 | ||
55 | #endregion | |
56 | ||
57 | ||
58 | /// <summary> | |
59 | /// Parent tag element | |
60 | /// </summary> | |
61 | [XmlIgnoreAttribute] | |
62 | public SqlTag Parent | |
63 | { | |
64 | 0 | get |
65 | { | |
66 | return _parent; | |
67 | } | |
68 | 5780 | set |
69 | { | |
70 | 5780 | _parent = value; |
71 | } | |
72 | } | |
73 | ||
74 | ||
75 | /// <summary> | |
76 | /// Prepend attribute | |
77 | /// </summary> | |
78 | [XmlAttribute("prepend")] | |
79 | public string Prepend | |
80 | { | |
81 | 39 | get |
82 | { | |
83 | 39 | return _prepend; |
84 | } | |
85 | 6630 | set |
86 | { | |
87 | 6630 | _prepend = value; |
88 | } | |
89 | } | |
90 | ||
91 | ||
92 | /// <summary> | |
93 | /// Handler for this sql tag | |
94 | /// </summary> | |
95 | [XmlIgnoreAttribute] | |
96 | public ISqlTagHandler Handler | |
97 | { | |
98 | ||
99 | 10893 | get |
100 | { | |
101 | 10893 | return _handler; |
102 | } | |
103 | 10710 | set |
104 | { | |
105 | 10710 | _handler = value; |
106 | } | |
107 | } | |
108 | ||
109 | /// <summary> | |
110 | /// | |
111 | /// </summary> | |
112 | public bool IsPrependAvailable | |
113 | { | |
114 | 274 | get |
115 | { | |
116 | 274 | return (_prepend != null && _prepend.Length > 0); |
117 | } | |
118 | } | |
119 | ||
120 | /// <summary> | |
121 | /// | |
122 | /// </summary> | |
123 | /// <returns></returns> | |
124 | 105 | public IEnumerator GetChildrenEnumerator() |
125 | { | |
126 | 105 | return _children.GetEnumerator(); |
127 | } | |
128 | ||
129 | #region IDynamicParent Members | |
130 | ||
131 | /// <summary> | |
132 | /// | |
133 | /// </summary> | |
134 | /// <param name="child"></param> | |
135 | 13940 | public void AddChild(ISqlChild child) |
136 | { | |
137 | 13940 | if (child is SqlTag) |
138 | { | |
139 | 5780 | ((SqlTag) child).Parent = this; |
140 | } | |
141 | 13940 | _children.Add(child); |
142 | } | |
143 | ||
144 | #endregion | |
145 | } | |
146 | } | |
147 |
|