/// <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);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="sqlTag"></param>
        /// <param name="parameterObject"></param>
        /// <returns></returns>
        protected long Compare(SqlTagContext ctx, SqlTag sqlTag, object parameterObject)
        {
            Conditional tag                 = (Conditional)sqlTag;
            string      propertyName        = tag.Property;
            string      comparePropertyName = tag.CompareProperty;
            string      compareValue        = tag.CompareValue;

            object value1 = null;
            Type   type   = null;

            if (propertyName != null && propertyName.Length > 0)
            {
                value1 = ObjectProbe.GetMemberValue(parameterObject, propertyName, this.AccessorFactory);
                type   = value1.GetType();
            }
            else
            {
                value1 = parameterObject;
                if (value1 != null)
                {
                    type = parameterObject.GetType();
                }
                else
                {
                    type = typeof(object);
                }
            }
            if (comparePropertyName != null && comparePropertyName.Length > 0)
            {
                object value2 = ObjectProbe.GetMemberValue(parameterObject, comparePropertyName, this.AccessorFactory);
                return(CompareValues(type, value1, value2));
            }
            else if (compareValue != null && compareValue != "")
            {
                return(CompareValues(type, value1, compareValue));
            }
            else
            {
                throw new DataMapperException("Error comparing in conditional fragment.  Uknown 'compare to' values.");
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="tag"></param>
 /// <param name="parameterObject"></param>
 /// <returns></returns>
 public override bool IsCondition(SqlTagContext ctx, SqlTag tag, object parameterObject)
 {
     if (parameterObject == null)
     {
         return(true);
     }
     else
     {
         string propertyName = ((BaseTag)tag).Property;
         object value;
         if (propertyName != null && propertyName.Length > 0)
         {
             value = ObjectProbe.GetMemberValue(parameterObject, propertyName, this.AccessorFactory);
         }
         else
         {
             value = parameterObject;
         }
         return(value == null);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="tag"></param>
 /// <param name="parameterObject"></param>
 /// <returns></returns>
 public override bool IsCondition(SqlTagContext ctx, SqlTag tag, object parameterObject)
 {
     return(this.Compare(ctx, tag, parameterObject) == 0);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="tag"></param>
 /// <param name="parameterObject"></param>
 /// <returns></returns>
 public override bool IsCondition(SqlTagContext ctx, SqlTag tag, object parameterObject)
 {
     return(!base.IsCondition(ctx, tag, parameterObject));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="tag"></param>
 /// <param name="parameterObject"></param>
 /// <param name="bodyContent"></param>
 /// <returns></returns>
 public virtual int DoEndFragment(SqlTagContext ctx, SqlTag tag, object parameterObject, StringBuilder bodyContent)
 {
     return(BaseTagHandler.INCLUDE_BODY);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="tag"></param>
 /// <param name="parameterObject"></param>
 /// <returns></returns>
 public virtual int DoStartFragment(SqlTagContext ctx, SqlTag tag, object parameterObject)
 {
     return(BaseTagHandler.INCLUDE_BODY);
 }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="tag"></param>
        /// <param name="parameterObject"></param>
        /// <returns></returns>
        public override bool IsCondition(SqlTagContext ctx, SqlTag tag, object parameterObject)
        {
            long x = this.Compare(ctx, tag, parameterObject);

            return((x < 0) && (x != ConditionalTagHandler.NOT_COMPARABLE));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="tag"></param>
 /// <param name="parameterObject"></param>
 /// <returns></returns>
 public abstract bool IsCondition(SqlTagContext ctx, SqlTag tag, object parameterObject);
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="tag"></param>
 /// <param name="parameterObject"></param>
 /// <returns></returns>
 public override bool IsCondition(SqlTagContext ctx, SqlTag tag, object parameterObject)
 {
     return(parameterObject != null);
 }