#region Apache Notice /***************************************************************************** * $Header: $ * $Revision: $ * $Date: $ * * iBATIS.NET Data Mapper * Copyright (C) 2004 - Gilles Bayon * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ********************************************************************************/ #endregion #region Using using System; using System.Xml.Serialization; using IBatisNet.Common.Utilities; #endregion namespace IBatisNet.DataMapper.Configuration.Alias { /// /// TypeAlias. /// [Serializable] [XmlRoot("typeAlias", Namespace="http://ibatis.apache.org/dataMapper")] public class TypeAlias { #region Fields [NonSerialized] private string _name = string.Empty; [NonSerialized] private string _className = string.Empty; [NonSerialized] private Type _class = null; #endregion #region Properties /// /// Name used to identify the typeAlias amongst the others. /// /// Account [XmlAttribute("alias")] public string Name { get { return _name; } set { if ((value == null) || (value.Length < 1)) { throw new ArgumentNullException("The name attribute is mandatory in the typeAlias "); } _name = value; } } /// /// The type class for the typeAlias /// [XmlIgnore] public Type Class { get { return _class; } } /// /// The class name to identify the typeAlias. /// /// Com.Site.Domain.Product [XmlAttribute("type")] public string ClassName { get { return _className; } set { if ((value == null) || (value.Length < 1)) { throw new ArgumentNullException("The class attribute is mandatory in the typeAlias " + _name); } _className = value; } } #endregion #region Constructor (s) / Destructor /// /// Do not use direclty, only for serialization. /// public TypeAlias() {} /// /// Constructor /// /// a type. public TypeAlias(Type type) { _class = type; } #endregion #region Methods /// /// Initialize the object, /// try to idenfify the .Net type class from the corresponding name. /// public void Initialize() { _class = Resources.TypeForName(_className); } #endregion } }