Beispiel #1
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));
            }
            else if (!string.IsNullOrEmpty(compareValue))
            {
                return(CompareValues(type, value1, compareValue));
            }
            else
            {
                throw new DataMapperException("Error comparing in conditional fragment.  Unknown 'compare to' values.");
            }
        }
Beispiel #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);
     }
     else
     {
         string propertyName = ((BaseTag)tag).Property;
         object value;
         if (propertyName != null && propertyName.Length > 0)
         {
             value = ObjectProbe.GetMemberValue(parameterObject, propertyName, AccessorFactory);
         }
         else
         {
             value = parameterObject;
         }
         return(value == null);
     }
 }
Beispiel #3
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);
 }
 /// <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);
 }
Beispiel #5
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(BaseTagHandler.INCLUDE_BODY);
 }
Beispiel #6
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(BaseTagHandler.INCLUDE_BODY);
 }
Beispiel #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)
        {
            long x = Compare(ctx, tag, parameterObject);

            return((x <= 0) && (x != ConditionalTagHandler.NOT_COMPARABLE));
        }
Beispiel #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)
 {
     return(!base.IsCondition(ctx, tag, parameterObject));
 }
Beispiel #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);