Пример #1
0
        /// <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(REPEAT_BODY);
            }
            return(INCLUDE_BODY);
        }
Пример #2
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)
        {
            if (parameterObject == null)
            {
                return(true);
            }
            string propertyName = ((BaseTag)tag).Property;
            object value;

            if (!string.IsNullOrEmpty(propertyName))
            {
                value = ObjectProbe.GetMemberValue(parameterObject, propertyName, AccessorFactory);
            }
            else
            {
                value = parameterObject;
            }
            return(value == null);
        }
Пример #3
0
        /// <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 (!string.IsNullOrEmpty(propertyName))
            {
                value1 = ObjectProbe.GetMemberValue(parameterObject, propertyName, AccessorFactory);
                type   = value1.GetType();
            }
            else
            {
                value1 = parameterObject;
                if (value1 != null)
                {
                    type = parameterObject.GetType();
                }
                else
                {
                    type = typeof(object);
                }
            }
            if (!string.IsNullOrEmpty(comparePropertyName))
            {
                object value2 = ObjectProbe.GetMemberValue(parameterObject, comparePropertyName, AccessorFactory);
                return(CompareValues(type, value1, value2));
            }
            if (!string.IsNullOrEmpty(compareValue))
            {
                return(CompareValues(type, value1, compareValue));
            }
            throw new DataMapperException("Error comparing in conditional fragment.  Uknown 'compare to' values.");
        }
Пример #4
0
 /// <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(INCLUDE_BODY);
 }
Пример #5
0
 /// <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(INCLUDE_BODY);
 }
Пример #6
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));
 }
Пример #7
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(Compare(ctx, tag, parameterObject) == 0);
 }
Пример #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 = Compare(ctx, tag, parameterObject);

            return((x <= 0) && (x != NOT_COMPARABLE));
        }
Пример #9
0
 /// <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);
 }