Exemple #1
0
        private PurchasePolicy CreateCondition(PolicyType type, string subject, ConditionType cond, string value)
        {
            PurchasePolicy policy = null;

            switch (cond)
            {
            case ConditionType.AddressEqual:
                policy = new AddressEquals(type, subject, value, SessionPolicies.Count);
                break;

            case ConditionType.PriceGreater:
                policy = new PriceGreaterThan(type, subject, value, SessionPolicies.Count);
                break;

            case ConditionType.PriceLesser:
                policy = new PriceLessThan(type, subject, value, SessionPolicies.Count);
                break;

            case ConditionType.QuantityGreater:
                policy = new QuantityGreaterThan(type, subject, value, SessionPolicies.Count);
                break;

            case ConditionType.QuantityLesser:
                policy = new QuantityLessThan(type, subject, value, SessionPolicies.Count);
                break;

            case ConditionType.UsernameEqual:
                policy = new UsernameEquals(type, subject, value, SessionPolicies.Count);
                break;
            }
            SessionPolicies.Add(policy);
            return(policy);
        }
Exemple #2
0
        private bool Equals(QuantityLessThan obj)
        {
            bool answer = true;

            if (Value == null)
            {
                answer = answer && (obj.Value == null);
            }
            if (Subject == null)
            {
                answer = answer && (obj.Subject == null);
            }
            if (Value != null)
            {
                answer = answer && (Value.Equals(obj.Value));
            }
            if (Subject != null)
            {
                answer = answer && (Subject.Equals(obj.Subject));
            }
            answer = answer && obj.ID.Equals(ID) && obj.Type.Equals(Type);
            return(answer);
        }