/// <summary> /// /// </summary> /// <param name="ctx"></param> /// <param name="tag"></param> /// <param name="parameterObject"></param> /// <returns></returns> public override int DoStartFragment(SqlTagContext ctx, SqlTag tag, object parameterObject) { IterateContext iterate = (IterateContext)ctx.GetAttribute(tag); if (iterate == null) { string propertyName = ((BaseTag)tag).Property; object collection; if (propertyName != null && propertyName.Length > 0) { collection = ObjectProbe.GetMemberValue(parameterObject, propertyName, this.AccessorFactory); } else { collection = parameterObject; } iterate = new IterateContext(collection); ctx.AddAttribute(tag, iterate); } if (iterate != null && iterate.HasNext) { return(BaseTagHandler.INCLUDE_BODY); } else { return(BaseTagHandler.SKIP_BODY); } }
public override int DoStartFragment(SqlTagContext ctx, SqlTag tag, object parameterObject) { IterateContext attribute = (IterateContext)ctx.GetAttribute(tag); if (attribute == null) { object obj2; string property = ((BaseTag)tag).Property; if ((property != null) && (property.Length > 0)) { obj2 = ObjectProbe.GetMemberValue(parameterObject, property, base.AccessorFactory); } else { obj2 = parameterObject; } attribute = new IterateContext(obj2); ctx.AddAttribute(tag, attribute); } if ((attribute != null) && attribute.HasNext) { return(1); } return(0); }
/// <summary> /// /// </summary> /// <param name="ctx"></param> /// <param name="tag"></param> /// <param name="parameterObject"></param> /// <param name="bodyContent"></param> public override void DoPrepend(SqlTagContext ctx, SqlTag tag, object parameterObject, StringBuilder bodyContent) { IterateContext iterate = (IterateContext)ctx.GetAttribute(tag); if (iterate.IsFirst) { base.DoPrepend(ctx, tag, parameterObject, bodyContent); } }
/// <summary> /// /// </summary> /// <param name="ctx"></param> /// <param name="tag"></param> /// <param name="parameterObject"></param> /// <param name="bodyContent"></param> /// <returns></returns> public override int DoEndFragment(SqlTagContext ctx, SqlTag tag, object parameterObject, StringBuilder bodyContent) { IterateContext iterate = (IterateContext)ctx.GetAttribute(tag); if (iterate.MoveNext()) { string propertyName = ((BaseTag)tag).Property; if (propertyName == null) { propertyName = ""; } string find = propertyName + "[]"; string replace = propertyName + "[" + iterate.Index + "]"; //Parameter-index-Dynamic Replace(bodyContent, find, replace); if (iterate.IsFirst) { string open = ((Iterate)tag).Open; if (open != null) { bodyContent.Insert(0, open); bodyContent.Insert(0, ' '); } } if (!iterate.IsLast) { string conjunction = ((Iterate)tag).Conjunction; if (conjunction != null) { bodyContent.Append(conjunction); bodyContent.Append(' '); } } if (iterate.IsLast) { string close = ((Iterate)tag).Close; if (close != null) { bodyContent.Append(close); } } return(BaseTagHandler.REPEAT_BODY); } else { return(BaseTagHandler.INCLUDE_BODY); } }
public override int DoEndFragment(SqlTagContext ctx, SqlTag tag, object parameterObject, StringBuilder bodyContent) { IterateContext attribute = (IterateContext)ctx.GetAttribute(tag); if (!attribute.MoveNext()) { return(1); } string property = ((BaseTag)tag).Property; if (property == null) { property = ""; } string find = property + "[]"; string replace = string.Concat(new object[] { property, "[", attribute.Index, "]" }); Replace(bodyContent, find, replace); if (attribute.IsFirst) { string open = ((Iterate)tag).Open; if (open != null) { bodyContent.Insert(0, open); bodyContent.Insert(0, ' '); } } if (!attribute.IsLast) { string conjunction = ((Iterate)tag).Conjunction; if (conjunction != null) { bodyContent.Append(conjunction); bodyContent.Append(' '); } } if (attribute.IsLast) { string close = ((Iterate)tag).Close; if (close != null) { bodyContent.Append(close); } } return(2); }
/// <summary> /// /// </summary> /// <param name="ctx"></param> /// <param name="tag"></param> /// <param name="parameterObject"></param> /// <returns></returns> public override int DoStartFragment(SqlTagContext ctx, SqlTag tag, object parameterObject) { IterateContext iterate = (IterateContext) ctx.GetAttribute(tag); if (iterate == null) { string propertyName = ((BaseTag)tag).Property; object collection; if (propertyName != null && propertyName.Length>0) { collection = ObjectProbe.GetMemberValue(parameterObject, propertyName, this.AccessorFactory); } else { collection = parameterObject; } iterate = new IterateContext(collection); ctx.AddAttribute(tag, iterate); } if (iterate != null && iterate.HasNext) { return BaseTagHandler.INCLUDE_BODY; } else { return BaseTagHandler.SKIP_BODY; } }