From: Naresh B. <nb...@us...> - 2006-07-09 12:08:25
|
User: nbhatia Date: 06/07/09 05:08:25 Added: etc/andromda-dotnet/AndroMDA.NHibernateSupport AndroMDA.NHibernateSupport.csproj AndroMDA.NHibernateSupport.sln AndroMDA.NHibernateSupport.suo AssemblyInfo.cs etc/andromda-dotnet/AndroMDA.NHibernateSupport/src DbSupport.cs DefaultSessionManager.cs HttpSessionManagerModule.cs INHibernateDaoSupport.cs ISessionManager.cs NHibernateDaoSupport.cs SessionManagerFactory.cs etc/andromda-dotnet/Lib/AndroMDA.NHibernateSupport AndroMDA.NHibernateSupport.dll etc/andromda-dotnet/Lib DLL Versions.txt etc/andromda-dotnet/Lib/NHibernate.Nullables2 NHibernate.Nullables2.dll etc/andromda-dotnet/Lib/NHibernateContrib Bamboo.Prevalence.dll NHibernate.Caches.Prevalence.dll NHibernate.Caches.SysCache.dll etc/andromda-dotnet/Lib/NHibernate Castle.DynamicProxy.dll HashCodeProvider.dll Iesi.Collections.dll NHibernate.dll log4net.dll etc/andromda-dotnet/NHibernate.Nullables2 NHibernate.Nullables2.sln Readme.doc etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2 EmptyAnsiStringType.cs EmptyStringType.cs NHibernate.Nullables2.csproj NullableBaseType.cs NullableBooleanType.cs NullableByteType.cs NullableCharType.cs NullableDateTimeType.cs NullableDecimalType.cs NullableDoubleType.cs NullableGuidType.cs NullableInt16Type.cs NullableInt32Type.cs NullableInt64Type.cs NullableSByteType.cs NullableSingleType.cs etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/Properties AssemblyInfo.cs etc/andromda-dotnet/NHibernate.Nullables2/nhibtest FooBar.cs FooBar.hbm.xml FooBarNHibernateTests.cs NhibTest.csproj NhibTest.dll.config etc/andromda-dotnet/NHibernate.Nullables2/nhibtest/Properties AssemblyInfo.cs Log: Moved from contrib Revision Changes Path 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/AndroMDA.NHibernateSupport.csproj Index: AndroMDA.NHibernateSupport.csproj =================================================================== <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{8349509A-0F7D-411A-AA7B-176AA6452911}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "AndroMDA.NHibernateSupport" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" PreBuildEvent = "" PostBuildEvent = "" RootNamespace = "AndroMDA.NHibernateSupport" RunPostBuildEvent = "OnBuildSuccess" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /> <Reference Name = "System.Data" AssemblyName = "System.Data" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" /> <Reference Name = "System.XML" AssemblyName = "System.Xml" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> <Reference Name = "System.Web" AssemblyName = "System.Web" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Web.dll" /> <Reference Name = "log4net" AssemblyName = "log4net" HintPath = "..\Lib\NHibernate\log4net.dll" /> <Reference Name = "NHibernate" AssemblyName = "NHibernate" HintPath = "..\Lib\NHibernate\NHibernate.dll" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "src\DbSupport.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "src\DefaultSessionManager.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "src\HttpSessionManagerModule.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "src\INHibernateDaoSupport.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "src\ISessionManager.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "src\NHibernateDaoSupport.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "src\SessionManagerFactory.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/AndroMDA.NHibernateSupport.sln Index: AndroMDA.NHibernateSupport.sln =================================================================== Microsoft Visual Studio Solution File, Format Version 8.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AndroMDA.NHibernateSupport", "AndroMDA.NHibernateSupport.csproj", "{8349509A-0F7D-411A-AA7B-176AA6452911}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {8349509A-0F7D-411A-AA7B-176AA6452911}.Debug.ActiveCfg = Debug|.NET {8349509A-0F7D-411A-AA7B-176AA6452911}.Debug.Build.0 = Debug|.NET {8349509A-0F7D-411A-AA7B-176AA6452911}.Release.ActiveCfg = Release|.NET {8349509A-0F7D-411A-AA7B-176AA6452911}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/AndroMDA.NHibernateSupport.suo <<Binary file>> 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/AssemblyInfo.cs Index: AssemblyInfo.cs =================================================================== using System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: AssemblyTitle("AndroMDA.NHibernateSupport")] [assembly: AssemblyDescription("NHibernate support for AndroMDA")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("The AndroMDA Project")] [assembly: AssemblyProduct("AndroMDA")] [assembly: AssemblyCopyright("Copyright (c) 2002 - 2005, The AndroMDA Team")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.3.0")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/src/DbSupport.cs Index: DbSupport.cs =================================================================== // Name: DbSupport.cs // Author: Naresh Bhatia using System; namespace AndroMDA.NHibernateSupport { public class DbSupport { /// <summary> /// Creates ddl and/or runs it against the database. /// </summary> /// <param name="script">true if the ddl should be outputted in the Console.</param> /// <param name="export">true if the ddl should be executed against the Database.</param> public static void CreateDatabase(bool script, bool export) { NHibernate.Tool.hbm2ddl.SchemaExport schemaExport = new NHibernate.Tool.hbm2ddl.SchemaExport(SessionManagerFactory.SessionManager.Config); schemaExport.Create(script, export); } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/src/DefaultSessionManager.cs Index: DefaultSessionManager.cs =================================================================== // Name: DefaultSessionManager.cs // Author: Naresh Bhatia using System; using System.Collections; using System.Web; using NHibernate; using NHibernate.Cfg; namespace AndroMDA.NHibernateSupport { /// <summary> /// <p>DefaultSessionManager stores the NHibernate session in HttpContext. However, /// if HttpContext is not available it will fall back to ThreadLocal variables. /// Thus the DefaultSessionManager is usable in ASP.NET, Console and Windows Forms /// applications.</p> /// /// <p>In ASP.NET applications one HttpRequest is not guaranteed to be serviced by /// the same thread. HttpContext is a much more reliable place to store the session /// in these applications. That's what the DefaultSessionManager does. However if the /// ASP.NET application spawns new threads that do not have an HttpContext, then /// this SessionManager will dynamically switch to ThreadLocal variables for such threads. /// Of course in Console and Windows Forms applications there is no HttpContext. In such /// applications the DefaultSessionManager quitely switches to ThreadLocal variables. /// You just pay a minor penalty to check for HttpContext every time you need to access /// the Session.</p> /// /// <p>To use the DefaultSessionManager you must store the NHibernate configuration /// in an XML file. For an ASP.NET application, add the name of this file to your /// Web.config as follows. The key must be "nhibernate.config" and the value must /// be the path of your NHibernate configuration file starting from the web root.</p> /// /// <pre> /// <appSettings> /// <add key="nhibernate.config" value="~/nhibernate.config" /> /// </appSettings> /// </pre> /// /// <p>For a Console or Windows Forms application, add the name of the XML configuration /// file to your App.config as follows. The key must be "nhibernate.config" and the value /// must be the path of your NHibernate configuration file.</p> /// /// <pre> /// <appSettings> /// <add key="nhibernate.config" value="nhibernate.config" /> /// </appSettings> /// </pre> /// </summary> public class DefaultSessionManager : ISessionManager { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(DefaultSessionManager)); /// <summary> /// NHibernate configuration /// </summary> private Configuration config = null; public Configuration Config { get { return config; } } /// <summary> /// NHibernate factory for creating sessions /// </summary> private ISessionFactory sessionFactory = null; public ISessionFactory SessionFactory { get { if (sessionFactory == null) { BuildSessionFactory(); } return sessionFactory; } } /// <summary> /// NHibernate session /// </summary> [ThreadStatic] private static ISession threadStaticSession; public ISession Session { get { ISession session = GetSession(); if (session == null) { if (isSessionInitializedLazily) session = OpenSession(); else throw new Exception("Session does not exist."); } return session; } } // Key used to store the NHibernate session in HttpContext. private const string NHibernateSessionKey = "NHibernate.Session"; private ISession GetSession() { return (HttpContext.Current != null) ? (ISession)HttpContext.Current.Items[NHibernateSessionKey] : threadStaticSession; } private void SetSession(ISession session) { if (HttpContext.Current != null) HttpContext.Current.Items[NHibernateSessionKey] = session; else threadStaticSession = session; } private ISession OpenSession() { ISession session = sessionFactory.OpenSession(); SetSession(session); if (log.IsDebugEnabled) log.Debug("Opened hibernate session"); return session; } private void CloseSession() { ISession session = GetSession(); if (session != null) { session.Close(); SetSession(null); if (log.IsDebugEnabled) log.Debug("Closed hibernate session"); } } /// <summary> /// NHibernate transaction /// </summary> [ThreadStatic] private static ITransaction threadStaticTransaction; // Key used to store the NHibernate transaction in HttpContext. private const string NHibernateTransactionKey = "NHibernate.Transaction"; private ITransaction GetTransaction() { return (HttpContext.Current != null) ? (ITransaction)HttpContext.Current.Items[NHibernateTransactionKey] : threadStaticTransaction; } private void SetTransaction(ITransaction transaction) { if (HttpContext.Current != null) HttpContext.Current.Items[NHibernateTransactionKey] = transaction; else threadStaticTransaction = transaction; } /// <summary> /// Boolean that controls whether sessions will be created lazily or not /// </summary> private bool isSessionInitializedLazily = true; public bool IsSessionInitializedLazily { get { return isSessionInitializedLazily; } set { isSessionInitializedLazily = value; } } public void HandleApplicationStart() { if (sessionFactory != null) { throw new Exception("A SessionFactory already exists. (Was HandleApplicationStart called twice?)"); } BuildSessionFactory(); } public void HandleApplicationEnd() { config = null; sessionFactory = null; } public void HandleSessionStart() { // This uses the SessionFactory property, so if the factory // will attempt to be initialized if it is null if (SessionFactory == null) { throw new Exception("The nhibernate session factory has not been initialized."); } if (GetSession() != null) { throw new Exception("A Session already exists."); } if (!isSessionInitializedLazily) { OpenSession(); } } public void HandleSessionEnd() { if (GetTransaction() != null) throw new Exception("A transaction still exists."); CloseSession(); } public void BeginTransaction() { if (GetTransaction() != null) throw new Exception("A transaction already exists."); ITransaction transaction = Session.BeginTransaction(); SetTransaction(transaction); } public void CommitTransaction() { ITransaction transaction = GetTransaction(); if (transaction != null) { transaction.Commit(); SetTransaction(null); } } public void RollbackTransaction() { ITransaction transaction = GetTransaction(); if (transaction != null) { transaction.Rollback(); SetTransaction(null); } } private void BuildSessionFactory() { config = new Configuration(); System.Collections.Specialized.NameValueCollection nhibernateConfig = System.Configuration.ConfigurationSettings.GetConfig("nhibernate") as System.Collections.Specialized.NameValueCollection; if (SettingExists("nhibernate.config")) { try { // Load specified nhibernate.config file config.Configure(TranslateConfigPath(GetSetting("nhibernate.config"))); } catch (Exception e) { throw new Exception("An error occured while attempting to load nhibernate.cfg", e); } } else if (SettingExists("hibernate.dialect", nhibernateConfig)) { // Load embedded hibernate configuration in web.config AddSettingToConfig("hibernate.connection.provider", nhibernateConfig); AddSettingToConfig("hibernate.connection.driver_class", nhibernateConfig); AddSettingToConfig("hibernate.connection.connection_string", nhibernateConfig); AddSettingToConfig("hibernate.connection.isolation", nhibernateConfig); AddSettingToConfig("hibernate.dialect", nhibernateConfig); AddSettingToConfig("hibernate.default_schema", nhibernateConfig); AddSettingToConfig("hibernate.use_outer_join", nhibernateConfig); AddSettingToConfig("hibernate.max_fetch_depth", nhibernateConfig); AddSettingToConfig("hibernate.use_reflection_optimizer", nhibernateConfig); AddSettingToConfig("hibernate.cache.provider_class", nhibernateConfig); AddSettingToConfig("hibernate.cache.use_minimal_puts", nhibernateConfig); AddSettingToConfig("hibernate.cache.use_query_cache", nhibernateConfig); AddSettingToConfig("hibernate.cache.query_cache_factory", nhibernateConfig); AddSettingToConfig("hibernate.cache.region_prefix", nhibernateConfig); AddSettingToConfig("hibernate.query.substitutions", nhibernateConfig); AddSettingToConfig("hibernate.show_sql", nhibernateConfig); AddSettingToConfig("hibernate.hbm2ddl.auto", nhibernateConfig); if (SettingExists("nhibernate.mapping_assembly", nhibernateConfig)) { string mapping_assembly = GetSetting("nhibernate.mapping_assembly", nhibernateConfig); config.AddAssembly(mapping_assembly); } } else { // Attempt to configure with the default settings // Usually this attempts to load hibernate.xml.cfg config.Configure(); } sessionFactory = config.BuildSessionFactory(); } /// <summary> /// Translates the specified virtual path for the NHibernate config file to a /// physical path. This method returns the physical path based the type of /// the application. For an ASP.NET application it accepts a URL and returns /// the absolute file path of the config file. For Console and Windows applications /// it returns the supplied path without any change. /// </summary> /// <param name="virtualPath"> /// The virtual path (absolute or relative) of the NHibernate config file. /// </param> /// <returns>The physical path on the server specified by virtualPath.</returns> public String TranslateConfigPath(String virtualPath) { if (HttpContext.Current != null) return HttpContext.Current.Request.MapPath(virtualPath); else return virtualPath; } #region Setting utilities private string GetSetting(string key) { return GetSetting(key, System.Configuration.ConfigurationSettings.AppSettings); } private string GetSetting(string key, System.Collections.Specialized.NameValueCollection sourceConfig) { string setting = sourceConfig[key]; if (setting == null) setting = string.Empty; return setting; } private bool SettingExists(string key) { return SettingExists(key, System.Configuration.ConfigurationSettings.AppSettings); } private bool SettingExists(string key, System.Collections.Specialized.NameValueCollection sourceConfig) { string setting = sourceConfig[key]; return !(setting == null || setting == string.Empty); } private void AddSettingToConfig(string key) { AddSettingToConfig(key, System.Configuration.ConfigurationSettings.AppSettings); } private void AddSettingToConfig(string key, System.Collections.Specialized.NameValueCollection sourceConfig) { if (SettingExists(key, sourceConfig)) { config.SetProperty(key, GetSetting(key, sourceConfig)); } } #endregion } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/src/HttpSessionManagerModule.cs Index: HttpSessionManagerModule.cs =================================================================== using System; using System.Web; namespace AndroMDA.NHibernateSupport { /// <summary> /// HttpModule to call SessionManager at the end of an HttpRequest. /// </summary> public sealed class HttpSessionManagerModule : IHttpModule { public void Init(HttpApplication context) { context.BeginRequest += new EventHandler(BeginRequest); context.EndRequest += new EventHandler(EndRequest); } public void BeginRequest(Object sender, EventArgs e) { SessionManagerFactory.SessionManager.HandleSessionStart(); } public void EndRequest(Object sender, EventArgs e) { SessionManagerFactory.SessionManager.HandleSessionEnd(); } public void Dispose() { } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/src/INHibernateDaoSupport.cs Index: INHibernateDaoSupport.cs =================================================================== // Name: INHibernateDaoSupport.cs // Author: Naresh Bhatia using System; namespace AndroMDA.NHibernateSupport { public interface INHibernateDaoSupport { void BeginTransaction(); void CommitTransaction(); void RollbackTransaction(); } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/src/ISessionManager.cs Index: ISessionManager.cs =================================================================== // Name: ISessionManager.cs // Author: Naresh Bhatia using System; using NHibernate; using NHibernate.Cfg; namespace AndroMDA.NHibernateSupport { /// <summary> /// ISessionManager is an interface to manage NHibernate sessions. It defines /// a contract between the application and itself to guarantee clean and efficient /// session management. Impementations may choose to optimize this this task /// based on various criteria. /// /// The details of the contract are as follows: /// 1. When the application starts, it must call ISessionManager.HandleApplicationStart(). /// 2. When the application ends, it must call ISessionManager.HandleApplicationEnd(). /// 3. When the application needs to start using an NHibernate session, for example when /// it receives a request from a user, it must call ISessionManager.HandleSessionStart(). /// 4. When the application is done using the session, for example it has completely /// processed the user's request, it must call ISessionManager.HandleSessionEnd(). /// /// If the application follows the above protocol, then ISessionManager guarantees the following: /// 1. The NHibernate configuration can be accessed anytime between the HandleApplicationStart() /// and HandleApplicationEnd() calls. Use the Config property to access the configuration. /// 2. The NHibernate session can be accessed anytime between the HandleSessionStart() /// and HandleSessionEnd() calls. Use the Session property to access the session. /// </summary> public interface ISessionManager { // Application start and end void HandleApplicationStart(); void HandleApplicationEnd(); // Session management void HandleSessionStart(); void HandleSessionEnd(); // Transaction management void BeginTransaction(); void CommitTransaction(); void RollbackTransaction(); // Exposed properties Configuration Config { get; } ISessionFactory SessionFactory { get; } ISession Session { get; } bool IsSessionInitializedLazily { get; set; } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/src/NHibernateDaoSupport.cs Index: NHibernateDaoSupport.cs =================================================================== // Name: NHibernateDaoSupport.cs // Author: Naresh Bhatia using System; using NHibernate; namespace AndroMDA.NHibernateSupport { public abstract class NHibernateDaoSupport : INHibernateDaoSupport { protected ISession Session { get { return SessionManagerFactory.SessionManager.Session; } } public void BeginTransaction() { SessionManagerFactory.SessionManager.BeginTransaction(); } public void CommitTransaction() { SessionManagerFactory.SessionManager.CommitTransaction(); } public void RollbackTransaction() { SessionManagerFactory.SessionManager.RollbackTransaction(); } } } 1.1 plugins/etc/andromda-dotnet/AndroMDA.NHibernateSupport/src/SessionManagerFactory.cs Index: SessionManagerFactory.cs =================================================================== // Name: SessionManagerFactory.cs // Author: Naresh Bhatia using System; namespace AndroMDA.NHibernateSupport { public class SessionManagerFactory { private static ISessionManager m_sessionManager = null; // DO not allow instantiation of this class private SessionManagerFactory() { } public static ISessionManager SessionManager { get { // If the session manager has not been set yet if (m_sessionManager == null) { // Create a new default session manager m_sessionManager = new DefaultSessionManager(); } return m_sessionManager; } set { m_sessionManager = value; } } } } 1.1 plugins/etc/andromda-dotnet/Lib/AndroMDA.NHibernateSupport/AndroMDA.NHibernateSupport.dll <<Binary file>> No revision No revision 1.1 plugins/etc/andromda-dotnet/Lib/NHibernate.Nullables2/NHibernate.Nullables2.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernateContrib/Bamboo.Prevalence.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernateContrib/NHibernate.Caches.Prevalence.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernateContrib/NHibernate.Caches.SysCache.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernate/Castle.DynamicProxy.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernate/HashCodeProvider.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernate/Iesi.Collections.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernate/NHibernate.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/Lib/NHibernate/log4net.dll <<Binary file>> 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2.sln Index: NHibernate.Nullables2.sln ===================================================================  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.Nullables2", "NHibernate.Nullables2\NHibernate.Nullables2.csproj", "{298AFDF0-223D-4EBD-8310-E2FF4372F760}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NhibTest", "nhibtest\NhibTest.csproj", "{4D200941-ECBF-475D-B1F6-34DE12C0F0CF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {298AFDF0-223D-4EBD-8310-E2FF4372F760}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {298AFDF0-223D-4EBD-8310-E2FF4372F760}.Debug|Any CPU.Build.0 = Debug|Any CPU {298AFDF0-223D-4EBD-8310-E2FF4372F760}.Release|Any CPU.ActiveCfg = Release|Any CPU {298AFDF0-223D-4EBD-8310-E2FF4372F760}.Release|Any CPU.Build.0 = Release|Any CPU {4D200941-ECBF-475D-B1F6-34DE12C0F0CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4D200941-ECBF-475D-B1F6-34DE12C0F0CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {4D200941-ECBF-475D-B1F6-34DE12C0F0CF}.Release|Any CPU.ActiveCfg = Release|Any CPU {4D200941-ECBF-475D-B1F6-34DE12C0F0CF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/Readme.doc <<Binary file>> 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/EmptyAnsiStringType.cs Index: EmptyAnsiStringType.cs =================================================================== using System; using System.Data; using NHibernate; using NHibernate.SqlTypes; using NHibernate.Type; namespace NHibernate.Nullables2 { /// <summary> /// An <see cref="IUserType"/> that reads a <c>null</c> value from an <c>ansi string</c> /// column in the database as a <see cref="String.Empty">String.Empty</see> /// and writes a <see cref="String.Empty">String.Empty</see> to the database /// as <c>null</c>. /// </summary> /// <remarks> /// This is intended to help with Windows Forms DataBinding and the problems associated /// with binding a null value. See <a href="http://jira.nhibernate.org/browse/NH-279"> /// NH-279</a> for the origin of this code. /// </remarks> public class EmptyAnsiStringType : IUserType { AnsiStringType stringType; public EmptyAnsiStringType() { stringType = (AnsiStringType)NHibernateUtil.AnsiString; } #region IUserType Members bool IUserType.Equals(object x, object y) { if( x==y ) { return true; } if( ( x==null ) || ( y==null ) ) { return false; } return x.Equals( y ); } public SqlType[] SqlTypes { get { return new SqlType[] { stringType.SqlType }; } } public DbType[] DbTypes { get { return new DbType[] { stringType.SqlType.DbType }; } } public object DeepCopy(object value) { return value; } public void NullSafeSet(IDbCommand cmd, object value, int index) { if( value==null || value.Equals(string.Empty) ) { ((IDbDataParameter)cmd.Parameters[index]).Value = DBNull.Value; } else { stringType.Set(cmd, value, index); } } public System.Type ReturnedType { get { return typeof(string); } } public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner) { int index = rs.GetOrdinal(names[0]); if (rs.IsDBNull(index)) { return string.Empty; } else { return rs[index]; } } public bool IsMutable { get { return false; } } #endregion } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/EmptyStringType.cs Index: EmptyStringType.cs =================================================================== using System; using System.Data; using NHibernate; using NHibernate.SqlTypes; using NHibernate.Type; namespace NHibernate.Nullables2 { /// <summary> /// An <see cref="IUserType"/> that reads a <c>null</c> value from an <c>string</c> /// column in the database as a <see cref="String.Empty">String.Empty</see> /// and writes a <see cref="String.Empty">String.Empty</see> to the database /// as <c>null</c>. /// </summary> /// <remarks> /// This is intended to help with Windows Forms DataBinding and the problems associated /// with binding a null value. See <a href="http://jira.nhibernate.org/browse/NH-279"> /// NH-279</a> for the origin of this code. /// </remarks> public class EmptyStringType : IUserType { StringType stringType; public EmptyStringType() { stringType = (StringType)NHibernateUtil.String; } #region IUserType Members bool IUserType.Equals(object x, object y) { if( x==y ) { return true; } if( ( x==null ) || ( y==null ) ) { return false; } return x.Equals( y ); } public SqlType[] SqlTypes { get { return new SqlType[] { stringType.SqlType }; } } public DbType[] DbTypes { get { return new DbType[] { stringType.SqlType.DbType }; } } public object DeepCopy(object value) { return value; } public void NullSafeSet(IDbCommand cmd, object value, int index) { if( value==null || value.Equals(string.Empty) ) { ((IDbDataParameter)cmd.Parameters[index]).Value = DBNull.Value; } else { stringType.Set(cmd, value, index); } } public System.Type ReturnedType { get { return typeof(string); } } public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner) { int index = rs.GetOrdinal(names[0]); if (rs.IsDBNull(index)) { return string.Empty; } else { return rs[index]; } } public bool IsMutable { get { return false; } } #endregion } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NHibernate.Nullables2.csproj Index: NHibernate.Nullables2.csproj =================================================================== <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{298AFDF0-223D-4EBD-8310-E2FF4372F760}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>NHibernate.Nullables2</RootNamespace> <AssemblyName>NHibernate.Nullables2</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\NHibernate\log4net.dll</HintPath> </Reference> <Reference Include="NHibernate, Version=1.0.2.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\Lib\NHibernate\NHibernate.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="NullableBooleanType.cs" /> <Compile Include="NullableByteType.cs" /> <Compile Include="NullableCharType.cs" /> <Compile Include="NullableDateTimeType.cs" /> <Compile Include="NullableDecimalType.cs" /> <Compile Include="NullableDoubleType.cs" /> <Compile Include="NullableGuidType.cs" /> <Compile Include="NullableInt16Type.cs" /> <Compile Include="NullableInt32Type.cs" /> <Compile Include="NullableInt64Type.cs" /> <Compile Include="NullableSByteType.cs" /> <Compile Include="NullableSingleType.cs" /> <Compile Include="NullableBaseType.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project> 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableBaseType.cs Index: NullableBaseType.cs =================================================================== using System; using NHibernate; using NHibernate.Type; using NHibernate.SqlTypes; using log4net; namespace NHibernate.Nullables2 { /// <summary> /// Abstract type used for implementing NHibernate <see cref="IType"/>s for /// the Nullables library. /// </summary> public abstract class NullableBaseType : NullableType { private static readonly ILog log = LogManager.GetLogger( typeof(NullableBaseType) ); public NullableBaseType(SqlType type) : base(type) { } public override object NullSafeGet(System.Data.IDataReader rs, string name) { int index = rs.GetOrdinal(name); if( rs.IsDBNull(index) ) { if ( log.IsDebugEnabled ) { log.Debug("returning null as column: " + name); } return NullValue; //this value is determined by the subclass. } else { object val = null; try { val = Get(rs, index); } catch(System.InvalidCastException ice) { throw new ADOException( "Could not cast the value in field " + name + " to the Type " + this.GetType().Name + ". Please check to make sure that the mapping is correct and that your DataProvider supports this Data Type.", ice); } if ( log.IsDebugEnabled ) { log.Debug("returning '" + ToString(val) + "' as column: " + name); } return val; } } public override object Get(System.Data.IDataReader rs, string name) { return Get(rs, rs.GetOrdinal(name)); } public abstract object NullValue{ get; } } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableBooleanType.cs Index: NullableBooleanType.cs =================================================================== using System; using NHibernate.Type; using NHibernate.SqlTypes; namespace NHibernate.Nullables2 { /// <summary> /// A NHibernate <see cref="IType"/> for bool? /// </summary> public class NullableBooleanType : NullableBaseType { public NullableBooleanType() : base(new BooleanSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. bool? xTyped = (bool?)x; return xTyped.Equals(y); } public override object NullValue { get { return new bool?(); } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "bool?"; } } public override System.Type ReturnedClass { get { return typeof(bool?); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableBoolean has a method/operator/contructor that will take an object. object value = rs[index]; bool? nullBool = new bool?( (bool)value); return nullBool; } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; bool? nullableValue = (bool?)value; if (nullableValue.HasValue) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToString(object val) { return val.ToString(); } public override object FromStringValue(string xml) { return new bool?(Boolean.Parse(xml)); } } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableByteType.cs Index: NullableByteType.cs =================================================================== using System; using NHibernate.Type; using NHibernate.SqlTypes; namespace NHibernate.Nullables2 { /// <summary> /// A NHibernate <see cref="IType"/> for a byte?. /// </summary> public class NullableByteType : NullableBaseType { public NullableByteType() : base(new ByteSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. byte? xTyped = (byte?)x; return xTyped.Equals(y); } public override object NullValue { get { return new byte?(); } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "byte?"; } } public override System.Type ReturnedClass { get { return typeof(byte?); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableByte has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return new byte?(); } else { return new byte?(Convert.ToByte(value)); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; byte? nullableValue = (byte?)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToString(object val) { return val.ToString(); } public override object FromStringValue(string xml) { return new byte?(Byte.Parse(xml)); } } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableCharType.cs Index: NullableCharType.cs =================================================================== using System; using NHibernate.Type; using NHibernate.SqlTypes; namespace NHibernate.Nullables2 { /// <summary> /// A NHibernate <see cref="IType"/> for a char?. /// </summary> public class NullableCharType : NullableBaseType { public NullableCharType() : base(new StringFixedLengthSqlType(1)) { } public override bool Equals(object x, object y) { //get boxed values. char? xTyped = (char?)x; return xTyped.Equals(y); } public override object NullValue { get { return new char?(); } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "char?"; } } public override System.Type ReturnedClass { get { return typeof(char?); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableChar has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return new char?(); } else { return new char?(Convert.ToChar(value)); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; char? nullableValue = (char?)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToString(object val) { return val.ToString(); } public override object FromStringValue(string xml) { return new char?(xml[0]); } } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableDateTimeType.cs Index: NullableDateTimeType.cs =================================================================== using System; using NHibernate.Type; using NHibernate.SqlTypes; namespace NHibernate.Nullables2 { /// <summary> /// A NHibernate <see cref="IType"/> for a DateTime?. /// </summary> public class NullableDateTimeType : NullableBaseType { public NullableDateTimeType() : base(new DateTimeSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. DateTime? xTyped = (DateTime?)x; return xTyped.Equals(y); } public override object NullValue { get { return new DateTime?(); } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "DateTime?"; } } public override System.Type ReturnedClass { get { return typeof(DateTime?); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableDateTime has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return new DateTime?(); } else { return new DateTime?(Convert.ToDateTime(value)); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; DateTime? nullableValue = (DateTime?)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToString(object val) { return val.ToString(); } public override object FromStringValue(string xml) { return new DateTime?(DateTime.Parse(xml)); } } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableDecimalType.cs Index: NullableDecimalType.cs =================================================================== using System; using NHibernate.Type; using NHibernate.SqlTypes; namespace NHibernate.Nullables2 { /// <summary> /// A NHibernate <see cref="IType"/> for a <see cref="NullableDecimal"/>. /// </summary> public class NullableDecimalType : NullableBaseType { public NullableDecimalType() : base(new DecimalSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. decimal? xTyped = (decimal?)x; return xTyped.Equals(y); } public override object NullValue { get { return new decimal?(); } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "decimal?"; } } public override System.Type ReturnedClass { get { return typeof(decimal?); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableDecimal has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return new decimal?(); } else { return new decimal?(Convert.ToDecimal(value)); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; decimal? nullableValue = (decimal?)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToString(object val) { return val.ToString(); } public override object FromStringValue(string xml) { return new decimal?(Decimal.Parse(xml)); } } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableDoubleType.cs Index: NullableDoubleType.cs =================================================================== using System; using NHibernate.Type; using NHibernate.SqlTypes; namespace NHibernate.Nullables2 { /// <summary> /// A NHibernate <see cref="IType"/> for a <see cref="NullableDouble"/>. /// </summary> public class NullableDoubleType : NullableBaseType { public NullableDoubleType() : base(new DoubleSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. double? xTyped = (double?)x; return xTyped.Equals(y); } public override object NullValue { get { return new double?(); } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "double?"; } } public override System.Type ReturnedClass { get { return typeof(double?); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableDouble has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return new double?(); } else { return new double?(Convert.ToDouble(value)); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; double? nullableValue = (double?)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToString(object val) { return val.ToString(); } public override object FromStringValue(string xml) { return new double?(Double.Parse(xml)); } } } 1.1 plugins/etc/andromda-dotnet/NHibernate.Nullables2/NHibernate.Nullables2/NullableGuidType.cs Index: NullableGuidType.cs =================================================================== using System; using NHibernate.Type; using NHibernate.SqlTypes; namespace NHibernate.Nullables2 { /// <summary> /// A NHibernate <see cref="IType"/> for a <see cref="NullableGuid"/>. /// </summary> public class NullableGuidType : NullableBaseType { public NullableGuidType() : base(new GuidSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. Guid? xTyped = (Guid?)x; return xTyped.Equals(y); } public override object NullValue { get { return new Guid?(); } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "Guid?"; } } public override System.Type ReturnedClass { get { return typeof(Guid?); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableGuid has a method/oper... [truncated message content] |