/// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <param name="ctx"></param>
        /// <param name="parameterObject"></param>
        /// <param name="localChildren"></param>
        /// <param name="buffer"></param>
        private void ProcessBodyChildren(RequestScope request, SqlTagContext ctx,
                                         object parameterObject, IEnumerator localChildren, StringBuilder buffer)
        {
            while (localChildren.MoveNext())
            {
                ISqlChild child = (ISqlChild)localChildren.Current;

                if (child is SqlText)
                {
                    SqlText sqlText      = (SqlText)child;
                    string  sqlStatement = sqlText.Text;
                    if (sqlText.IsWhiteSpace)
                    {
                        buffer.Append(sqlStatement);
                    }
                    else
                    {
//						if (SimpleDynamicSql.IsSimpleDynamicSql(sqlStatement))
//						{
//							sqlStatement = new SimpleDynamicSql(sqlStatement, _statement).GetSql(parameterObject);
//							SqlText newSqlText = _paramParser.ParseInlineParameterMap( null, sqlStatement );
//							sqlStatement = newSqlText.Text;
//							ParameterProperty[] mappings = newSqlText.Parameters;
//							if (mappings != null)
//							{
//								for (int i = 0; i < mappings.Length; i++)
//								{
//									ctx.AddParameterMapping(mappings[i]);
//								}
//							}
//						}
                        // BODY OUT
                        buffer.Append(" ");
                        buffer.Append(sqlStatement);

                        ParameterProperty[] parameters = sqlText.Parameters;
                        if (parameters != null)
                        {
                            int length = parameters.Length;
                            for (int i = 0; i < length; i++)
                            {
                                ctx.AddParameterMapping(parameters[i]);
                            }
                        }
                    }
                }
                else if (child is SqlTag)
                {
                    SqlTag         tag      = (SqlTag)child;
                    ISqlTagHandler handler  = tag.Handler;
                    int            response = BaseTagHandler.INCLUDE_BODY;

                    do
                    {
                        StringBuilder body = new StringBuilder();

                        response = handler.DoStartFragment(ctx, tag, parameterObject);
                        if (response != BaseTagHandler.SKIP_BODY)
                        {
                            if (ctx.IsOverridePrepend &&
                                ctx.FirstNonDynamicTagWithPrepend == null &&
                                tag.IsPrependAvailable &&
                                !(tag.Handler is DynamicTagHandler))
                            {
                                ctx.FirstNonDynamicTagWithPrepend = tag;
                            }

                            ProcessBodyChildren(request, ctx, parameterObject, tag.GetChildrenEnumerator(), body);

                            response = handler.DoEndFragment(ctx, tag, parameterObject, body);
                            handler.DoPrepend(ctx, tag, parameterObject, body);
                            if (response != BaseTagHandler.SKIP_BODY)
                            {
                                if (body.Length > 0)
                                {
                                    // BODY OUT

                                    if (handler.IsPostParseRequired)
                                    {
                                        SqlText sqlText = _paramParser.ParseInlineParameterMap(request, null, body.ToString());
                                        buffer.Append(sqlText.Text);
                                        ParameterProperty[] mappings = sqlText.Parameters;
                                        if (mappings != null)
                                        {
                                            int length = mappings.Length;
                                            for (int i = 0; i < length; i++)
                                            {
                                                ctx.AddParameterMapping(mappings[i]);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        buffer.Append(" ");
                                        buffer.Append(body.ToString());
                                    }
                                    if (tag.IsPrependAvailable && tag == ctx.FirstNonDynamicTagWithPrepend)
                                    {
                                        ctx.IsOverridePrepend = false;
                                    }
                                }
                            }
                        }
                    }while (response == BaseTagHandler.REPEAT_BODY);
                }
            }
        }
Esempio n. 2
0
 private void ProcessBodyChildren(RequestScope request, SqlTagContext ctx, object parameterObject, IEnumerator localChildren, StringBuilder buffer)
 {
     while (localChildren.MoveNext())
     {
         ISqlChild current = (ISqlChild)localChildren.Current;
         if (current is SqlText)
         {
             SqlText text = (SqlText)current;
             string  str  = text.Text;
             if (text.IsWhiteSpace)
             {
                 buffer.Append(str);
             }
             else
             {
                 buffer.Append(" ");
                 buffer.Append(str);
                 ParameterProperty[] parameters = text.Parameters;
                 if (parameters != null)
                 {
                     int length = parameters.Length;
                     for (int i = 0; i < length; i++)
                     {
                         ctx.AddParameterMapping(parameters[i]);
                     }
                 }
             }
         }
         else if (current is SqlTag)
         {
             SqlTag         tag     = (SqlTag)current;
             ISqlTagHandler handler = tag.Handler;
             int            num3    = 1;
             do
             {
                 StringBuilder builder = new StringBuilder();
                 num3 = handler.DoStartFragment(ctx, tag, parameterObject);
                 if (num3 != 0)
                 {
                     if ((ctx.IsOverridePrepend && (ctx.FirstNonDynamicTagWithPrepend == null)) && (tag.IsPrependAvailable && !(tag.Handler is DynamicTagHandler)))
                     {
                         ctx.FirstNonDynamicTagWithPrepend = tag;
                     }
                     this.ProcessBodyChildren(request, ctx, parameterObject, tag.GetChildrenEnumerator(), builder);
                     num3 = handler.DoEndFragment(ctx, tag, parameterObject, builder);
                     handler.DoPrepend(ctx, tag, parameterObject, builder);
                     if ((num3 != 0) && (builder.Length > 0))
                     {
                         if (handler.IsPostParseRequired)
                         {
                             SqlText text2 = this._paramParser.ParseInlineParameterMap(request, null, builder.ToString());
                             buffer.Append(text2.Text);
                             ParameterProperty[] propertyArray2 = text2.Parameters;
                             if (propertyArray2 != null)
                             {
                                 int num4 = propertyArray2.Length;
                                 for (int j = 0; j < num4; j++)
                                 {
                                     ctx.AddParameterMapping(propertyArray2[j]);
                                 }
                             }
                         }
                         else
                         {
                             buffer.Append(" ");
                             buffer.Append(builder.ToString());
                         }
                         if (tag.IsPrependAvailable && (tag == ctx.FirstNonDynamicTagWithPrepend))
                         {
                             ctx.IsOverridePrepend = false;
                         }
                     }
                 }
             }while (num3 == 2);
         }
     }
 }