/// <summary>
        /// Conditions the by or combining condition with condition.
        /// </summary>
        /// <param name="condition1">
        /// The condition1.
        /// </param>
        /// <param name="condition2">
        /// The condition2.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaDateTimeCondition"/>.
        /// </returns>
        public static UPInfoAreaDateTimeCondition ConditionByOrCombiningConditionWithCondition(
            UPInfoAreaDateTimeCondition condition1,
            UPInfoAreaDateTimeCondition condition2)
        {
            if (condition1 == null)
            {
                return(condition2 != null?OrCombined(condition2) : null);
            }

            if (condition2 == null)
            {
                return(OrCombined(condition1));
            }

            if (condition1 is UPInfoAreaORDateTimeCondition)
            {
                ((UPInfoAreaORDateTimeCondition)condition1).AppendCondition(condition2);
                return(condition1);
            }

            if (condition2 is UPInfoAreaORDateTimeCondition)
            {
                ((UPInfoAreaORDateTimeCondition)condition2).AppendCondition(condition1);
                return(condition2);
            }

            var orCondition = OrCombined(condition1);

            orCondition.AppendCondition(condition2);
            return(orCondition);
        }
        /// <summary>
        /// The or combined.
        /// </summary>
        /// <param name="condition">
        /// The condition.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaORDateTimeCondition"/>.
        /// </returns>
        public static UPInfoAreaORDateTimeCondition OrCombined(UPInfoAreaDateTimeCondition condition)
        {
            if (condition is UPInfoAreaORDateTimeCondition)
            {
                return((UPInfoAreaORDateTimeCondition)condition);
            }

            return(new UPInfoAreaORDateTimeCondition(condition.InfoAreaMetaInfo, condition));
        }
 /// <summary>
 /// Appends the condition.
 /// </summary>
 /// <param name="condition">
 /// The condition.
 /// </param>
 public void AppendCondition(UPInfoAreaDateTimeCondition condition)
 {
     if (condition is UPInfoAreaSingleDateTimeCondition)
     {
         this.AppendSingleCondition((UPInfoAreaSingleDateTimeCondition)condition);
     }
     else if (condition is UPInfoAreaANDDateTimeCondition)
     {
         this.AppendANDDateCondition((UPInfoAreaANDDateTimeCondition)condition);
     }
 }
 /// <summary>
 /// Appends the condition.
 /// </summary>
 /// <param name="condition">
 /// The condition.
 /// </param>
 public void AppendCondition(UPInfoAreaDateTimeCondition condition)
 {
     if (condition is UPInfoAreaORDateTimeCondition)
     {
         foreach (var c in ((UPInfoAreaORDateTimeCondition)condition).Conditions)
         {
             this.Conditions.Add(c);
         }
     }
     else
     {
         this.Conditions.Add(condition);
     }
 }
        /// <summary>
        /// Conditions the by and combining condition with condition.
        /// </summary>
        /// <param name="condition1">
        /// The condition1.
        /// </param>
        /// <param name="condition2">
        /// The condition2.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaDateTimeCondition"/>.
        /// </returns>
        public static UPInfoAreaDateTimeCondition ConditionByANDCombiningConditionWithCondition(
            UPInfoAreaDateTimeCondition condition1,
            UPInfoAreaDateTimeCondition condition2)
        {
            if (condition1 == null)
            {
                return(condition2);
            }

            if (condition2 == null)
            {
                return(condition1);
            }

            if (condition1 is UPInfoAreaORDateTimeCondition)
            {
                ((UPInfoAreaORDateTimeCondition)condition1).AppendCondition(condition2);
                return(condition1);
            }

            if (condition2 is UPInfoAreaORDateTimeCondition)
            {
                ((UPInfoAreaORDateTimeCondition)condition2).AppendCondition(condition1);
                return(condition2);
            }

            if (condition1 is UPInfoAreaANDDateTimeCondition)
            {
                ((UPInfoAreaANDDateTimeCondition)condition1).AppendCondition(condition2);
                return(condition1);
            }

            if (condition2 is UPInfoAreaANDDateTimeCondition)
            {
                ((UPInfoAreaANDDateTimeCondition)condition2).AppendCondition(condition1);
                return(condition2);
            }

            return
                (((UPInfoAreaSingleDateTimeCondition)condition1).AppendSingleCondition(
                     (UPInfoAreaSingleDateTimeCondition)condition2)
                    ? condition1
                    : new UPInfoAreaANDDateTimeCondition(
                     condition1.InfoAreaMetaInfo,
                     (UPInfoAreaSingleDateTimeCondition)condition1,
                     (UPInfoAreaSingleDateTimeCondition)condition2));
        }
示例#6
0
        /// <summary>
        /// Dates the time condition for information area parent.
        /// </summary>
        /// <param name="infoArea">
        /// The information area.
        /// </param>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <returns>
        /// The <see cref="UPInfoAreaDateTimeCondition"/>.
        /// </returns>
        public override UPInfoAreaDateTimeCondition DateTimeConditionForInfoAreaParent(
            UPContainerInfoAreaMetaInfo infoArea,
            UPInfoAreaConditionTree parent)
        {
            if (this.conditions == null)
            {
                return(null);
            }

            UPInfoAreaDateTimeCondition combinedCondition = null;

            if (this.relation == "AND")
            {
                foreach (var cond in this.conditions)
                {
                    var dateTimeCond = cond.DateTimeConditionForInfoAreaParent(infoArea, this);
                    if (dateTimeCond != null)
                    {
                        combinedCondition =
                            UPInfoAreaDateTimeCondition.ConditionByANDCombiningConditionWithCondition(
                                dateTimeCond,
                                combinedCondition);
                    }
                }
            }
            else
            {
                foreach (var cond in this.conditions)
                {
                    var dateTimeCond = cond.DateTimeConditionForInfoAreaParent(infoArea, this);
                    if (dateTimeCond != null || combinedCondition != null)
                    {
                        combinedCondition =
                            UPInfoAreaDateTimeCondition.ConditionByOrCombiningConditionWithCondition(
                                dateTimeCond,
                                combinedCondition);
                    }
                }
            }

            return(combinedCondition);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPInfoAreaORDateTimeCondition"/> class.
 /// </summary>
 /// <param name="infoAreaMetaInfo">
 /// The information area meta information.
 /// </param>
 /// <param name="condition">
 /// The condition.
 /// </param>
 public UPInfoAreaORDateTimeCondition(UPContainerInfoAreaMetaInfo infoAreaMetaInfo, UPInfoAreaDateTimeCondition condition)
     : base(infoAreaMetaInfo)
 {
     this.Conditions = new List <UPInfoAreaDateTimeCondition> {
         condition
     };
 }