filterdefinitionfactory.cs

来自「NHibernate NET开发者所需的」· CS 代码 · 共 43 行

CS
43
字号
using System.Collections.Generic;
using log4net;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Engine;
using NHibernate.Type;

namespace NHibernate.Cfg.XmlHbmBinding
{
	public class FilterDefinitionFactory
	{
		private static readonly ILog log = LogManager.GetLogger(typeof (FilterDefinitionFactory));

		public static FilterDefinition CreateFilterDefinition(HbmFilterDef filterDefSchema)
		{
			log.DebugFormat("Parsing filter-def [{0}]", filterDefSchema.name);

			string defaultCondition = filterDefSchema.GetDefaultCondition();
			IDictionary<string, IType> parameterTypes = GetFilterParameterTypes(filterDefSchema);

			log.DebugFormat("Parsed filter-def [{0}]", filterDefSchema.name);

			return new FilterDefinition(filterDefSchema.name, defaultCondition, parameterTypes);
		}

		private static IDictionary<string, IType> GetFilterParameterTypes(HbmFilterDef filterDefSchema)
		{
			Dictionary<string, IType> parameterTypes = new Dictionary<string, IType>();

			foreach (HbmFilterParam paramSchema in filterDefSchema.ListParameters())
			{
				log.DebugFormat("Adding filter parameter : {0} -> {1}", paramSchema.name, paramSchema.type);

				IType heuristicType = TypeFactory.HeuristicType(paramSchema.type);

				log.DebugFormat("Parameter heuristic type : {0}", heuristicType);

				parameterTypes.Add(paramSchema.name, heuristicType);
			}

			return parameterTypes;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?