| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Configuration\Alias\TypeAlias.cs | 50.0 % | 72.7 % | 87.5 % | 73.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 | #region Using | |
28 | ||
29 | using System; | |
30 | using System.Xml.Serialization; | |
31 | using IBatisNet.Common.Utilities; | |
32 | ||
33 | #endregion | |
34 | ||
35 | namespace IBatisNet.DataMapper.Configuration.Alias | |
36 | { | |
37 | /// <summary> | |
38 | /// TypeAlias. | |
39 | /// </summary> | |
40 | [Serializable] | |
41 | [XmlRoot("typeAlias")] | |
42 | public class TypeAlias | |
43 | { | |
44 | ||
45 | #region Fields | |
46 | [NonSerialized] | |
47 | private string _name = string.Empty; | |
48 | [NonSerialized] | |
49 | private string _className = string.Empty; | |
50 | [NonSerialized] | |
51 | private Type _class = null; | |
52 | #endregion | |
53 | ||
54 | #region Properties | |
55 | /// <summary> | |
56 | /// Name used to identify the typeAlias amongst the others. | |
57 | /// </summary> | |
58 | /// <example> Account</example> | |
59 | [XmlAttribute("alias")] | |
60 | public string Name | |
61 | { | |
62 | 2720 | get { return _name; } |
63 | 2720 | set |
64 | { | |
65 | 2720 | if ((value == null) || (value.Length < 1)) |
66 | { | |
67 | 0 | throw new ArgumentNullException("The name attribute is mandatory in the typeAlias "); |
68 | } | |
69 | 2720 | _name = value; |
70 | } | |
71 | } | |
72 | ||
73 | ||
74 | /// <summary> | |
75 | /// The type class for the typeAlias | |
76 | /// </summary> | |
77 | [XmlIgnore] | |
78 | public Type Class | |
79 | { | |
80 | 16830 | get { return _class; } |
81 | } | |
82 | ||
83 | ||
84 | /// <summary> | |
85 | /// The class name to identify the typeAlias. | |
86 | /// </summary> | |
87 | /// <example>Com.Site.Domain.Product</example> | |
88 | [XmlAttribute("type")] | |
89 | public string ClassName | |
90 | { | |
91 | 2720 | get { return _className; } |
92 | 2720 | set |
93 | { | |
94 | 2720 | if ((value == null) || (value.Length < 1)) |
95 | { | |
96 | 0 | throw new ArgumentNullException("The class attribute is mandatory in the typeAlias " + _name); |
97 | } | |
98 | 2720 | _className = value; |
99 | } | |
100 | } | |
101 | #endregion | |
102 | ||
103 | #region Constructor (s) / Destructor | |
104 | /// <summary> | |
105 | /// Do not use direclty, only for serialization. | |
106 | /// </summary> | |
107 | 2720 | [Obsolete("This public constructor with no parameter is not really obsolete, but is reserved for serialization.", false)] |
108 | public TypeAlias() | |
109 | {} | |
110 | ||
111 | /// <summary> | |
112 | /// Constructor | |
113 | /// </summary> | |
114 | /// <param name="type">a type.</param> | |
115 | 0 | public TypeAlias(Type type) |
116 | { | |
117 | _class = type; | |
118 | } | |
119 | #endregion | |
120 | ||
121 | #region Methods | |
122 | /// <summary> | |
123 | /// Initialize the object, | |
124 | /// try to idenfify the .Net type class from the corresponding name. | |
125 | /// </summary> | |
126 | 2720 | public void Initialize() |
127 | { | |
128 | 2720 | _class = Resources.TypeForName(_className); |
129 | } | |
130 | #endregion | |
131 | ||
132 | } | |
133 | } | |
134 |
|