You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2005/08/13 17:47:26 UTC
svn commit: r232503 [1/3] - in /ibatis/trunk/cs/mapper: IBatisNet.Common/
IBatisNet.Common/Utilities/ IBatisNet.Common/Xml/ IBatisNet.DataAccess/
IBatisNet.DataAccess/Configuration/
IBatisNet.DataAccess/Configuration/Serializers/ IBatisNet.DataMapper/ ...
Author: gbayon
Date: Sat Aug 13 08:46:16 2005
New Revision: 232503
URL: http://svn.apache.org/viewcvs?rev=232503&view=rev
Log:
- Removed usage of XmlSerialier for configuration => Boost the config loading
Added:
ibatis/trunk/cs/mapper/IBatisNet.Common/DataSourceDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Xml/
ibatis/trunk/cs/mapper/IBatisNet.Common/Xml/NodeUtils.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoSessionHandlerDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/CacheModelDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeSerializerFactory.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DiscriminatorDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DynamicDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/InsertDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsEmptyDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsEqualDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsGreaterEqualDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsGreaterThanDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsLessEqualDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsLessThanDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsNotEmptyDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsNotEqualDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsNotNullDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsNotParameterPresentDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsNotPropertyAvailableDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsNullDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsParameterPresentDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IsPropertyAvailableDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IterateSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterMapDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ParameterPropertyDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ProcedureDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ResultMapDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/ResultPropertyDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SelectDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/StatementDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/SubMapDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/TypeAliasDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/TypeHandlerDeSerializer.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/UpdateDeSerializer.cs
Removed:
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DataSourceConfig.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeAliasMapping.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/SerializerFactory.cs
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Dao.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DaoSessionHandler.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Sql/Dynamic/Elements/SqlTag.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Delete.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Generate.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/IStatement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Insert.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Procedure.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Select.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/SelectKey.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Statement.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/Update.cs
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/IBatisNet.DataMapper.csproj
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Scope/ConfigurationScope.cs
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/DataSourceDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/DataSourceDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/DataSourceDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/DataSourceDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,56 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+#endregion
+
+namespace IBatisNet.Common
+{
+ /// <summary>
+ /// Summary description for DataSourceDeSerializer.
+ /// </summary>
+ public class DataSourceDeSerializer
+ {
+ /// <summary>
+ /// Deserialize a DataSource object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <returns></returns>
+ public static DataSource Deserialize(XmlNode node)
+ {
+ DataSource dataSource = new DataSource();
+ NameValueCollection prop = NodeUtils.ParseAttributes(node);
+
+ dataSource.ConnectionString = prop["connectionString"];
+ dataSource.Name = prop["name"];
+
+ return dataSource;
+ }
+ }
+}
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj Sat Aug 13 08:46:16 2005
@@ -122,6 +122,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "DataSourceDeSerializer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "IBatisNet.Common.build"
BuildAction = "None"
/>
@@ -148,6 +153,11 @@
BuildAction = "Content"
/>
<File
+ RelPath = "ProviderDeSerializer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "Exceptions\ConfigurationException.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -324,6 +334,11 @@
/>
<File
RelPath = "Utilities\TypesResolver\TypeResolver.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Xml\NodeUtils.cs"
SubType = "Code"
BuildAction = "Compile"
/>
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Provider.cs Sat Aug 13 08:46:16 2005
@@ -455,7 +455,6 @@
/// <summary>
/// Do not use direclty, only for serialization.
/// </summary>
- [Obsolete("This public constructor with no parameter is not really obsolete, but is reserved for serialization.", false)]
public Provider()
{
}
@@ -465,7 +464,7 @@
/// <summary>
/// Init the provider.
/// </summary>
- public void Initialisation()
+ public void Initialize()
{
Assembly assembly;
Type type;
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/ProviderDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,74 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+#endregion
+
+namespace IBatisNet.Common
+{
+ /// <summary>
+ /// Summary description for ProviderDeSerializer.
+ /// </summary>
+ public class ProviderDeSerializer
+ {
+ /// <summary>
+ /// Deserialize a Provider object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <returns></returns>
+ public static Provider Deserialize(XmlNode node)
+ {
+ Provider provider = new Provider();
+ NameValueCollection prop = NodeUtils.ParseAttributes(node);
+
+ provider.AssemblyName = prop["assemblyName"];
+ provider.CommandBuilderClass = prop["commandBuilderClass"];
+ provider.CommandClass = prop["commandClass"];
+ provider.ConnectionClass = prop["connectionClass"];
+ provider.DataAdapterClass = prop["dataAdapterClass"];
+ provider.Description = prop["description"];
+ provider.IsDefault = NodeUtils.GetBooleanAttribute(prop, "default", false);
+ provider.IsEnabled = NodeUtils.GetBooleanAttribute(prop, "enabled", true);
+ provider.Name = prop["name"];
+ provider.ParameterClass = prop["parameterClass"];
+ provider.ParameterDbTypeClass = prop["parameterDbTypeClass"];
+ provider.ParameterDbTypeProperty = prop["parameterDbTypeProperty"];
+ provider.ParameterPrefix = prop["parameterPrefix"];
+ provider.SetDbParameterPrecision = NodeUtils.GetBooleanAttribute(prop, "setDbParameterPrecision", true);
+ provider.SetDbParameterScale = NodeUtils.GetBooleanAttribute(prop, "setDbParameterScale", true);
+ provider.SetDbParameterSize = NodeUtils.GetBooleanAttribute(prop, "setDbParameterSize", true);
+ provider.UseDeriveParameters = NodeUtils.GetBooleanAttribute(prop, "useDeriveParameters", true);
+ provider.UseParameterPrefixInParameter = NodeUtils.GetBooleanAttribute(prop, "useParameterPrefixInParameter", true);
+ provider.UseParameterPrefixInSql = NodeUtils.GetBooleanAttribute(prop, "useParameterPrefixInSql", true);
+ provider.UsePositionalParameters = NodeUtils.GetBooleanAttribute(prop, "usePositionalParameters", false);
+
+ return provider;
+ }
+ }
+}
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Resources.cs Sat Aug 13 08:46:16 2005
@@ -34,6 +34,7 @@
using System.Xml;
using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Utilities.TypesResolver;
+using IBatisNet.Common.Xml;
using log4net;
#endregion
@@ -229,17 +230,17 @@
if (node.Attributes["resource"] != null)
{
- string ressource = Resources.ParsePropertyTokens( node.Attributes["resource"].Value, properties);
+ string ressource = NodeUtils.ParsePropertyTokens( node.Attributes["resource"].Value, properties);
xmlDocument = Resources.GetResourceAsXmlDocument( ressource );
}
else if (node.Attributes["url"] != null)
{
- string url = Resources.ParsePropertyTokens( node.Attributes["url"].Value, properties);
+ string url = NodeUtils.ParsePropertyTokens( node.Attributes["url"].Value, properties);
xmlDocument = Resources.GetUrlAsXmlDocument( url );
}
else if (node.Attributes["embedded"] != null)
{
- string embedded = Resources.ParsePropertyTokens( node.Attributes["embedded"].Value, properties);
+ string embedded = NodeUtils.ParsePropertyTokens( node.Attributes["embedded"].Value, properties);
xmlDocument = Resources.GetEmbeddedResourceAsXmlDocument(embedded);
}
@@ -259,12 +260,12 @@
if (node.Attributes["resource"] != null)
{
- string ressource = Resources.ParsePropertyTokens( node.Attributes["resource"].Value, properties);
+ string ressource = NodeUtils.ParsePropertyTokens( node.Attributes["resource"].Value, properties);
path = Path.Combine(_applicationBase, ressource);
}
else if (node.Attributes["url"] != null)
{
- string url = Resources.ParsePropertyTokens( node.Attributes["url"].Value, properties);
+ string url = NodeUtils.ParsePropertyTokens( node.Attributes["url"].Value, properties);
path = url;
}
@@ -493,47 +494,6 @@
}
return fileInfo;
- }
-
-
- /// <summary>
- /// Replace properties by their values in the given string
- /// </summary>
- /// <param name="str"></param>
- /// <param name="properties"></param>
- /// <returns></returns>
- public static string ParsePropertyTokens(string str, NameValueCollection properties)
- {
- string OPEN = "${";
- string CLOSE = "}";
-
- string newString = str;
- if (newString != null && properties != null)
- {
- int start = newString.IndexOf(OPEN);
- int end = newString.IndexOf(CLOSE);
-
- while (start > -1 && end > start)
- {
- string prepend = newString.Substring(0, start);
- string append = newString.Substring(end + CLOSE.Length);
-
- int index = start + OPEN.Length;
- string propName = newString.Substring(index, end-index);
- string propValue = properties.Get(propName);
- if (propValue == null)
- {
- newString = prepend + propName + append;
- }
- else
- {
- newString = prepend + propValue + append;
- }
- start = newString.IndexOf(OPEN);
- end = newString.IndexOf(CLOSE);
- }
- }
- return newString;
}
Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Xml/NodeUtils.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Xml/NodeUtils.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Xml/NodeUtils.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Xml/NodeUtils.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,181 @@
+using System;
+using System.Xml;
+using System.Collections.Specialized;
+
+namespace IBatisNet.Common.Xml
+{
+ /// <summary>
+ /// Summary description for NodeUtils.
+ /// </summary>
+ public class NodeUtils
+ {
+
+ /// <summary>
+ /// Searches for the attribute with the specified name in this attributes list.
+ /// </summary>
+ /// <param name="attributes"></param>
+ /// <param name="name">The key</param>
+ /// <returns></returns>
+ public static string GetStringAttribute(NameValueCollection attributes, string name)
+ {
+ string value = attributes[name];
+ if (value == null)
+ {
+ return string.Empty;
+ }
+ else
+ {
+ return value;
+ }
+ }
+
+ /// <summary>
+ /// Searches for the attribute with the specified name in this attributes list.
+ /// </summary>
+ /// <param name="attributes"></param>
+ /// <param name="name">The key</param>
+ /// <param name="def">The default value to be returned if the attribute is not found.</param>
+ /// <returns></returns>
+ public static string GetStringAttribute(NameValueCollection attributes, string name, string def)
+ {
+ string value = attributes[name];
+ if (value == null)
+ {
+ return def;
+ }
+ else
+ {
+ return value;
+ }
+ }
+ /// <summary>
+ /// Searches for the attribute with the specified name in this attributes list.
+ /// </summary>
+ /// <param name="attributes"></param>
+ /// <param name="name">The key</param>
+ /// <param name="def">The default value to be returned if the attribute is not found.</param>
+ /// <returns></returns>
+ public static byte GetByteAttribute(NameValueCollection attributes, string name, byte def)
+ {
+ string value = attributes[name];
+ if (value == null)
+ {
+ return def;
+ }
+ else
+ {
+ return XmlConvert.ToByte(value);
+ }
+ }
+
+ /// <summary>
+ /// Searches for the attribute with the specified name in this attributes list.
+ /// </summary>
+ /// <param name="attributes"></param>
+ /// <param name="name">The key</param>
+ /// <param name="def">The default value to be returned if the attribute is not found.</param>
+ /// <returns></returns>
+ public static int GetIntAttribute(NameValueCollection attributes, string name, int def)
+ {
+ string value = attributes[name];
+ if (value == null)
+ {
+ return def;
+ }
+ else
+ {
+ return XmlConvert.ToInt32(value);
+ }
+ }
+
+ /// <summary>
+ /// Searches for the attribute with the specified name in this attributes list.
+ /// </summary>
+ /// <param name="attributes"></param>
+ /// <param name="name">The key</param>
+ /// <param name="def">The default value to be returned if the attribute is not found.</param>
+ /// <returns></returns>
+ public static bool GetBooleanAttribute(NameValueCollection attributes, string name, bool def)
+ {
+ string value = attributes[name];
+ if (value == null)
+ {
+ return def;
+ }
+ else
+ {
+ return XmlConvert.ToBoolean(value);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="node"></param>
+ /// <returns></returns>
+ public static NameValueCollection ParseAttributes(XmlNode node)
+ {
+ return ParseAttributes(node, null);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="node"></param>
+ /// <param name="variables"></param>
+ /// <returns></returns>
+ public static NameValueCollection ParseAttributes(XmlNode node, NameValueCollection variables)
+ {
+ NameValueCollection attributes = new NameValueCollection();
+ for (int i = 0; i < node.Attributes.Count; i++)
+ {
+ XmlAttribute attribute = node.Attributes[i];
+ String value = ParsePropertyTokens(attribute.Value, variables);
+ attributes.Add(attribute.Name, value);
+ }
+ return attributes;
+ }
+
+
+ /// <summary>
+ /// Replace properties by their values in the given string
+ /// </summary>
+ /// <param name="str"></param>
+ /// <param name="properties"></param>
+ /// <returns></returns>
+ public static string ParsePropertyTokens(string str, NameValueCollection properties)
+ {
+ string OPEN = "${";
+ string CLOSE = "}";
+
+ string newString = str;
+ if (newString != null && properties != null)
+ {
+ int start = newString.IndexOf(OPEN);
+ int end = newString.IndexOf(CLOSE);
+
+ while (start > -1 && end > start)
+ {
+ string prepend = newString.Substring(0, start);
+ string append = newString.Substring(end + CLOSE.Length);
+
+ int index = start + OPEN.Length;
+ string propName = newString.Substring(index, end-index);
+ string propValue = properties.Get(propName);
+ if (propValue == null)
+ {
+ newString = prepend + propName + append;
+ }
+ else
+ {
+ newString = prepend + propValue + append;
+ }
+ start = newString.IndexOf(OPEN);
+ end = newString.IndexOf(CLOSE);
+ }
+ }
+ return newString;
+ }
+
+ }
+}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Dao.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Dao.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Dao.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Dao.cs Sat Aug 13 08:46:16 2005
@@ -152,7 +152,6 @@
/// <summary>
/// Do not use direclty, only for serialization.
/// </summary>
- [Obsolete("This public constructor with no parameter is not really obsolete, but is reserved for serialization.", false)]
public Dao()
{
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DaoSessionHandler.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DaoSessionHandler.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DaoSessionHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DaoSessionHandler.cs Sat Aug 13 08:46:16 2005
@@ -108,7 +108,6 @@
/// <summary>
/// Do not use direclty, only for serialization.
/// </summary>
- [Obsolete("This public constructor with no parameter is not really obsolete, but is reserved for serialization.", false)]
public DaoSessionHandler()
{
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/DomDaoManagerBuilder.cs Sat Aug 13 08:46:16 2005
@@ -29,13 +29,15 @@
using System;
using System.Collections;
using System.IO;
+using System.Reflection;
using System.Threading;
using System.Xml;
-using System.Xml.Serialization;
using IBatisNet.Common;
using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Logging;
using IBatisNet.Common.Utilities;
+using IBatisNet.Common.Xml;
+using IBatisNet.DataAccess.Configuration.Serializers;
using IBatisNet.DataAccess.Interfaces;
using IBatisNet.DataAccess.Scope;
@@ -146,7 +148,7 @@
#region Fields
- private static readonly ILog _logger = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
+ private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
#endregion
@@ -371,7 +373,6 @@
/// <param name="configurationScope">The scope of the configuration</param>
private void GetProviders(ConfigurationScope configurationScope)
{
- XmlSerializer serializer = null;
Provider provider = null;
XmlDocument xmlProviders = null;
@@ -389,20 +390,18 @@
xmlProviders = Resources.GetConfigAsXmlDocument(PROVIDERS_FILE_NAME);
}
- serializer = new XmlSerializer(typeof(Provider));
-
foreach (XmlNode node in xmlProviders.SelectNodes(ApplyProviderNamespacePrefix(XML_PROVIDER), configurationScope.XmlNamespaceManager ) )
{
configurationScope.ErrorContext.Resource = node.InnerXml.ToString();
- provider = (Provider) serializer.Deserialize(new XmlNodeReader(node));
+ provider = ProviderDeSerializer.Deserialize(node);
if (provider.IsEnabled == true)
{
configurationScope.ErrorContext.ObjectId = provider.Name;
configurationScope.ErrorContext.MoreInfo = "initialize provider";
- provider.Initialisation();
+ provider.Initialize() ;
configurationScope.Providers.Add(provider.Name, provider);
if (provider.IsDefault == true)
{
@@ -429,12 +428,10 @@
/// <param name="configurationScope">The scope of the configuration</param>
private void GetDaoSessionHandlers(ConfigurationScope configurationScope)
{
- XmlSerializer serializer = null;
XmlNode daoSessionHandlersNode = null;
configurationScope.ErrorContext.Activity = "loading custom DaoSession Handlers";
- serializer = new XmlSerializer(typeof(DaoSessionHandler));
daoSessionHandlersNode = configurationScope.DaoConfigDocument.SelectSingleNode( ApplyNamespacePrefix(XML_DAO_SESSION_HANDLERS), configurationScope.XmlNamespaceManager);
if (daoSessionHandlersNode != null)
@@ -443,13 +440,11 @@
{
configurationScope.ErrorContext.Resource = node.InnerXml.ToString();
- DaoSessionHandler daoSessionHandler =(DaoSessionHandler) serializer.Deserialize(new XmlNodeReader(node));
+ DaoSessionHandler daoSessionHandler = DaoSessionHandlerDeSerializer.Deserialize(node, configurationScope);
configurationScope.ErrorContext.ObjectId = daoSessionHandler.Name;
configurationScope.ErrorContext.MoreInfo = "build daoSession handler";
- //IDaoSessionHandler sessionHandler = daoSessionHandler.GetIDaoSessionHandler();
-
configurationScope.DaoSectionHandlers[daoSessionHandler.Name] = daoSessionHandler.TypeInstance;
if (daoSessionHandler.IsDefault == true)
@@ -553,7 +548,7 @@
foreach(XmlNode nodeProperty in nodeSessionHandler.SelectNodes( ApplyNamespacePrefix(XML_PROPERTY), configurationScope.XmlNamespaceManager ))
{
resources.Add(nodeProperty.Attributes["name"].Value,
- Resources.ParsePropertyTokens(nodeProperty.Attributes["value"].Value, configurationScope.Properties));
+ NodeUtils.ParsePropertyTokens(nodeProperty.Attributes["value"].Value, configurationScope.Properties));
}
}
else
@@ -792,18 +787,16 @@
/// <returns>A DataSource</returns>
private DataSource ParseDataSource(ConfigurationScope configurationScope)
{
- XmlSerializer serializer = null;
DataSource dataSource = null;
XmlNode node = configurationScope.NodeContext.SelectSingleNode( ApplyNamespacePrefix(XML_DATABASE_DATASOURCE), configurationScope.XmlNamespaceManager);
configurationScope.ErrorContext.Resource = node.InnerXml.ToString();
configurationScope.ErrorContext.MoreInfo = "configure data source";
- serializer = new XmlSerializer(typeof(DataSourceConfig));
+ dataSource = DataSourceDeSerializer.Deserialize( node );
+// (DataSource)serializer.Deserialize(new XmlNodeReader(node));
- dataSource = (DataSource)serializer.Deserialize(new XmlNodeReader(node));
-
- dataSource.ConnectionString = Resources.ParsePropertyTokens(dataSource.ConnectionString, configurationScope.Properties);
+ dataSource.ConnectionString = NodeUtils.ParsePropertyTokens(dataSource.ConnectionString, configurationScope.Properties);
configurationScope.ErrorContext.Resource = string.Empty;
configurationScope.ErrorContext.MoreInfo = string.Empty;
@@ -819,16 +812,14 @@
/// <param name="daoManager"></param>
private void ParseDaoFactory(ConfigurationScope configurationScope, DaoManager daoManager)
{
- XmlSerializer serializer = null;
Dao dao = null;
configurationScope.ErrorContext.MoreInfo = "configure dao";
-
- serializer = new XmlSerializer(typeof(Dao));
foreach (XmlNode node in configurationScope.NodeContext.SelectNodes(ApplyNamespacePrefix(XML_DAO), configurationScope.XmlNamespaceManager ))
{
- dao = (Dao) serializer.Deserialize(new XmlNodeReader(node));
+ dao = DaoDeSerializer.Deserialize(node, configurationScope);
+ //(Dao) serializer.Deserialize(new XmlNodeReader(node));
configurationScope.ErrorContext.ObjectId = dao.Implementation;
Added: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,59 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+using IBatisNet.DataAccess.Scope;
+
+#endregion
+
+namespace IBatisNet.DataAccess.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for DaoDeSerializer.
+ /// </summary>
+ public class DaoDeSerializer
+ {
+ /// <summary>
+ /// Deserialize a Dao object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <param name="configScope"></param>
+ /// <returns></returns>
+ public static Dao Deserialize(XmlNode node, ConfigurationScope configScope)
+ {
+ Dao dao = new Dao();
+
+ NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties);
+ dao.Implementation = NodeUtils.GetStringAttribute(prop, "implementation");
+ dao.Interface = NodeUtils.GetStringAttribute(prop, "interface");
+
+ return dao;
+ }
+ }
+}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoSessionHandlerDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoSessionHandlerDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoSessionHandlerDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/Configuration/Serializers/DaoSessionHandlerDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,60 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+using IBatisNet.DataAccess.Scope;
+
+#endregion
+
+namespace IBatisNet.DataAccess.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for DaoSessionHandlerDeSerializer.
+ /// </summary>
+ public class DaoSessionHandlerDeSerializer
+ {
+ /// <summary>
+ /// Deserialize a Dao object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <param name="configScope"></param>
+ /// <returns></returns>
+ public static DaoSessionHandler Deserialize(XmlNode node, ConfigurationScope configScope)
+ {
+ DaoSessionHandler daoSessionHandler = new DaoSessionHandler();
+
+ NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties);
+ daoSessionHandler.Implementation = NodeUtils.GetStringAttribute(prop, "implementation");
+ daoSessionHandler.Name = NodeUtils.GetStringAttribute(prop, "id");
+ daoSessionHandler.IsDefault = NodeUtils.GetBooleanAttribute(prop, "default", false);
+
+ return daoSessionHandler;
+ }
+ }
+}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataAccess/IBatisNet.DataAccess.csproj Sat Aug 13 08:46:16 2005
@@ -163,12 +163,17 @@
BuildAction = "Compile"
/>
<File
- RelPath = "Configuration\DataSourceConfig.cs"
+ RelPath = "Configuration\DomDaoManagerBuilder.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
- RelPath = "Configuration\DomDaoManagerBuilder.cs"
+ RelPath = "Configuration\Serializers\DaoDeSerializer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Configuration\Serializers\DaoSessionHandlerDeSerializer.cs"
SubType = "Code"
BuildAction = "Compile"
/>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Alias/TypeHandler.cs Sat Aug 13 08:46:16 2005
@@ -101,11 +101,9 @@
/// <summary>
/// Do not use direclty, only for serialization.
/// </summary>
- [Obsolete("This public constructor with no parameter is not really obsolete, but is reserved for serialization.", false)]
public TypeHandler()
{}
#endregion
-
#region Methods
/// <summary>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/DomSqlMapBuilder.cs Sat Aug 13 08:46:16 2005
@@ -35,15 +35,19 @@
using System.Threading;
using System.Xml;
using System.Xml.Schema;
-using System.Xml.Serialization;
using IBatisNet.Common;
using IBatisNet.Common.Exceptions;
using IBatisNet.Common.Logging;
using IBatisNet.Common.Utilities;
+using IBatisNet.Common.Xml;
using IBatisNet.DataMapper.Configuration.Alias;
using IBatisNet.DataMapper.Configuration.Cache;
+using IBatisNet.DataMapper.Configuration.Cache.Fifo;
+using IBatisNet.DataMapper.Configuration.Cache.Lru;
+using IBatisNet.DataMapper.Configuration.Cache.Memory;
using IBatisNet.DataMapper.Configuration.ParameterMapping;
using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Configuration.Serializers;
using IBatisNet.DataMapper.Configuration.Sql;
using IBatisNet.DataMapper.Configuration.Sql.Dynamic;
using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Elements;
@@ -277,9 +281,10 @@
#region Fields
- private static readonly ILog _logger = LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
+ private static readonly ILog _logger = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType );
private ConfigurationScope _configScope = null;
+ private DeSerializerFactory _deSerializerFactory = null;
private InlineParameterMapParser _paramParser = null;
#endregion
@@ -293,6 +298,7 @@
{
_configScope = new ConfigurationScope();
_paramParser = new InlineParameterMapParser(_configScope.ErrorContext);
+ _deSerializerFactory = new DeSerializerFactory(_configScope);
}
/// <summary>
@@ -617,7 +623,7 @@
}
/// <summary>
- /// Intilaize an SqlMap.
+ /// Intialize an SqlMap.
/// </summary>
private void Initialize()
{
@@ -627,13 +633,13 @@
#region Cache Alias
- TypeAlias cacheAlias = new TypeAlias(typeof(IBatisNet.DataMapper.Configuration.Cache.Memory.MemoryCacheControler));
+ TypeAlias cacheAlias = new TypeAlias(typeof(MemoryCacheControler));
cacheAlias.Name = "MEMORY";
_configScope.SqlMapper.AddTypeAlias(cacheAlias.Name, cacheAlias);
- cacheAlias = new TypeAlias(typeof(IBatisNet.DataMapper.Configuration.Cache.Lru.LruCacheController));
+ cacheAlias = new TypeAlias(typeof(LruCacheController));
cacheAlias.Name = "LRU";
_configScope.SqlMapper.AddTypeAlias(cacheAlias.Name, cacheAlias);
- cacheAlias = new TypeAlias(typeof(IBatisNet.DataMapper.Configuration.Cache.Fifo.FifoCacheController));
+ cacheAlias = new TypeAlias(typeof(FifoCacheController));
cacheAlias.Name = "FIFO";
_configScope.SqlMapper.AddTypeAlias(cacheAlias.Name, cacheAlias);
@@ -661,23 +667,23 @@
{
if (setting.Attributes[ATR_USE_STATEMENT_NAMESPACES] != null )
{
- string value = Resources.ParsePropertyTokens(setting.Attributes[ATR_USE_STATEMENT_NAMESPACES].Value, _configScope.Properties);
+ string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_USE_STATEMENT_NAMESPACES].Value, _configScope.Properties);
_configScope.UseStatementNamespaces = Convert.ToBoolean( value );
}
if (setting.Attributes[ATR_CACHE_MODELS_ENABLED] != null )
{
- string value = Resources.ParsePropertyTokens(setting.Attributes[ATR_CACHE_MODELS_ENABLED].Value, _configScope.Properties);
+ string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_CACHE_MODELS_ENABLED].Value, _configScope.Properties);
_configScope.IsCacheModelsEnabled = Convert.ToBoolean( value );
}
if (setting.Attributes[ATR_EMBED_STATEMENT_PARAMS] != null )
{
- string value = Resources.ParsePropertyTokens(setting.Attributes[ATR_EMBED_STATEMENT_PARAMS].Value, _configScope.Properties);
+ string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_EMBED_STATEMENT_PARAMS].Value, _configScope.Properties);
_configScope.UseEmbedStatementParams = Convert.ToBoolean( value );
}
if (setting.Attributes[ATR_VALIDATE_SQLMAP] != null )
{
- string value = Resources.ParsePropertyTokens(setting.Attributes[ATR_VALIDATE_SQLMAP].Value, _configScope.Properties);
+ string value = NodeUtils.ParsePropertyTokens(setting.Attributes[ATR_VALIDATE_SQLMAP].Value, _configScope.Properties);
_configScope.ValidateSqlMap = Convert.ToBoolean( value );
}
}
@@ -727,13 +733,11 @@
{
_configScope.ErrorContext.Resource = nodeDataSource.OuterXml.ToString();
_configScope.ErrorContext.MoreInfo = "parse DataSource";
- XmlSerializer serializer = null;
- serializer = new XmlSerializer(typeof(DataSource));
- DataSource dataSource = (DataSource) serializer.Deserialize(new XmlNodeReader(nodeDataSource));
+
+ DataSource dataSource = DataSourceDeSerializer.Deserialize( nodeDataSource );
dataSource.Provider = provider;
- // Use Global Properties if any
- dataSource.ConnectionString = Resources.ParsePropertyTokens(dataSource.ConnectionString, _configScope.Properties);
+ dataSource.ConnectionString = NodeUtils.ParsePropertyTokens(dataSource.ConnectionString, _configScope.Properties);
_configScope.DataSource = dataSource;
_configScope.SqlMapper.DataSource = _configScope.DataSource;
@@ -751,15 +755,7 @@
foreach (XmlNode xmlNode in _configScope.SqlMapConfigDocument.SelectNodes( ApplyDataMapperNamespacePrefix(XML_GLOBAL_TYPEALIAS), _configScope.XmlNamespaceManager))
{
_configScope.ErrorContext.Activity = "loading global Type alias";
- TypeAlias typeAlias = null;
- XmlSerializer serializer = new XmlSerializer(typeof(TypeAlias));
-
- typeAlias = (TypeAlias) serializer.Deserialize(new XmlNodeReader(xmlNode));
- _configScope.ErrorContext.ObjectId = typeAlias.ClassName;
- _configScope.ErrorContext.MoreInfo = "initialize type alias";
- typeAlias.Initialize();
-
- _configScope.SqlMapper.AddTypeAlias( typeAlias.Name, typeAlias );
+ TypeAliasDeSerializer.Deserialize(xmlNode, _configScope);
}
_configScope.ErrorContext.Reset();
#endregion
@@ -770,40 +766,7 @@
try
{
_configScope.ErrorContext.Activity = "loading typeHandler";
- TypeHandler handler = null;
- XmlSerializer serializer = new XmlSerializer(typeof(TypeHandler));
-
- handler = (TypeHandler) serializer.Deserialize(new XmlNodeReader(xmlNode));
- _configScope.ErrorContext.ObjectId = handler.CallBackName;
- _configScope.ErrorContext.MoreInfo = "initialize typeHandler";
- handler.Initialize();
-
- _configScope.ErrorContext.MoreInfo = "Check the callback attribute '" + handler.CallBackName + "' (must be a classname).";
- ITypeHandler typeHandler = null;
- Type type = _configScope.SqlMapper.GetType(handler.CallBackName);
- object impl = Activator.CreateInstance( type );
- if (impl is ITypeHandlerCallback)
- {
- typeHandler = new CustomTypeHandler((ITypeHandlerCallback) impl);
- }
- else if (impl is ITypeHandler)
- {
- typeHandler = (ITypeHandler) impl;
- }
- else
- {
- throw new ConfigurationException("The callBack type is not a valid implementation of ITypeHandler or ITypeHandlerCallback");
- }
-
- _configScope.ErrorContext.MoreInfo = "Check the type attribute '" + handler.ClassName + "' (must be a class name) or the dbType '" + handler.DbType + "' (must be a DbType type name).";
- if (handler.DbType!= null && handler.DbType.Length > 0)
- {
- _configScope.TypeHandlerFactory.Register(Resources.TypeForName(handler.ClassName), handler.DbType, typeHandler);
- }
- else
- {
- _configScope.TypeHandlerFactory.Register(Resources.TypeForName(handler.ClassName), typeHandler);
- }
+ TypeHandlerDeSerializer.Deserialize( xmlNode, _configScope );
}
catch (Exception e)
{
@@ -880,7 +843,6 @@
/// </summary>
private void GetProviders()
{
- XmlSerializer serializer = null;
Provider provider = null;
XmlDocument xmlProviders = null;
@@ -898,20 +860,17 @@
xmlProviders = Resources.GetConfigAsXmlDocument(PROVIDERS_FILE_NAME);
}
- serializer = new XmlSerializer(typeof(Provider));
-
foreach (XmlNode node in xmlProviders.SelectNodes( ApplyProviderNamespacePrefix(XML_PROVIDER), _configScope.XmlNamespaceManager ) )
{
_configScope.ErrorContext.Resource = node.InnerXml.ToString();
-
- provider = (Provider) serializer.Deserialize(new XmlNodeReader(node));
+ provider = ProviderDeSerializer.Deserialize(node);
if (provider.IsEnabled == true)
{
_configScope.ErrorContext.ObjectId = provider.Name;
_configScope.ErrorContext.MoreInfo = "initialize provider";
- provider.Initialisation();
+ provider.Initialize();
_configScope.Providers.Add(provider.Name, provider);
if (provider.IsDefault == true)
@@ -944,8 +903,7 @@
if (node != null)
{
_configScope.ErrorContext.Resource = node.OuterXml.ToString();
- // name
- string providerName = Resources.ParsePropertyTokens(node.Attributes["name"].Value, _configScope.Properties);
+ string providerName = NodeUtils.ParsePropertyTokens(node.Attributes["name"].Value, _configScope.Properties);
_configScope.ErrorContext.ObjectId = providerName;
@@ -980,7 +938,6 @@
/// </summary>
private void ConfigureSqlMap( )
{
- XmlSerializer serializer = null;
XmlNode sqlMapNode = _configScope.NodeContext;
_configScope.ErrorContext.Activity = "loading SqlMap ";
@@ -1008,15 +965,7 @@
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_TYPEALIAS), _configScope.XmlNamespaceManager))
{
- _configScope.ErrorContext.MoreInfo = "loading type alias";
- TypeAlias typeAlias = null;
- serializer = new XmlSerializer(typeof(TypeAliasMapping));
- typeAlias = (TypeAlias) serializer.Deserialize(new XmlNodeReader(xmlNode));
- _configScope.ErrorContext.ObjectId = typeAlias.ClassName;
- _configScope.ErrorContext.MoreInfo = "initialize type alias";
- typeAlias.Initialize();
-
- _configScope.SqlMapper.AddTypeAlias( typeAlias.Name, typeAlias );
+ TypeAliasDeSerializer.Deserialize(xmlNode, _configScope);
}
_configScope.ErrorContext.MoreInfo = string.Empty;
_configScope.ErrorContext.ObjectId = string.Empty;
@@ -1051,7 +1000,6 @@
#region Statement tag
Statement statement = null;
- serializer = new XmlSerializer(typeof(Statement));
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_STATEMENT), _configScope.XmlNamespaceManager))
{
_configScope.ErrorContext.MoreInfo = "loading statement tag";
@@ -1059,7 +1007,7 @@
MappedStatement mappedStatement = null;
- statement = (Statement) serializer.Deserialize(new XmlNodeReader(xmlNode));
+ statement = StatementDeSerializer.Deserialize(xmlNode, _configScope);
statement.CacheModelName = ApplyNamespace( statement.CacheModelName );
statement.ParameterMapName = ApplyNamespace( statement.ParameterMapName );
statement.ResultMapName = ApplyNamespace( statement.ResultMapName );
@@ -1083,13 +1031,12 @@
#region Select tag
Select select = null;
- serializer = new XmlSerializer(typeof(Select));
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_SELECT), _configScope.XmlNamespaceManager))
{
_configScope.ErrorContext.MoreInfo = "loading select tag";
_configScope.NodeContext = xmlNode; // A select node
- select = (Select) serializer.Deserialize(new XmlNodeReader(xmlNode));
+ select = SelectDeSerializer.Deserialize(xmlNode, _configScope);
select.CacheModelName = ApplyNamespace( select.CacheModelName );
select.ParameterMapName = ApplyNamespace( select.ParameterMapName );
select.ResultMapName = ApplyNamespace( select.ResultMapName );
@@ -1126,7 +1073,6 @@
#region Insert tag
Insert insert = null;
- serializer = new XmlSerializer(typeof(Insert));
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_INSERT), _configScope.XmlNamespaceManager))
{
_configScope.ErrorContext.MoreInfo = "loading insert tag";
@@ -1134,7 +1080,7 @@
MappedStatement mappedStatement = null;
- insert = (Insert) serializer.Deserialize(new XmlNodeReader(xmlNode));
+ insert = InsertDeSerializer.Deserialize(xmlNode, _configScope);
insert.CacheModelName = ApplyNamespace( insert.CacheModelName );
insert.ParameterMapName = ApplyNamespace( insert.ParameterMapName );
insert.ResultMapName = ApplyNamespace( insert.ResultMapName );
@@ -1175,7 +1121,7 @@
// insert.SelectKey.Id = insert.Id + DOT + "SelectKey";
string commandText = xmlNode.SelectSingleNode( ApplyMappingNamespacePrefix(XML_SELECTKEY), _configScope.XmlNamespaceManager).FirstChild.InnerText.Replace('\n', ' ').Replace('\r', ' ').Replace('\t', ' ').Trim();
- commandText = Resources.ParsePropertyTokens(commandText, _configScope.Properties);
+ commandText = NodeUtils.ParsePropertyTokens(commandText, _configScope.Properties);
StaticSql sql = new StaticSql(insert.SelectKey);
IDalSession session = new SqlMapSession( _configScope.SqlMapper.DataSource );
sql.BuildPreparedStatement( session, commandText );
@@ -1192,7 +1138,6 @@
#region Update tag
Update update = null;
- serializer = new XmlSerializer(typeof(Update));
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_UPDATE), _configScope.XmlNamespaceManager))
{
_configScope.ErrorContext.MoreInfo = "loading update tag";
@@ -1200,7 +1145,7 @@
MappedStatement mappedStatement = null;
- update = (Update) serializer.Deserialize(new XmlNodeReader(xmlNode));
+ update = UpdateDeSerializer.Deserialize(xmlNode, _configScope);
update.CacheModelName = ApplyNamespace( update.CacheModelName );
update.ParameterMapName = ApplyNamespace( update.ParameterMapName );
update.ResultMapName = ApplyNamespace( update.ResultMapName );
@@ -1232,14 +1177,13 @@
#region Delete tag
Delete delete = null;
- serializer = new XmlSerializer(typeof(Delete));
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_DELETE), _configScope.XmlNamespaceManager))
{
_configScope.ErrorContext.MoreInfo = "loading delete tag";
_configScope.NodeContext = xmlNode; // A delete tag
MappedStatement mappedStatement = null;
- delete = (Delete) serializer.Deserialize(new XmlNodeReader(xmlNode));
+ delete = DeleteDeSerializer.Deserialize(xmlNode, _configScope);
delete.CacheModelName = ApplyNamespace( delete.CacheModelName );
delete.ParameterMapName = ApplyNamespace( delete.ParameterMapName );
delete.ResultMapName = ApplyNamespace( delete.ResultMapName );
@@ -1271,7 +1215,6 @@
#region Procedure tag
Procedure procedure = null;
- serializer = new XmlSerializer(typeof(Procedure));
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_PROCEDURE), _configScope.XmlNamespaceManager))
{
_configScope.ErrorContext.MoreInfo = "loading procedure tag";
@@ -1279,7 +1222,7 @@
MappedStatement mappedStatement = null;
- procedure = (Procedure)serializer.Deserialize(new XmlNodeReader(xmlNode));
+ procedure = ProcedureDeSerializer.Deserialize(xmlNode, _configScope);
procedure.CacheModelName = ApplyNamespace( procedure.CacheModelName );
procedure.ParameterMapName = ApplyNamespace( procedure.ParameterMapName );
procedure.ResultMapName = ApplyNamespace( procedure.ResultMapName );
@@ -1293,7 +1236,6 @@
// Build ISql (analyse sql command text)
ProcessSqlStatement( procedure );
- //config, sqlMapName, sqlMap, xmlNode, procedure);
// Build MappedStatement
mappedStatement = new MappedStatement( _configScope.SqlMapper, procedure);
@@ -1309,12 +1251,10 @@
if (_configScope.IsCacheModelsEnabled == true)
{
CacheModel cacheModel = null;
- serializer = new XmlSerializer(typeof(CacheModel));
foreach (XmlNode xmlNode in _configScope.SqlMapDocument.SelectNodes( ApplyMappingNamespacePrefix(XML_CACHE_MODEL), _configScope.XmlNamespaceManager))
{
- cacheModel = (CacheModel) serializer.Deserialize(new XmlNodeReader(xmlNode));
+ cacheModel = CacheModelDeSerializer.Deserialize(xmlNode, _configScope);
cacheModel.Id = ApplyNamespace( cacheModel.Id );
- cacheModel.Implementation = _configScope.SqlMapper.GetTypeAlias(cacheModel.Implementation).Class.AssemblyQualifiedName;
// Attach ExecuteEventHandler
foreach(XmlNode flushOn in xmlNode.SelectNodes( ApplyMappingNamespacePrefix(XML_FLUSH_ON_EXECUTE), _configScope.XmlNamespaceManager ))
@@ -1365,17 +1305,17 @@
_configScope.ErrorContext.MoreInfo = "process the Sql statement";
// Resolve "extend" attribute on Statement
- if (statement.ExtendSatement.Length >0)
+ if (statement.ExtendStatement.Length >0)
{
// Find 'super' statement
- XmlNode supperStatementNode = _configScope.SqlMapDocument.SelectSingleNode( ApplyMappingNamespacePrefix(XML_SEARCH_STATEMENT)+"/child::*[@id='"+statement.ExtendSatement+"']",_configScope.XmlNamespaceManager );
+ XmlNode supperStatementNode = _configScope.SqlMapDocument.SelectSingleNode( ApplyMappingNamespacePrefix(XML_SEARCH_STATEMENT)+"/child::*[@id='"+statement.ExtendStatement+"']",_configScope.XmlNamespaceManager );
if (supperStatementNode!=null)
{
commandTextNode.InnerXml = supperStatementNode.InnerXml + commandTextNode.InnerXml;
}
else
{
- throw new ConfigurationException("Unable to find extend statement named '"+statement.ExtendSatement+"' on statement '"+statement.Id+"'.'");
+ throw new ConfigurationException("Unable to find extend statement named '"+statement.ExtendStatement+"' on statement '"+statement.Id+"'.'");
}
}
@@ -1415,7 +1355,7 @@
{
string data = child.InnerText.Replace('\n', ' ').Replace('\r', ' ').Replace('\t', ' ').Trim(); //??
- data = Resources.ParsePropertyTokens(data, _configScope.Properties);
+ data = NodeUtils.ParsePropertyTokens(data, _configScope.Properties);
SqlText sqlText = null;
if ( postParseRequired == true )
@@ -1434,14 +1374,14 @@
else
{
string nodeName = child.Name;
- XmlSerializer serializer = SerializerFactory.GetSerializer(nodeName);
+ IDeSerializer serializer = _deSerializerFactory.GetDeSerializer(nodeName);
if (serializer != null)
{
isDynamic = true;
SqlTag tag = null;
- tag = (SqlTag) serializer.Deserialize(new XmlNodeReader(child));
+ tag = serializer.Deserialize(child);
dynamic.AddChild(tag);
@@ -1575,7 +1515,7 @@
}
}
}
- _configScope.ErrorContext.Reset();;
+ _configScope.ErrorContext.Reset();
}
@@ -1608,8 +1548,6 @@
ParameterMap parameterMap = null;
XmlNode parameterMapNode = _configScope.NodeContext;
- XmlSerializer serializer = new XmlSerializer(typeof(ParameterMap));
-
_configScope.ErrorContext.MoreInfo = "build ParameterMap";
// Get the parameterMap id
@@ -1619,11 +1557,7 @@
// Did we already process it ?
if (_configScope.SqlMapper.ParameterMaps.Contains( id ) == false)
{
- parameterMap = (ParameterMap) serializer.Deserialize(new XmlNodeReader(parameterMapNode));
-
- _configScope.ErrorContext.MoreInfo = "Initialize ParameterMap";
- _configScope.NodeContext = parameterMapNode;
- parameterMap.Initialize( _configScope );
+ parameterMap = ParameterMapDeSerializer.Deserialize(parameterMapNode, _configScope);
parameterMap.Id = ApplyNamespace( parameterMap.Id );
string attributeExtendMap = parameterMap.ExtendMap;
@@ -1675,8 +1609,6 @@
ResultMap resultMap = null;
XmlNode resultMapNode = _configScope.NodeContext;
- XmlSerializer serializer = new XmlSerializer(typeof(ResultMap));
-
_configScope.ErrorContext.MoreInfo = "build ResultMap";
string id = ApplyNamespace( ((XmlAttribute)resultMapNode.Attributes.GetNamedItem("id")).Value );
@@ -1685,18 +1617,13 @@
// Did we alredy process it
if (_configScope.SqlMapper.ResultMaps.Contains( id ) == false)
{
- resultMap = (ResultMap) serializer.Deserialize(new XmlNodeReader(resultMapNode));
+ resultMap = ResultMapDeSerializer.Deserialize( resultMapNode, _configScope );
- resultMap.SqlMapNameSpace = _configScope.SqlMapNamespace;
-
- _configScope.ErrorContext.MoreInfo = "initialize ResultMap";
- resultMap.Initialize( _configScope );
-
resultMap.Id = ApplyNamespace( resultMap.Id );
string attributeExtendMap = resultMap.ExtendMap;
resultMap.ExtendMap = ApplyNamespace( resultMap.ExtendMap );
- if (resultMap.ExtendMap.Length >0)
+ if (resultMap.ExtendMap!=null && resultMap.ExtendMap.Length >0)
{
ResultMap superMap = null;
// Did we already build Extend ResultMap?
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterMap.cs Sat Aug 13 08:46:16 2005
@@ -32,6 +32,7 @@
using System.Xml;
using System.Xml.Serialization;
using IBatisNet.Common.Utilities.Objects;
+using IBatisNet.DataMapper.Configuration.Serializers;
using IBatisNet.DataMapper.Scope;
using IBatisNet.DataMapper.TypeHandlers;
@@ -322,15 +323,11 @@
/// <param name="configScope"></param>
private void GetProperties(ConfigurationScope configScope)
{
- XmlSerializer serializer = null;
ParameterProperty property = null;
- serializer = new XmlSerializer(typeof(ParameterProperty));
foreach ( XmlNode parameterNode in configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_PARAMATER), configScope.XmlNamespaceManager) )
{
- property = (ParameterProperty) serializer.Deserialize(new XmlNodeReader(parameterNode));
- property.Initialize( configScope );
-
+ property = ParameterPropertyDeSerializer.Deserialize(parameterNode, configScope);
AddParameterProperty(property);
}
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ParameterMapping/ParameterProperty.cs Sat Aug 13 08:46:16 2005
@@ -49,7 +49,7 @@
#region Fields
[NonSerialized]
- private string _nullValue = string.Empty;
+ private string _nullValue = null;//string.Empty;//null;
[NonSerialized]
private string _property = string.Empty;
[NonSerialized]
@@ -211,12 +211,12 @@
}
/// <summary>
- /// Tell if a nullValue is defined.
+ /// Tell if a nullValue is defined._nullValue!=null
/// </summary>
[XmlIgnore]
public bool HasNullValue
{
- get { return (_nullValue.Length>0); }
+ get { return (_nullValue!=null); }
}
/// <summary>
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultMap.cs Sat Aug 13 08:46:16 2005
@@ -29,12 +29,11 @@
using System;
using System.Collections;
using System.Data;
-using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
using IBatisNet.Common.Exceptions;
-using IBatisNet.Common.Utilities.Objects;
using IBatisNet.Common.Utilities.TypesResolver;
+using IBatisNet.DataMapper.Configuration.Serializers;
using IBatisNet.DataMapper.Scope;
#endregion
@@ -219,25 +218,18 @@
/// <param name="configScope"></param>
private void GetChildNode(ConfigurationScope configScope)
{
- XmlSerializer serializer = null;
ResultProperty mapping = null;
SubMap subMap = null;
+
#region Load the Result Properties
- serializer = new XmlSerializer(typeof(ResultProperty));
foreach ( XmlNode resultNode in configScope.NodeContext.SelectNodes( DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_RESULT), configScope.XmlNamespaceManager) )
{
- mapping = (ResultProperty) serializer.Deserialize(new XmlNodeReader(resultNode));
+ mapping = ResultPropertyDeSerializer.Deserialize( resultNode, configScope );
configScope.ErrorContext.MoreInfo = "initialize result property :"+mapping.PropertyName;
-//
-// PropertyInfo propertyInfo = null;
-//
-// if ( mapping.PropertyName != "value" && !typeof(IDictionary).IsAssignableFrom(_class) )
-// {
-// propertyInfo = ReflectionInfo.GetInstance(_class).GetSetter( mapping.PropertyName );
-// }
+
mapping.Initialize( configScope, _class );
this.AddResultPropery( mapping );
@@ -246,21 +238,18 @@
#region Load the Discriminator Property
- serializer = new XmlSerializer(typeof(Discriminator));
XmlNode discriminatorNode = configScope.NodeContext.SelectSingleNode(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_DISCRIMNATOR), configScope.XmlNamespaceManager);
if (discriminatorNode != null)
{
configScope.ErrorContext.MoreInfo = "initialize discriminator";
- this.Discriminator = (Discriminator) serializer.Deserialize(new XmlNodeReader(discriminatorNode));
-
+ this.Discriminator = DiscriminatorDeSerializer.Deserialize(discriminatorNode, configScope);
this.Discriminator.SetMapping( configScope, _class );
}
#endregion
#region Load the SubMap Properties
- serializer = new XmlSerializer(typeof(SubMap));
if (configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_SUBMAP), configScope.XmlNamespaceManager).Count>0 && this.Discriminator==null)
{
throw new ConfigurationException("The discriminator is null, but somehow a subMap was reached. This is a bug.");
@@ -268,7 +257,8 @@
foreach ( XmlNode resultNode in configScope.NodeContext.SelectNodes(DomSqlMapBuilder.ApplyMappingNamespacePrefix(XML_SUBMAP), configScope.XmlNamespaceManager) )
{
configScope.ErrorContext.MoreInfo = "initialize subMap";
- subMap = (SubMap) serializer.Deserialize(new XmlNodeReader(resultNode));
+ subMap = SubMapDeSerializer.Deserialize(resultNode, configScope);
+
subMap.ResultMapName = this.SqlMapNameSpace + DomSqlMapBuilder.DOT + subMap.ResultMapName;
this.Discriminator.Add( subMap );
}
Modified: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs?rev=232503&r1=232502&r2=232503&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/ResultMapping/ResultProperty.cs Sat Aug 13 08:46:16 2005
@@ -58,9 +58,9 @@
#region Fields
[NonSerialized]
- private PropertyInfo _propertyInfo;
+ private PropertyInfo _propertyInfo = null;
[NonSerialized]
- private string _nullValue = string.Empty;
+ private string _nullValue = null;
[NonSerialized]
private string _propertyName = string.Empty;
[NonSerialized]
@@ -214,7 +214,7 @@
[XmlIgnore]
public bool HasNullValue
{
- get { return (_nullValue.Length>0); }
+ get { return (_nullValue!=null); }
}
/// <summary>
@@ -262,7 +262,7 @@
_propertyInfo = ReflectionInfo.GetInstance(resultClass).GetSetter( _propertyName );
}
- if (this.CallBackName.Length >0)
+ if (this.CallBackName!=null && this.CallBackName.Length >0)
{
configScope.ErrorContext.MoreInfo = "Result property '"+_propertyName+"' check the typeHandler attribute '" + this.CallBackName + "' (must be a ITypeHandlerCallback implementation).";
try
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/CacheModelDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/CacheModelDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/CacheModelDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/CacheModelDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,78 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+using IBatisNet.DataMapper.Configuration.Cache;
+using IBatisNet.DataMapper.Scope;
+#endregion
+
+
+namespace IBatisNet.DataMapper.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for CacheModelDeSerializer.
+ /// </summary>
+ public class CacheModelDeSerializer
+ {
+ /// <summary>
+ /// Deserialize a CacheModel object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <param name="configScope"></param>
+ /// <returns></returns>
+ public static CacheModel Deserialize(XmlNode node, ConfigurationScope configScope)
+ {
+ CacheModel model = new CacheModel();
+
+ NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties);
+ model.Id = NodeUtils.GetStringAttribute(prop, "id");
+ model.Implementation = NodeUtils.GetStringAttribute(prop, "implementation");
+ model.Implementation = configScope.SqlMapper.GetTypeAlias(model.Implementation).Class.AssemblyQualifiedName;
+
+ for(int i=0;i<node.ChildNodes.Count;i++)
+ {
+ if (node.ChildNodes[i].LocalName=="flushInterval")
+ {
+ FlushInterval flush = new FlushInterval();
+ NameValueCollection props = NodeUtils.ParseAttributes(node.ChildNodes[i], configScope.Properties);
+ flush.Hours = NodeUtils.GetIntAttribute(props, "hours", 0);
+ flush.Milliseconds = NodeUtils.GetIntAttribute(props, "milliseconds", 0);
+ flush.Minutes = NodeUtils.GetIntAttribute(props, "minutes", 0);
+ flush.Seconds = NodeUtils.GetIntAttribute(props, "seconds", 0);
+
+ flush.Initialize();
+
+ model.FlushInterval = flush;
+ }
+ }
+
+ return model;
+ }
+ }
+}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeSerializerFactory.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeSerializerFactory.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeSerializerFactory.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeSerializerFactory.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,50 @@
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using IBatisNet.DataMapper.Scope;
+
+namespace IBatisNet.DataMapper.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for DeSerializerFactory.
+ /// </summary>
+ public class DeSerializerFactory
+ {
+ private IDictionary _serializerMap = new HybridDictionary();
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="configScope"></param>
+ public DeSerializerFactory(ConfigurationScope configScope)
+ {
+ _serializerMap.Add("dynamic", new DynamicDeSerializer(configScope));
+ _serializerMap.Add("isEqual", new IsEqualDeSerializer(configScope));
+ _serializerMap.Add("isNotEqual", new IsNotEqualDeSerializer(configScope));
+ _serializerMap.Add("isGreaterEqual", new IsGreaterEqualDeSerializer(configScope));
+ _serializerMap.Add("isGreaterThan", new IsGreaterThanDeSerializer(configScope));
+ _serializerMap.Add("isLessEqual", new IsLessEqualDeSerializer(configScope));
+ _serializerMap.Add("isLessThan", new IsLessThanDeSerializer(configScope));
+ _serializerMap.Add("isNotEmpty", new IsNotEmptyDeSerializer(configScope));
+ _serializerMap.Add("isEmpty", new IsEmptyDeSerializer(configScope));
+ _serializerMap.Add("isNotNull", new IsNotNullDeSerializer(configScope));
+ _serializerMap.Add("isNotParameterPresent", new IsNotParameterPresentDeSerializer(configScope));
+ _serializerMap.Add("isNotPropertyAvailable", new IsNotPropertyAvailableDeSerializer(configScope));
+ _serializerMap.Add("isNull", new IsNullDeSerializer(configScope));
+ _serializerMap.Add("isParameterPresent", new IsParameterPresentDeSerializer(configScope));
+ _serializerMap.Add("isPropertyAvailable", new IsPropertyAvailableDeSerializer(configScope));
+ _serializerMap.Add("iterate", new IterateSerializer(configScope));
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
+ public IDeSerializer GetDeSerializer(string name)
+ {
+ return (IDeSerializer) _serializerMap[name];
+ }
+
+ }
+}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DeleteDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,79 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+using IBatisNet.DataMapper.Configuration.Statements;
+using IBatisNet.DataMapper.Scope;
+
+#endregion
+
+namespace IBatisNet.DataMapper.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for DeleteDeSerializer.
+ /// </summary>
+ public class DeleteDeSerializer
+ {
+ /// <summary>
+ /// Deserialize a TypeHandler object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <param name="configScope"></param>
+ /// <returns></returns>
+ public static Delete Deserialize(XmlNode node, ConfigurationScope configScope)
+ {
+ Delete delete = new Delete();
+ NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties);
+
+ delete.CacheModelName = NodeUtils.GetStringAttribute(prop, "cacheModel");
+ delete.ExtendStatement = NodeUtils.GetStringAttribute(prop, "extends");
+ delete.Id = NodeUtils.GetStringAttribute(prop, "id");
+ delete.ListClassName = NodeUtils.GetStringAttribute(prop, "listClass");
+ delete.ParameterClassName = NodeUtils.GetStringAttribute(prop, "parameterClass");
+ delete.ParameterMapName = NodeUtils.GetStringAttribute(prop, "parameterMap");
+ delete.ResultClassName = NodeUtils.GetStringAttribute(prop, "resultClass");
+ delete.ResultMapName = NodeUtils.GetStringAttribute(prop, "resultMap");
+
+ for(int i=0;i<node.ChildNodes.Count;i++)
+ {
+ if (node.ChildNodes[i].LocalName=="generate")
+ {
+ Generate generate = new Generate();
+ NameValueCollection props = NodeUtils.ParseAttributes(node.ChildNodes[i], configScope.Properties);
+
+ generate.By = NodeUtils.GetStringAttribute(props, "by");
+ generate.Table = NodeUtils.GetStringAttribute(props, "table");
+
+ delete.Generate = generate;
+ }
+ }
+ return delete;
+ }
+ }
+}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DiscriminatorDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DiscriminatorDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DiscriminatorDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DiscriminatorDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,63 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+using IBatisNet.DataMapper.Configuration.ResultMapping;
+using IBatisNet.DataMapper.Scope;
+#endregion
+
+namespace IBatisNet.DataMapper.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for DiscriminatorDeSerializer.
+ /// </summary>
+ public class DiscriminatorDeSerializer
+ {
+ /// <summary>
+ /// Deserialize a ResultMap object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <param name="configScope"></param>
+ /// <returns></returns>
+ public static Discriminator Deserialize(XmlNode node, ConfigurationScope configScope)
+ {
+ Discriminator discriminator = new Discriminator();
+
+ NameValueCollection prop = NodeUtils.ParseAttributes(node, configScope.Properties);
+ discriminator.CallBackName = NodeUtils.GetStringAttribute(prop, "typeHandler");
+ discriminator.CLRType = NodeUtils.GetStringAttribute(prop, "type");
+ discriminator.ColumnIndex = NodeUtils.GetIntAttribute( prop, "columnIndex", ResultProperty.UNKNOWN_COLUMN_INDEX );
+ discriminator.ColumnName = NodeUtils.GetStringAttribute(prop, "column");
+ discriminator.DbType = NodeUtils.GetStringAttribute(prop, "dbType");
+ discriminator.NullValue = prop["nullValue"];
+
+ return discriminator;
+ }
+ }
+}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DynamicDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DynamicDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DynamicDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/DynamicDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,74 @@
+#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.Collections.Specialized;
+using System.Xml;
+using IBatisNet.Common.Xml;
+using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Elements;
+using IBatisNet.DataMapper.Scope;
+
+#endregion
+
+namespace IBatisNet.DataMapper.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for DynamicDeSerializer.
+ /// </summary>
+ public class DynamicDeSerializer : IDeSerializer
+ {
+ private ConfigurationScope _configScope = null;
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="configScope"></param>
+ public DynamicDeSerializer(ConfigurationScope configScope)
+ {
+ _configScope = configScope;
+ }
+
+
+ #region IDeSerializer Members
+
+ /// <summary>
+ /// Deserialize a Dynamic object
+ /// </summary>
+ /// <param name="node"></param>
+ /// <returns></returns>
+ public SqlTag Deserialize(XmlNode node)
+ {
+ Dynamic dynamic = new Dynamic();
+
+ NameValueCollection prop = NodeUtils.ParseAttributes(node, _configScope.Properties);
+ dynamic.Prepend = NodeUtils.GetStringAttribute(prop, "prepend");
+
+ return dynamic;
+ }
+
+ #endregion
+ }
+}
Added: ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IDeSerializer.cs
URL: http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IDeSerializer.cs?rev=232503&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IDeSerializer.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Serializers/IDeSerializer.cs Sat Aug 13 08:46:16 2005
@@ -0,0 +1,46 @@
+#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.Xml;
+using IBatisNet.DataMapper.Configuration.Sql.Dynamic.Elements;
+#endregion
+
+namespace IBatisNet.DataMapper.Configuration.Serializers
+{
+ /// <summary>
+ /// Summary description for IDeSerializer.
+ /// </summary>
+ public interface IDeSerializer
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="node"></param>
+ /// <returns></returns>
+ SqlTag Deserialize(XmlNode node);
+ }
+}