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


C# StringTokenizer.GetEnumerator方法代码示例

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


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

示例1: NotSoSimpleWithDelimiters

		public void NotSoSimpleWithDelimiters()
		{
			string s = "The lazy... I don't know ";
			StringTokenizer st = new StringTokenizer(s, " .", true);
			IEnumerator enumerator = st.GetEnumerator();
			enumerator.MoveNext();
			Assert.AreEqual("The", (string) enumerator.Current, "Can't get first token");
			enumerator.MoveNext();
			Assert.AreEqual(" ", (string) enumerator.Current, "Can't get first space");
			enumerator.MoveNext();
			Assert.AreEqual("lazy", (string) enumerator.Current, "Can't get second token");
			enumerator.MoveNext();
			Assert.AreEqual(".", (string) enumerator.Current, "Can't get first dot");
			enumerator.MoveNext();
			Assert.AreEqual(".", (string) enumerator.Current, "Can't get second dot");
			enumerator.MoveNext();
			Assert.AreEqual(".", (string) enumerator.Current, "Can't get third dot");
			enumerator.MoveNext();
			Assert.AreEqual(" ", (string) enumerator.Current, "Can't get second space");
			enumerator.MoveNext();
			Assert.AreEqual("I", (string) enumerator.Current, "Can't get third token");
			enumerator.MoveNext();
			Assert.AreEqual(" ", (string) enumerator.Current, "Can't get third space");
			enumerator.MoveNext();
			Assert.AreEqual("don't", (string) enumerator.Current, "Can't get fourth token");
			enumerator.MoveNext();
			Assert.AreEqual(" ", (string) enumerator.Current, "Can't get fourth space");
			enumerator.MoveNext();
			Assert.AreEqual("know", (string) enumerator.Current, "Can't get fifth token");
			enumerator.MoveNext();
			Assert.AreEqual(" ", (string) enumerator.Current, "Can't get last space");
			Assert.AreEqual(false, enumerator.MoveNext(), "Still thinking there are more tokens");
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:33,代码来源:StringTokenizerFixture.cs

示例2: SimpleStringWithoutDelimiters

		public void SimpleStringWithoutDelimiters()
		{
			string s = "Hello world!";
			StringTokenizer st = new StringTokenizer(s);
			IEnumerator enumerator = st.GetEnumerator();
			enumerator.MoveNext();
			Assert.AreEqual("Hello", (string) enumerator.Current, "Can't get first token");
			enumerator.MoveNext();
			Assert.AreEqual("world!", (string) enumerator.Current, "Can't get second token");
			Assert.AreEqual(false, enumerator.MoveNext(), "Still thinking there are more tokens");
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:11,代码来源:StringTokenizerFixture.cs

示例3: ToDictionary

		/// <summary>
		/// 
		/// </summary>
		/// <param name="property"></param>
		/// <param name="delim"></param>
		/// <param name="properties"></param>
		/// <returns></returns>
		public static IDictionary ToDictionary( string property, string delim, IDictionary properties )
		{
			IDictionary map = new Hashtable();
			string propValue = ( string ) properties[ property ];
			if( propValue != null )
			{
				StringTokenizer tokens = new StringTokenizer( propValue, delim, false );
				IEnumerator en = tokens.GetEnumerator();
				while( en.MoveNext() )
				{
					string key = ( string ) en.Current;

					string value = en.MoveNext() ? ( string ) en.Current : String.Empty;
					map[ key ] = value;
				}
			}
			return map;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:25,代码来源:PropertiesHelper.cs

示例4: ToDictionary

		public static IDictionary<string, string> ToDictionary(string property, string delim, IDictionary<string, string> properties)
		{
			IDictionary<string, string> map = new Dictionary<string, string>();
			
			if (properties.ContainsKey(property))
			{
				string propValue = properties[property];
				StringTokenizer tokens = new StringTokenizer(propValue, delim, false);
				IEnumerator<string> en = tokens.GetEnumerator();
				while (en.MoveNext())
				{
					string key = en.Current;

					string value = en.MoveNext() ? en.Current : String.Empty;
					map[key] = value;
				}
			}
			return map;
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:19,代码来源:PropertiesHelper.cs

示例5: Replace

        private string Replace(string message, object entity)
        {
            var tokens = new StringTokenizer(message, "#${}", true);
            var buf = new StringBuilder(100);
            var escaped = false;
            var el = false;
            var isMember = false;

            IEnumerator ie = tokens.GetEnumerator();

            while (ie.MoveNext())
            {
                string token = (string) ie.Current;

                if (!escaped && "#".Equals(token))
                {
                    el = true;
                }

                if(!el && ("$".Equals(token)))
                {
                    isMember = true;
                }
                else if("}".Equals(token) && isMember)
                {
                    isMember = false;
                }
                if (!el && "{".Equals(token))
                {
                    escaped = true;
                }
                else if (escaped && "}".Equals(token))
                {
                    escaped = false;
                }
                else if (!escaped)
                {
                    if ("{".Equals(token))
                    {
                        el = false;
                    }

                    if(!"$".Equals(token)) buf.Append(token);
                }
                else if(!isMember)
                {
                    object variable;
                    if (attributeParameters.TryGetValue(token.ToLowerInvariant(), out variable))
                    {
                        buf.Append(variable);
                    }
                    else
                    {
                        string _string = null;
                        try
                        {
                            _string = messageBundle != null ? messageBundle.GetString(token, culture) : null;
                        }
                        catch (MissingManifestResourceException)
                        {
                            //give a second chance with the default resource bundle
                        }
                        if (_string == null)
                        {
                            _string = defaultMessageBundle.GetString(token, culture);
                            // in this case we don't catch the MissingManifestResourceException because
                            // we are sure that we DefaultValidatorMessages.resx is an embedded resource
                        }
                        if (_string == null)
                        {
                            buf.Append('{').Append(token).Append('}');
                        }
                        else
                        {
                            buf.Append(Replace(_string,entity));
                        }
                    }
                }
                else
                {
                    ReplaceValue(buf, entity, token);
                }
            }
            return buf.ToString();
        }
开发者ID:mpielikis,项目名称:nhibernate-contrib,代码行数:85,代码来源:DefaultMessageInterpolator.cs

示例6: RenderWhereStringTemplate

		public static string RenderWhereStringTemplate(string sqlWhereString, string placeholder, Dialect.Dialect dialect,
		                                               SQLFunctionRegistry functionRegistry)
		{
			//TODO: make this a bit nicer
			string symbols = new StringBuilder()
				.Append("=><!+-*/()',|&`")
				.Append(ParserHelper.Whitespace)
				.Append(dialect.OpenQuote)
				.Append(dialect.CloseQuote)
				.ToString();
			StringTokenizer tokens = new StringTokenizer(sqlWhereString, symbols, true);

			StringBuilder result = new StringBuilder();
			bool quoted = false;
			bool quotedIdentifier = false;
			bool beforeTable = false;
			bool inFromClause = false;
			bool afterFromTable = false;

			IEnumerator tokensEnum = tokens.GetEnumerator();
			bool hasMore = tokensEnum.MoveNext();
			string nextToken = hasMore ? (string) tokensEnum.Current : null;
			while (hasMore)
			{
				string token = nextToken;
				string lcToken = token.ToLower(CultureInfo.InvariantCulture);
				hasMore = tokensEnum.MoveNext();
				nextToken = hasMore ? (string) tokensEnum.Current : null;

				bool isQuoteCharacter = false;

				if (!quotedIdentifier && "'".Equals(token))
				{
					quoted = !quoted;
					isQuoteCharacter = true;
				}

				if (!quoted)
				{
					bool isOpenQuote;
					if ("`".Equals(token))
					{
						isOpenQuote = !quotedIdentifier;
						token = lcToken = isOpenQuote ?
						                  dialect.OpenQuote.ToString() :
						                  dialect.CloseQuote.ToString();
						quotedIdentifier = isOpenQuote;
						isQuoteCharacter = true;
					}
					else if (!quotedIdentifier && (dialect.OpenQuote == token[0]))
					{
						isOpenQuote = true;
						quotedIdentifier = true;
						isQuoteCharacter = true;
					}
					else if (quotedIdentifier && (dialect.CloseQuote == token[0]))
					{
						quotedIdentifier = false;
						isQuoteCharacter = true;
						isOpenQuote = false;
					}
					else
					{
						isOpenQuote = false;
					}

					if (isOpenQuote)
					{
						result.Append(placeholder).Append('.');
					}
				}

				bool quotedOrWhitespace = quoted ||
				                          quotedIdentifier ||
				                          isQuoteCharacter ||
				                          char.IsWhiteSpace(token[0]);

				if (quotedOrWhitespace)
				{
					result.Append(token);
				}
				else if (beforeTable)
				{
					result.Append(token);
					beforeTable = false;
					afterFromTable = true;
				}
				else if (afterFromTable)
				{
					if (!"as".Equals(lcToken))
						afterFromTable = false;
					result.Append(token);
				}
				else if (IsNamedParameter(token))
				{
					result.Append(token);
				}
				else if (
					IsIdentifier(token, dialect) &&
					!IsFunctionOrKeyword(lcToken, nextToken, dialect, functionRegistry)
//.........这里部分代码省略.........
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:101,代码来源:Template.cs

示例7: RenderOrderByStringTemplate

		public static string RenderOrderByStringTemplate(string sqlOrderByString, Dialect.Dialect dialect,
		                                                 SQLFunctionRegistry functionRegistry)
		{
			//TODO: make this a bit nicer
			string symbols = new StringBuilder()
				.Append("=><!+-*/()',|&`")
				.Append(ParserHelper.Whitespace)
				.Append(dialect.OpenQuote)
				.Append(dialect.CloseQuote)
				.ToString();
			StringTokenizer tokens = new StringTokenizer(sqlOrderByString, symbols, true);

			StringBuilder result = new StringBuilder();
			bool quoted = false;
			bool quotedIdentifier = false;

			IEnumerator<string> tokensEnum = tokens.GetEnumerator();
			bool hasMore = tokensEnum.MoveNext();
			string nextToken = hasMore ? tokensEnum.Current : null;
			while (hasMore)
			{
				string token = nextToken;
				string lcToken = token.ToLowerInvariant();
				hasMore = tokensEnum.MoveNext();
				nextToken = hasMore ? tokensEnum.Current : null;

				bool isQuoteCharacter = false;

				if (!quotedIdentifier && "'".Equals(token))
				{
					quoted = !quoted;
					isQuoteCharacter = true;
				}

				if (!quoted)
				{
					bool isOpenQuote;
					if ("`".Equals(token))
					{
						isOpenQuote = !quotedIdentifier;
						token = lcToken = isOpenQuote ?
						                  dialect.OpenQuote.ToString() :
						                  dialect.CloseQuote.ToString();
						quotedIdentifier = isOpenQuote;
						isQuoteCharacter = true;
					}
					else if (!quotedIdentifier && (dialect.OpenQuote == token[0]))
					{
						isOpenQuote = true;
						quotedIdentifier = true;
						isQuoteCharacter = true;
					}
					else if (quotedIdentifier && (dialect.CloseQuote == token[0]))
					{
						quotedIdentifier = false;
						isQuoteCharacter = true;
						isOpenQuote = false;
					}
					else
					{
						isOpenQuote = false;
					}

					if (isOpenQuote)
					{
						result.Append(Placeholder).Append('.');
					}
				}

				bool quotedOrWhitespace = quoted ||
				                          quotedIdentifier ||
				                          isQuoteCharacter ||
				                          char.IsWhiteSpace(token[0]);

				if (quotedOrWhitespace)
				{
					result.Append(token);
				}
				else if (
					IsIdentifier(token, dialect) &&
					!IsFunctionOrKeyword(lcToken, nextToken, dialect, functionRegistry)
					)
				{
					result.Append(Placeholder)
						.Append('.')
						.Append(token);
				}
				else
				{
					result.Append(token);
				}
			}
			return result.ToString();
		}
开发者ID:nikson,项目名称:nhibernate-core,代码行数:94,代码来源:Template.cs

示例8: OnlyDelimitersWithoutDelimiters

		public void OnlyDelimitersWithoutDelimiters()
		{
			string s = " .,,,";
			StringTokenizer st = new StringTokenizer(s, " ,.", false);
			IEnumerator enumerator = st.GetEnumerator();
			Assert.AreEqual(false, enumerator.MoveNext(), "Still thinking there are more tokens");
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:7,代码来源:StringTokenizerFixture.cs

示例9: OnlyDelimitersWithDelimiters

		public void OnlyDelimitersWithDelimiters()
		{
			string s = " .,,,";
			StringTokenizer st = new StringTokenizer(s, " ,.", true);
			IEnumerator enumerator = st.GetEnumerator();
			enumerator.MoveNext();
			Assert.AreEqual(" ", (string) enumerator.Current, "Can't get first delimiter");
			enumerator.MoveNext();
			Assert.AreEqual(".", (string) enumerator.Current, "Can't get second delimiter");
			enumerator.MoveNext();
			Assert.AreEqual(",", (string) enumerator.Current, "Can't get third delimiter");
			enumerator.MoveNext();
			Assert.AreEqual(",", (string) enumerator.Current, "Can't get fourth delimiter");
			enumerator.MoveNext();
			Assert.AreEqual(",", (string) enumerator.Current, "Can't get fifth delimiter");
			Assert.AreEqual(false, enumerator.MoveNext(), "Still thinking there are more tokens");
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:17,代码来源:StringTokenizerFixture.cs

示例10: ResolveArgument

        private IActor ResolveArgument(IActor resolvedActor, String expression, int index)
        {
            String argument = null;

            String whiteSpace = "                                                                                      ".Substring(0, index);

            String[] parameters = null;

            int argumentEndIndex = expression.IndexOf("->", index);
            if (argumentEndIndex == -1)
            {
                argumentEndIndex = expression.Length;
            }

            int parametersStartIndex = expression.IndexOf("(", index);
            int parametersEndIndex = -1;
            if ((parametersStartIndex != -1) && (parametersStartIndex < argumentEndIndex))
            {
                argument = expression.Substring(index, (parametersStartIndex) - (index)).Trim();
                parametersEndIndex = expression.IndexOf(")", parametersStartIndex + 1);

                if (parametersEndIndex > argumentEndIndex)
                {
                    throw new SystemException("can't resolve assigner expression : couldn't find closing bracket for bracket on index '" + parametersStartIndex + "' in expression '" + expression + "'");
                }

                // the next exception happens when a parameter contains a right bracket.
                String shouldBewhiteSpace = expression.Substring(parametersEndIndex + 1, (argumentEndIndex) - (parametersEndIndex + 1));
                if (!"".Equals(shouldBewhiteSpace.Trim()))
                {
                    throw new SystemException("can't resolve assigner expression : only whitespace allowed between closing bracket of the parameterlist of an argument and the end of the argument : closing bracket position '" + parametersEndIndex + "' in expression '" + expression + "'");
                }

                String parametersText = expression.Substring(parametersStartIndex + 1, (parametersEndIndex) - (parametersStartIndex + 1));
                ArrayList parameterList = new ArrayList();

                StringTokenizer tokenizer = new StringTokenizer(parametersText, ",");
                IEnumerator tokenEnum = tokenizer.GetEnumerator();
                while (tokenEnum.MoveNext())
                {
                    parameterList.Add(tokenEnum.Current.ToString().Trim());
                }

                if (parameterList.Count > 0)
                {
                    parameters = new String[parameterList.Count];
                    parameters = (String[])parameterList.ToArray(typeof(String));
                }
                else
                {
                    parameters = new String[0];
                }
            }
            else
            {
                argument = expression.Substring(index, (argumentEndIndex) - (index)).Trim();
                parameters = new String[0];
            }

            if ("".Equals(argument))
            {
                throw new SystemException("can't resolve assigner expression : can't resolve empty argument on index '" + index + "' for expression '" + expression + "'");
            }

            String methodName = "ResolveArgument" + argument.Substring(0, 1).ToUpper() + argument.Substring(1);
            try
            {
                MethodInfo method = this.GetType().GetMethod(methodName, (Type[])RESOLVE_METHOD_ARGUMENT_TYPES);
                Object[] args = new Object[] { resolvedActor, parameters };

                resolvedActor = (IActor)method.Invoke(this, (Object[])args);
            }
            catch (Exception t)
            {
                throw new SystemException("can't resolve assigner expression : couldn't resolve argument '" + argument + "' : " + t.Message, t);
            }

            if (argumentEndIndex != expression.Length)
            {
                if (argumentEndIndex < expression.Length)
                {
                    argumentEndIndex = expression.IndexOf("->", argumentEndIndex) + 2;
                }
                resolvedActor = ResolveArgument(resolvedActor, expression, argumentEndIndex);
            }

            return resolvedActor;
        }
开发者ID:ephebe,项目名称:netbpm,代码行数:88,代码来源:ActorExpressionResolverService.cs

示例11: RenderWhereStringTemplate

		/// <summary>
		/// Takes the where condition provided in the mapping attribute and iterpolates the alias.
		/// </summary>
		/// <param name="whereSql">The "where" sql statement from the mapping attribute.</param>
		/// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with rendering the Sql.</param>
		/// <returns>
		/// A well formed "where" sql statement for the <see cref="Dialect.Dialect"/>.
		/// </returns>
		public static string RenderWhereStringTemplate( string whereSql, Dialect.Dialect dialect )
		{
			//TODO: make this a bit nicer.

			StringTokenizer tokens = new StringTokenizer( whereSql, delimiters, true );

			StringBuilder result = new StringBuilder( whereSql.Length + 10 );

			bool quoted = false;
			bool afterFrom = false;
			bool afterFromTable = false;

			IEnumerator tokensEnum = tokens.GetEnumerator();
			bool hasMore = tokensEnum.MoveNext();
			string nextToken = hasMore ? ( string ) tokensEnum.Current : null;

			while( hasMore )
			{
				string token = nextToken;
				hasMore = tokensEnum.MoveNext();
				nextToken = hasMore ? ( string ) tokensEnum.Current : null;

				// the begin or end "'" has been found
				if( "'".Equals( token ) )
				{
					quoted = !quoted;
				}

				if( quoted || char.IsWhiteSpace( token[ 0 ] ) )
				{
					result.Append( token );
				}
				else
				{
					bool isIdentifier = token[ 0 ] == '`' || ( // allow any identifier quoted with backtick
						Char.IsLetter( token[ 0 ] ) && // only recognizes identifiers beginning with a letter
							!Keywords.Contains( token.ToLower( System.Globalization.CultureInfo.InvariantCulture ) ) &&
							token.IndexOf( '.' ) < 0
						);

					if( afterFrom )
					{
						result.Append( token );
						afterFrom = false;
						afterFromTable = true;
					}
					else if( afterFromTable )
					{
						afterFromTable = false;
						result.Append( token );
					}
					else if( isIdentifier && ( nextToken == null || !nextToken.Equals( "(" ) ) ) // not a function call
					{
						result.Append( Placeholder )
							.Append( StringHelper.Dot )
							.Append( Quote( token, dialect ) );

					}
					else
					{
						if( "from".Equals( token.ToLower( System.Globalization.CultureInfo.InvariantCulture ) ) )
						{
							afterFrom = true;
						}
						result.Append( token );
					}
				}
			}

			return result.ToString();

		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:80,代码来源:Template.cs

示例12: RenderOrderByStringTemplate

		/// <summary>
		/// Takes "order by" clause in the mapping attribute and iterpolates the alias
		/// </summary>
		/// <param name="orderBySql">The "order by" sql statement from the mapping.</param>
		/// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with rendering the Sql.</param>
		/// <returns>
		/// A well formed "order by" sql statement for the <see cref="Dialect.Dialect"/>.
		/// </returns>
		public static string RenderOrderByStringTemplate( string orderBySql, Dialect.Dialect dialect )
		{
			//TODO: make this a bit nicer
			StringTokenizer tokens = new StringTokenizer( orderBySql, ",", false );
			StringBuilder result = new StringBuilder( orderBySql.Length + 2 );
			bool commaNeeded = false;
			IEnumerator tokenEnum = tokens.GetEnumerator();

			while( tokenEnum.MoveNext() )
			{
				string column = Quote( ( ( string ) tokenEnum.Current ).Trim(), dialect );

				if( commaNeeded )
				{
					result.Append( StringHelper.CommaSpace );
				}
				commaNeeded = true;

				result.Append( Placeholder )
					.Append( StringHelper.Dot )
					.Append( column );
			}

			return result.ToString();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:33,代码来源:Template.cs

示例13: InitParameterBookKeeping

		private void InitParameterBookKeeping()
		{
			StringTokenizer st = new StringTokenizer( queryString, ParserHelper.HqlSeparators, true );
			ISet result = new HashedSet();

			IEnumerator enumer = st.GetEnumerator();
			while( enumer.MoveNext() ) 
			{
				string str = (string) enumer.Current;
				if ( str.StartsWith( ParserHelper.HqlVariablePrefix ) )
				{
					result.Add( str.Substring( 1 ) );
				}
			}

			actualNamedParameters = result;
			// TODO: This is weak as it doesn't take account of ? embedded in the SQL
			positionalParameterCount = StringHelper.CountUnquoted( queryString, StringHelper.SqlParameter.ToCharArray()[0] );
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:19,代码来源:AbstractQueryImpl.cs


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