ColumnMap.cs :  » Persistence-Frameworks » Persist.NET » Persist » Maps » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Persistence Frameworks » Persist.NET 
Persist.NET » Persist » Maps » ColumnMap.cs
// Persist library : Persistence layer
// Copyright (C) 2003 Vincent Daron
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

using System;
using System.Data;

using Persist.Converters;
using Persist.IdGenerators;

namespace Persist.Maps{
   /// <summary>
   /// Summary description for ColumnMap.
   /// </summary>
   public class ColumnMap
   {
      /// <summary>
      /// Type of primary Key
      /// </summary>
      public enum KeyTypeEnum
      {
         /// <summary>
         /// Not a primary Key
         /// </summary>
         None = 0,
         /// <summary>
         /// Primary key
         /// </summary>
         Primary = 1,
         /// <summary>
         /// Foreign key (unused for now)
         /// </summary>
         Foreign = 2
      };

      private string theName;
      private KeyTypeEnum theKeyType = KeyTypeEnum.None;
      private TableMap theTableMap = null;
      private DbType theDbType = DbType.Object;
      private string theIdGeneratorName;
      private string theConverterName;
      private IIdGenerator theIdGenerator = null;
      private IConverter theConverter = null;
      private bool isInitialized = false;
      /// <summary>
      /// Creates ColumnMap.
      /// </summary>
      /// <param name="name">the ColumnMap name</param>
      /// <param name="tableMap">the TableMap of this column map</param>
      public ColumnMap(string name, TableMap tableMap)
      {
         theName = name;
         theTableMap = tableMap;
      }

      /// <summary>
      /// Returns fully qualifies name of this column.
      /// </summary>
      public string FullyQualifiedName
      {
         get
         {
            return TableMap.Name + "." + Name;
         }
      }

      /// <summary>
      /// Returns key type of this column.
      /// Cannot be change once initialized (Trow an Exception)
      /// </summary>
      public KeyTypeEnum KeyType
      {
         get
         {
            return theKeyType;
         }
         set
         {
            if(isInitialized)throw new Exception("KeyType cannot be changed once initialized");
            theKeyType = value;
         }
      }

      /// <summary>
      /// Return ID generator for this attribute map.
      /// </summary>
      public IIdGenerator IdGenerator
      {
         get{return theIdGenerator;}
      }

      /// <summary>
      /// Return the Converter for this column
      /// </summary>
      public IConverter Converter
      {
         get
         {
            return theConverter;
         }
      }

      /// <summary>
      /// the IdGenerator name
      /// this cannot be change once initialized (Exception will be thrown)
      /// </summary>
      public string IdGeneratorName
      {
         get{return theIdGeneratorName;}
         set
         {
            if(isInitialized)throw new Exception("the IdGenerator name cannot be changed once initialized");
            theIdGeneratorName = value;
         }
      }

      /// <summary>
      /// the Conerter Name.
      /// this cannot be change once initialized (Exception will be thrown)
      /// </summary>
      public string ConverterName
      {
         get{return theConverterName;}
         set
         {
            if(isInitialized)throw new Exception("the Converter name cannot be changed once initialized");
            theConverterName = value;
         }
      }

      /// <summary>
      /// Initialize the ColumnMap
      /// </summary>
      /// <param name="configuration">the current configuration</param>
      public void Init(Config.Configuration configuration)
      {
         if(theIdGeneratorName != null)
         {
            theIdGenerator = configuration.GetIdGenerator(theIdGeneratorName);
         }

         if(theConverterName == null)
         {
            theConverter = configuration.TrivialConverter;
         }
         else
         {
            theConverter = configuration.GetConverter(theConverterName);
         }
         isInitialized = true;
      }

      /// <summary>
      ///  Returns name of this column.
      /// </summary>
      public string Name
      {
         get
         {
            return theName;
         }
      }

      /// <summary>
      /// Returns type of this column.
      /// This cannot be changed once initialized (throw exception)
      /// </summary>
      public DbType DbType
      {
         get
         {
            return theDbType;
         }
         set
         {
            if(isInitialized)throw new Exception("DbType cannot be changed once initialized");
            theDbType = value;
         }
      }

      /// <summary>
      /// Returns TableMap for this column.
      /// </summary>
      public TableMap TableMap
      {
         get
         {
            return theTableMap;
         }
      }
   }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.