using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Modeling.Validation;

namespace MDC.ProductionSystem
{
    [ValidationState(ValidationState.Enabled)]
    public partial class Machine
    {
        [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
        private void ValidateMachineOutputs(ValidationContext context)
        {
            if (!(this is QualityControl))
                if (MA_CB_ConveyorBelts.Count > 1)
                    context.LogError(CustomCode.Validation.ValidationResources.MachineOutgoingLinksError, "ProductionSystem 01", this);
        }
        
        [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
        private void ValidateGarageOutputs(ValidationContext context)
        {
            if (this is Garage)
                if (MA_CB_ConveyorBelts.Count > 0)
                    context.LogError(CustomCode.Validation.ValidationResources.GarageOutgoingLinkError, "ProductionSystem 01", this);
        }

        [ValidationMethod(ValidationCategories.Open | ValidationCategories.Save | ValidationCategories.Menu)]
        private void ValidateQualityControlOutputs(ValidationContext context)
        {
            if (this is QualityControl)
                if (!(MA_CB_ConveyorBelts.Count == 2))
                    context.LogError(CustomCode.Validation.ValidationResources.QualityControlOutgoingLinksError, "ProductionSystem 01", this);
        }
    }
}