コード例 #1
0
 public SchemaNodeComplexField(SchemaNode schema, string name, string title, string description, bool isNullable)
 {
     Schema      = schema;
     Name        = name;
     Title       = title;
     Description = description;
     IsNullable  = isNullable;
 }
コード例 #2
0
        public static SchemaNode GetSchemaNodeForBinaryOperation(BinaryOperation operation, SchemaNode leftOperandSchema, SchemaNode rightOperantSchema)
        {
            switch (operation.Operation)
            {
            case QueryOperationNodeType.Add:
            case QueryOperationNodeType.Subtract:
                switch (leftOperandSchema.Kind)
                {
                case SchemaNodeKind.Integer:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                        return(new SchemaNodeInteger());

                    case SchemaNodeKind.Decimal:
                        return(new SchemaNodeDecimal(null, null, ((SchemaNodeDecimal)rightOperantSchema).ShowAsPercent));

                    case SchemaNodeKind.Currency:
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)rightOperantSchema).Lcid));

                    default:
                        throw new InvalidOperationException();
                    }

                case SchemaNodeKind.Decimal:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                        return(new SchemaNodeDecimal(null, null, ((SchemaNodeDecimal)leftOperandSchema).ShowAsPercent));

                    case SchemaNodeKind.Decimal:
                        return(new SchemaNodeDecimal(null, null, NullableOr(((SchemaNodeDecimal)leftOperandSchema).ShowAsPercent, ((SchemaNodeDecimal)rightOperantSchema).ShowAsPercent, false)));

                    case SchemaNodeKind.Currency:
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)rightOperantSchema).Lcid));

                    default:
                        throw new InvalidOperationException();
                    }

                case SchemaNodeKind.Currency:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                    case SchemaNodeKind.Decimal:
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)leftOperandSchema).Lcid));

                    case SchemaNodeKind.Currency:
                        if (((SchemaNodeCurrency)leftOperandSchema).Lcid.HasValue && ((SchemaNodeCurrency)rightOperantSchema).Lcid.HasValue &&
                            ((SchemaNodeCurrency)leftOperandSchema).Lcid.Value != ((SchemaNodeCurrency)rightOperantSchema).Lcid.Value)
                        {
                            throw new InvalidOperationException();
                        }
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)rightOperantSchema).Lcid));

                    default:
                        throw new InvalidOperationException();
                    }

                default:
                    throw new InvalidOperationException();
                }

            case QueryOperationNodeType.Divide:
                switch (leftOperandSchema.Kind)
                {
                case SchemaNodeKind.Integer:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                        return(new SchemaNodeInteger());

                    case SchemaNodeKind.Decimal:
                    case SchemaNodeKind.Currency:
                        return(new SchemaNodeDecimal());

                    default:
                        throw new InvalidOperationException();
                    }

                case SchemaNodeKind.Decimal:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                    case SchemaNodeKind.Decimal:
                    case SchemaNodeKind.Currency:
                        return(new SchemaNodeDecimal(null, null, ((SchemaNodeDecimal)leftOperandSchema).ShowAsPercent));

                    default:
                        throw new InvalidOperationException();
                    }

                case SchemaNodeKind.Currency:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                    case SchemaNodeKind.Decimal:
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)leftOperandSchema).Lcid));

                    case SchemaNodeKind.Currency:
                        return(new SchemaNodeDecimal());

                    default:
                        throw new InvalidOperationException();
                    }

                default:
                    throw new InvalidOperationException();
                }

            case QueryOperationNodeType.Multiply:
                switch (leftOperandSchema.Kind)
                {
                case SchemaNodeKind.Integer:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                        return(new SchemaNodeInteger());

                    case SchemaNodeKind.Decimal:
                        return(new SchemaNodeDecimal(null, null, ((SchemaNodeDecimal)rightOperantSchema).ShowAsPercent));

                    case SchemaNodeKind.Currency:
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)rightOperantSchema).Lcid));

                    default:
                        throw new InvalidOperationException();
                    }

                case SchemaNodeKind.Decimal:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                        return(new SchemaNodeDecimal(null, null, ((SchemaNodeDecimal)leftOperandSchema).ShowAsPercent));

                    case SchemaNodeKind.Decimal:
                        return(new SchemaNodeDecimal(null, null, NullableOr(((SchemaNodeDecimal)leftOperandSchema).ShowAsPercent, ((SchemaNodeDecimal)rightOperantSchema).ShowAsPercent, false)));

                    case SchemaNodeKind.Currency:
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)rightOperantSchema).Lcid));

                    default:
                        throw new InvalidOperationException();
                    }

                case SchemaNodeKind.Currency:
                    switch (rightOperantSchema.Kind)
                    {
                    case SchemaNodeKind.Integer:
                    case SchemaNodeKind.Decimal:
                        return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)leftOperandSchema).Lcid));

                    default:
                        throw new InvalidOperationException();
                    }

                default:
                    throw new InvalidOperationException();
                }

            case QueryOperationNodeType.Equal:
            case QueryOperationNodeType.NotEqual:
                return(new SchemaNodeBoolean());

            case QueryOperationNodeType.Greater:
            case QueryOperationNodeType.GreaterOrEqual:
            case QueryOperationNodeType.Less:
            case QueryOperationNodeType.LessOrEqual:
                if ((leftOperandSchema.Kind == SchemaNodeKind.Integer || leftOperandSchema.Kind == SchemaNodeKind.Decimal || leftOperandSchema.Kind == SchemaNodeKind.Currency) &&
                    (rightOperantSchema.Kind == SchemaNodeKind.Integer || rightOperantSchema.Kind == SchemaNodeKind.Decimal || rightOperantSchema.Kind == SchemaNodeKind.Currency))
                {
                    return(new SchemaNodeBoolean());
                }
                else
                {
                    throw new InvalidOperationException();
                }

            case QueryOperationNodeType.And:
            case QueryOperationNodeType.Or:
                if (leftOperandSchema.Kind == SchemaNodeKind.Boolean && rightOperantSchema.Kind == SchemaNodeKind.Boolean)
                {
                    return(new SchemaNodeBoolean(((SchemaNodeBoolean)leftOperandSchema).Format == SchemaNodeBooleanFormat.YesNo && ((SchemaNodeBoolean)rightOperantSchema).Format == SchemaNodeBooleanFormat.YesNo ? SchemaNodeBooleanFormat.YesNo : SchemaNodeBooleanFormat.Checkbox));
                }
                else
                {
                    throw new InvalidOperationException();
                }

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #3
0
        public static SchemaNode GetSchemaNodeForUnaryOperation(UnaryOperation operation, SchemaNode schema)
        {
            switch (operation.Operation)
            {
            case QueryOperationNodeType.Not:
                if (schema.Kind != SchemaNodeKind.Boolean)
                {
                    throw new InvalidOperationException();
                }
                return(schema);

            case QueryOperationNodeType.Negate:
                switch (schema.Kind)
                {
                case SchemaNodeKind.Integer:
                    return(new SchemaNodeInteger());

                case SchemaNodeKind.Decimal:
                    return(new SchemaNodeDecimal(null, null, ((SchemaNodeDecimal)schema).ShowAsPercent));

                case SchemaNodeKind.Currency:
                    return(new SchemaNodeCurrency(null, null, ((SchemaNodeCurrency)schema).Lcid));

                default:
                    throw new InvalidOperationException();
                }

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #4
0
 public SchemaNodeCollection(SchemaNode elementSchema) : base()
 {
     ElementSchema = elementSchema;
 }