예제 #1
0
        private SegmentErrorContext ValidateSegment(IList list, InstanceContext instanceContext, int segmentIndex)
        {
            var errorCode = list.Count > MaxCount
                    ? SegmentErrorCode.SegmentExceedsMaximumUse
                    : SegmentErrorCode.SegmentBelowMinimumUse;

            var repIndex = list.Count > MaxCount
                    ? segmentIndex + 1 + MaxCount
                    : segmentIndex + MinCount;

            return(new SegmentErrorContext(instanceContext.GetId(), repIndex, instanceContext.GetStandardType(), errorCode));
        }
예제 #2
0
        private SegmentErrorContext ValidateComposite(InstanceContext instanceContext,
                                                      int segmentIndex, int inSegmentIndex)
        {
            if (instanceContext.Parent == null || !instanceContext.Parent.IsPropertyOfType <SegmentAttribute>())
            {
                throw new Exception(string.Format("Parent of composite {0} must be a segment.",
                                                  instanceContext.Property.Name));
            }

            var result       = new SegmentErrorContext(instanceContext.Parent.GetId(), segmentIndex, instanceContext.Parent.GetStandardType());
            var errorContext = new DataElementErrorContext(instanceContext.GetId(), inSegmentIndex,
                                                           DataElementErrorCode.RequiredDataElementMissing, 0, 0, null);

            result.Add(errorContext);

            return(result);
        }
예제 #3
0
        private SegmentErrorContext ValidateComposite(IList list, InstanceContext instanceContext,
                                                      int segmentIndex, int inSegmentIndex)
        {
            if (instanceContext.Parent == null || !instanceContext.Parent.IsPropertyOfType <SegmentAttribute>())
            {
                throw new Exception(string.Format("Parent of composite {0} must be a segment.",
                                                  instanceContext.Property.Name));
            }

            var errorCode = list.Count > MaxCount
                ? DataElementErrorCode.TooManyRepetitions
                : DataElementErrorCode.TooFewRepetitions;

            var repIndex = list.Count > MaxCount
                ? MaxCount + 1
                : MinCount - list.Count + 1;

            var result       = new SegmentErrorContext(instanceContext.Parent.GetId(), segmentIndex, instanceContext.Parent.GetStandardType());
            var errorContext = new DataElementErrorContext(instanceContext.GetId(), inSegmentIndex, errorCode, 0,
                                                           repIndex, null);

            result.Add(errorContext);
            return(result);
        }
예제 #4
0
 private SegmentErrorContext ValidateSegment(InstanceContext instanceContext, int segmentIndex)
 {
     return(new SegmentErrorContext(instanceContext.GetId(), segmentIndex + 1, instanceContext.GetStandardType(),
                                    SegmentErrorCode.RequiredSegmentMissing));
 }