/// <summary> /// Processes the dynamic elements with old syntax $property$ /// </summary> /// <param name="parameterObject">The parameter object.</param> /// <returns></returns> private string ProcessDynamicElementsOldSyntax(object parameterObject) { var textPropertyProbe = new TextPropertyProbe(sqlStatement); // code that was here has been moved as is into appropriate classes using a strategy pattern. return(textPropertyProbe.Process(new SimpleDynamicSqlTextTokenHandler(this.dataExchangeFactory, parameterObject))); }
/// <summary> /// Processes the body children. /// </summary> /// <param name="request">The request.</param> /// <param name="ctx">The CTX.</param> /// <param name="parameterObject">The parameter object.</param> /// <param name="childEnumerator">The child enumerator.</param> /// <param name="buffer">The buffer.</param> private void ProcessBodyChildren( RequestScope request, SqlTagContext ctx, object parameterObject, IEnumerator <ISqlChild> childEnumerator, StringBuilder buffer) { while (childEnumerator.MoveNext()) { ISqlChild child = childEnumerator.Current; if (child is SqlText) { // this represents the content within a mybatis xml tag, typically the hand-crafted sql itself var sqlText = (SqlText)child; if (sqlText.IsWhiteSpace) { buffer.Append(sqlText.Text); } else { // BODY OUT var textPropertyProbe = new TextPropertyProbe(sqlText.Text); // process the sql text content, replacing bindings and property usage. var sqlStatment = textPropertyProbe.Process(new DynamicSqlTextTokenHandler(ctx, sqlText)); buffer.Append(" "); buffer.Append(sqlStatment); ctx.AddParameterMappings(sqlText); } } else if (child is SqlTag) { SqlTag tag = (SqlTag)child; ISqlTagHandler handler = tag.Handler; int response = BaseTagHandler.INCLUDE_BODY; do { var body = new StringBuilder(); // if the tag is a bind element, add the bind element to a list so that we can later on work out how to replace variable usage. if (tag is Bind) { ctx.RememberBinding((Bind)tag); } response = handler.DoStartFragment(ctx, tag, parameterObject); // replace any bind variables found within the body content. // what's a bit confusing here is that the body element is essentially populated by actions that take place after this line // a recursive call could then be made which results in this being called again. ctx.ReplaceBindingVariables(body); if (response == BaseTagHandler.SKIP_BODY) { break; } ctx.CheckAssignFirstDynamicTagWithPrepend(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) { break; } if (body.Length > 0) { // BODY OUT if (handler.IsPostParseRequired) { var sqlText = InlineParameterMapParser.ParseInlineParameterMap(dataExchangeFactory, statement.Id, null, body.ToString()); sqlText.Parent = tag; buffer.Append(sqlText.Text); ctx.AddParameterMappings(sqlText); } else { buffer.Append(" "); buffer.Append(body.ToString()); } if (tag.IsPrependAvailable && tag == ctx.FirstNonDynamicTagWithPrepend) { ctx.IsOverridePrepend = false; } } }while (response == BaseTagHandler.REPEAT_BODY); } } }