当前位置: 首页>>代码示例>>C#>>正文


C# ISessionFactoryImplementor.GetImplementors方法代码示例

本文整理汇总了C#中ISessionFactoryImplementor.GetImplementors方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionFactoryImplementor.GetImplementors方法的具体用法?C# ISessionFactoryImplementor.GetImplementors怎么用?C# ISessionFactoryImplementor.GetImplementors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISessionFactoryImplementor的用法示例。


在下文中一共展示了ISessionFactoryImplementor.GetImplementors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetEntityPersister

		protected virtual IEntityPersister GetEntityPersister(ISessionFactoryImplementor factory, string entityName)
		{
			// Check for an exact match.
			IEntityPersister persister = factory.TryGetEntityPersister(entityName);
			if (persister != null)
			{
				return persister;
			}

			// Couldn't find persister through exact name, try finding a single implementing class.
			string[] implementors = factory.GetImplementors(entityName);
			if (implementors.Length > 1)
			{
				var messageBuilder = new StringBuilder(512);
				messageBuilder.AppendLine(string.Format("Ambiguous persister for {0} implemented by more than one hierarchy: ",
				                                        entityName));
				Array.ForEach(implementors, s=> messageBuilder.AppendLine(s));

				throw new HibernateException(messageBuilder.ToString());
			}
			if (implementors.Length == 0)
			{
				return null;
			}
			return factory.GetEntityPersister(implementors[0]);
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:26,代码来源:DefaultLoadEventListener.cs

示例2: ConcreteQueries

		public string[] ConcreteQueries(string query, ISessionFactoryImplementor factory)
		{
			// TODO H3.2 check if the QuerySplitter can do the work (this method is not present in H3.2)

			//scan the query string for class names appearing in the from clause and replace 
			//with all persistent implementors of the class/interface, returning multiple 
			//query strings (make sure we don't pick up a class in the select clause!) 

			//TODO: this is one of the ugliest and most fragile pieces of code in Hibernate...
			string[] tokens = StringHelper.Split(ParserHelper.Whitespace + "(),", query, true);
			if (tokens.Length == 0)
			{
				return new String[] {query};
			} // just especially for the trivial collection filter 

			var placeholders = new List<object>();
			var replacements = new List<object>();
			StringBuilder templateQuery = new StringBuilder(40);
			int count = 0;
			string last = null;
			int nextIndex = 0;
			string next = null;
			templateQuery.Append(tokens[0]);
			for (int i = 1; i < tokens.Length; i++)
			{
				//update last non-whitespace token, if necessary
				if (!ParserHelper.IsWhitespace(tokens[i - 1]))
				{
					last = tokens[i - 1].ToLowerInvariant();
				}

				string token = tokens[i];
				if (!ParserHelper.IsWhitespace(token) || last == null)
				{
					// scan for the next non-whitespace token
					if (nextIndex <= i)
					{
						for (nextIndex = i + 1; nextIndex < tokens.Length; nextIndex++)
						{
							next = tokens[nextIndex].ToLowerInvariant();
							if (!ParserHelper.IsWhitespace(next))
							{
								break;
							}
						}
					}

					//if ( Character.isUpperCase( token.charAt( token.lastIndexOf(".") + 1 ) ) ) {
					// added the checks for last!=null and next==null because an ISet can not contain 
					// a null key in .net - it is valid for a null key to be in a java.util.Set
					if (
						((last != null && beforeClassTokens.Contains(last)) && (next == null || !notAfterClassTokens.Contains(next))) ||
						PathExpressionParser.EntityClass.Equals(last))
					{
						System.Type clazz = Helper.GetImportedClass(token);
						if (clazz != null)
						{
							string[] implementors = factory.GetImplementors(clazz.FullName);
							string placeholder = "$clazz" + count++ + "$";

							if (implementors != null)
							{
								placeholders.Add(placeholder);
								replacements.Add(implementors);
							}
							token = placeholder; //Note this!!
						}
					}
				}
				templateQuery.Append(token);
			}
			string[] results =
				StringHelper.Multiply(templateQuery.ToString(), placeholders.GetEnumerator(), replacements.GetEnumerator());
			if (results.Length == 0)
			{
				log.Warn("no persistent classes found for query class: " + query);
			}
			return results;
		}
开发者ID:rbirkby,项目名称:nhibernate-core,代码行数:79,代码来源:QueryTranslator.cs

示例3: ConcreteQueries

		/// <summary>
		/// Handle Hibernate "implicit" polymorphism, by translating the query string into 
		/// several "concrete" queries against mapped classes.
		/// </summary>
		/// <param name="query"></param>
		/// <param name="factory"></param>
		/// <returns></returns>
		/// <exception cref="NHibernate.MappingException"/>
		public static string[] ConcreteQueries(string query, ISessionFactoryImplementor factory)
		{
			//scan the query string for class names appearing in the from clause and replace
			//with all persistent implementors of the class/interface, returning multiple
			//query strings (make sure we don't pick up a class in the select clause!)

			//TODO: this is one of the ugliest and most fragile pieces of code in Hibernate....

			SessionFactoryHelper helper = new SessionFactoryHelper(factory);

			string[] tokens = StringHelper.Split(StringHelper.WhiteSpace + "(),", query, true);
			if (tokens.Length == 0)
			{
				return new String[] {query}; // just especially for the trivial collection filter
			}
			ArrayList placeholders = new ArrayList();
			ArrayList replacements = new ArrayList();
			StringBuilder templateQuery = new StringBuilder(40);
			int count = 0;
			string last = null;
			int nextIndex = 0;
			string next = null;

			templateQuery.Append(tokens[0]);
			bool isSelectClause = StringHelper.EqualsCaseInsensitive("select", tokens[0]);

			for (int i = 1; i < tokens.Length; i++)
			{
				//update last non-whitespace token, if necessary
				if (!ParserHelper.IsWhitespace(tokens[i - 1]))
				{
					last = tokens[i - 1].ToLowerInvariant();
				}

				// select-range is terminated by declaration of "from"
				isSelectClause = !StringHelper.EqualsCaseInsensitive("from", tokens[i]);

				string token = tokens[i];
				if (!ParserHelper.IsWhitespace(token) || last == null)
				{
					//scan for next non-whitespace token
					if (nextIndex <= i)
					{
						for (nextIndex = i + 1; nextIndex < tokens.Length; nextIndex++)
						{
							next = tokens[nextIndex].ToLowerInvariant();
							if (!ParserHelper.IsWhitespace(next))
							{
								break;
							}
						}
					}

					// TODO H3.2 Different behavior
					// NHb: This block is not an exactly port from H3.2 but a port from previous implementation of QueryTranslator
					if (((last != null && beforeClassTokens.Contains(last)) &&
					     (next == null || !notAfterClassTokens.Contains(next))) ||
					    PathExpressionParser.EntityClass.Equals(last))
					{
						System.Type clazz = helper.GetImportedClass(token);
						if (clazz != null)
						{
							string[] implementors = factory.GetImplementors(clazz.FullName);
							string placeholder = "$clazz" + count++ + "$";

							if (implementors != null)
							{
								placeholders.Add(placeholder);
								replacements.Add(implementors);
							}
							token = placeholder; //Note this!!
						}
					}
				}
				templateQuery.Append(token);
			}
			string[] results =
				StringHelper.Multiply(templateQuery.ToString(), placeholders.GetEnumerator(), replacements.GetEnumerator());
			if (results.Length == 0)
			{
				log.Warn("no persistent classes found for query class: " + query);
			}
			return results;
		}
开发者ID:renefc3,项目名称:nhibernate,代码行数:92,代码来源:QuerySplitter.cs


注:本文中的ISessionFactoryImplementor.GetImplementors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。