PurplePen.ControlPoint.Validate C# (CSharp) Method

Validate() public method

public Validate ( Id id, EventDB validateInfo ) : void
id Id
validateInfo EventDB
return void
        public void Validate(Id<ControlPoint> id, EventDB.ValidateInfo validateInfo)
        {
            if (kind == ControlPointKind.Normal && code == null)
                throw new ApplicationException(string.Format("Control point '{0}' is missing a code", id));
            if (kind != ControlPointKind.Normal && code != null)
                throw new ApplicationException(string.Format("Control point '{0}' should not have a code", id));

            if ((kind == ControlPointKind.Normal || kind == ControlPointKind.Start || kind == ControlPointKind.MapExchange) && symbolIds.Length != 6)
                throw new ApplicationException(string.Format("Control point '{0}' should have 6 symbols", id));
            if ((kind == ControlPointKind.Finish || kind == ControlPointKind.CrossingPoint) && symbolIds.Length != 1)
                throw new ApplicationException(string.Format("Control point '{0}' should have 1 symbol", id));

            if ((kind != ControlPointKind.Normal && kind != ControlPointKind.Start) && columnFText != null)
                throw new ApplicationException(string.Format("Control point '{0}' should not have column F text", id));

            if (code != null) {
                if (validateInfo.usedCodes.ContainsKey(code))
                    throw new ApplicationException(string.Format("Code '{0}' used by two different controls", code));
                validateInfo.usedCodes[code] = true;
            }
        }