Exemplo n.º 1
0
        public AttributeFilter(string name, AttributeType attributeType, AttributeDataType dataType,
                               List <string> values, OperatorForValues operatorForValues, OperatorForLinkAtribute operatorForLinkAtribute,
                               ParenthesisThisAtribute parenthesisThisAtribute)
            : base(name, attributeType, dataType)
        {
            if (values == null || values.Count < 0)
            {
                throw new Exception("Un atributo de tipo filtro debe tener valores");
            }

            // si este atributo tiene valores de fecha o numero, deben cumplirse ciertas condiciones
            if (operatorForValues == OperatorForValues.Between && values.Count != 2)
            {
                throw new Exception("Un atributo de tipo filtro con el operador" + operatorForValues +
                                    " debe tener 2 valores");
            }

            if (operatorForValues == OperatorForValues.Bigger || operatorForValues == OperatorForValues.BiggerEqual ||
                operatorForValues == OperatorForValues.Minor || operatorForValues == OperatorForValues.MinorEqual)
            {
                if (values.Count != 1)
                {
                    throw new Exception("Un atributo de tipo filtro con el operador" + operatorForValues +
                                        " debe tener 1 valor");
                }
            }

            Values                  = values;
            OperatorForValues       = operatorForValues;
            OperatorForLinkAtribute = operatorForLinkAtribute;
            ParenthesisThisAtribute = parenthesisThisAtribute;
        }
Exemplo n.º 2
0
        public static string ParenthesisThisAtributeCustomToString(this ParenthesisThisAtribute p)
        {
            switch (p)
            {
            case ParenthesisThisAtribute.OpenParenthesis:
                return("(");

            case ParenthesisThisAtribute.CloseParenthesis:
                return(")");

            default: return(string.Empty);
            }
        }