/// <summary> /// Factory to create an instance of this segment and populate it with the given segment line data /// </summary> /// <param name="bsf">segment line data</param> /// <returns>newly created segment instance</returns> internal override BaseStdSegment CreateBaseStdSegment(BaseFieldValues bsf) { var obj = (BaseStdSegment)this.MemberwiseClone(); obj.Populate(bsf); return(obj); }
/// <summary> /// Default Ctor - all values must be set here as setters are marked private /// </summary> /// <param name="errMsg">Human friendly error message</param> /// <param name="errType">Type of the error encountered (as enum)</param> /// <param name="errLevel">Where the error occurred (as enum)</param> /// <param name="currLoop">The current loop being evaluated at time of error</param> /// <param name="currentSegmentValues">The segment that caused the error</param> public ParserError(string errMsg, X12ErrorTypes errType, X12ErrorLevel errLevel, LoopEntity currLoop, BaseFieldValues currentSegmentValues) { ErrorMessage = errMsg; ErrorType = errType; ErrorLevel = errLevel; CurrentLoop = currLoop; CurrentSegment = currentSegmentValues; }
/// <summary> /// Preps backing fields without needing the segment line to populate it /// Should only be called by derived members inside this project /// </summary> internal BaseStdSegment() { SegmentQualifierValues = new List <SegmentQualifiers>(); SyntaxRules = new List <string>(); FieldValues = new BaseFieldValues(new List <string>() { this.GetType().Name }); FieldUsage = new List <FieldUsageTypeNames>(); }
/// <summary> /// Must pass values to populate the fields of the segment /// </summary> /// <param name="values">field values, in order</param> internal BaseStdSegment(IEnumerable <string> values) : this() { IEnumerable <string> enumerable = values as IList <string> ?? values.ToList(); if (values == null || !enumerable.Any()) { throw new NullReferenceException("field values can't be null or empty"); } FieldValues = new BaseFieldValues(enumerable.ToList()); FieldUsage = new List <FieldUsageTypeNames>(enumerable.Count()); }
/// <summary> /// Determine whether this specific segment type could handle a given segment line /// </summary> /// <param name="segmentFields">extraced segment line value</param> /// <returns>True if this definition matches the given segment line</returns> internal override bool IsQualified(BaseFieldValues segmentFields) { try { bool retVal = string.Equals(this.GetType().Name, segmentFields[0], StringComparison.CurrentCultureIgnoreCase); foreach (var qualVal in SegmentQualifierValues) { retVal = retVal && qualVal.IsQaulified(segmentFields); } return(retVal); } catch (Exception ex) { //todo what are we doing??? } return(false); }
internal List <BaseStdSegment> IsQualified(BaseFieldValues baseFieldValues, QulificationLevel recursiveCheck) { var retVal = new List <BaseStdSegment>(); try { foreach (BaseStdSegment segmentDefinition in SegmentDefinitions) { if (segmentDefinition.IsQualified(baseFieldValues)) { retVal.Add(segmentDefinition); } } if (recursiveCheck != QulificationLevel.TopMost) //was originally written this way because there was a .Recursive option that was removed. Leaving like this because more could be added and this would break, seems less likely to break this way { if (recursiveCheck == QulificationLevel.FirstChild) { recursiveCheck = QulificationLevel.TopMost; } //would have to search lower than our current level //can only do this if we are currently working in a loop //if we are, check its child loopCollections as well if (LoopEntities != null && LoopEntities.Any()) { foreach (LoopCollectionBase childLoopCollection in LoopEntities.Last().ChildLoopCollections) { retVal.AddRange(childLoopCollection.IsQualified(baseFieldValues, recursiveCheck)); } } } } catch (Exception ex) { //todo srsly, how are we handling these here errors } return(retVal); }
internal abstract bool IsQualified(BaseFieldValues segmentFields);
internal abstract void Populate(BaseFieldValues baseVals);
internal abstract BaseStdSegment CreateBaseStdSegment(BaseFieldValues bsf);
internal bool IsQaulified(BaseFieldValues segmentFields) { return(QualifierValues.Contains(segmentFields[FieldId])); }
/// <summary> /// Populate the backing field for the actual values of the segment. /// This is necessary as we will clone a copy of the segment definintion to insert it during pasing /// </summary> /// <param name="baseVals"></param> internal override void Populate(BaseFieldValues baseVals) { FieldValues = baseVals; }
/// <summary> /// Checks to see this loop contains a definition to handle a given BaseFieldValue (segment line) /// </summary> /// <param name="baseFieldValues">segment line from the segment stream class</param> /// <param name="recursiveCheck">how far down the heirarchy to look (only segments in this loop, or include first level of children loops)</param> /// <returns>Any handlers that qualify for the given segment line. Should only be one, but needs to be checked and Count!=1 instances should be hanlded accordingly</returns> internal List <BaseStdSegment> IsQualified(BaseFieldValues baseFieldValues, QulificationLevel recursiveCheck) { return(ParentLoopCollection.IsQualified(baseFieldValues, recursiveCheck)); }