internal static bool TryParseAttributeValue(string attributeValue, out FtQuotedType enumerator) { enumerator = FtQuotedType.Always; // avoid compiler error bool result = false; foreach (FormatRec rec in formatRecArray) { if (String.Equals(rec.AttributeValue, attributeValue, StringComparison.OrdinalIgnoreCase)) { enumerator = rec.Enumerator; result = true; break; } } return(result); }
internal void EnterField(FtField aField) { field = aField; // cache field values fieldSubstitutionsEnabled = core.SubstitutionsEnabled; fieldSubstitutionChar = core.SubstitutionChar; fieldDelimiterChar = core.DelimiterChar; fieldQuoteChar = core.QuoteChar; if (headings) { fieldQuotedType = field.HeadingQuotedType; } else { fieldQuotedType = field.ValueQuotedType; } switch (fieldQuotedType) { case FtQuotedType.Never: quotedState = QuotedState.NeverOpen; break; case FtQuotedType.Optional: quotedState = QuotedState.CanOpen; break; case FtQuotedType.Always: quotedState = QuotedState.MustOpen; break; default: throw FtInternalException.Create(InternalError.DelimitedFieldParser_EnterField_UnsupportedQuotedType, fieldQuotedType.ToString()); } textBuilder.Clear(); position = charReader.Position; rawOffset = -1; rawLength = 0; }
internal DelimitedFieldParser(SerializationCore myCore, CharReader myCharReader, bool forHeadings) { headings = forHeadings; charReader = myCharReader; core = myCore; textBuilder = new StringBuilder(20); field = null; fieldQuotedType = FtQuotedType.Optional; fieldSubstitutionsEnabled = false; fieldSubstitutionChar = '\0'; fieldDelimiterChar = '\0'; fieldQuoteChar = '\0'; quotedState = QuotedState.CanOpen; substitutionActive = false; position = -1; rawOffset = -1; rawLength = 0; }
internal static string ToAttributeValue(FtQuotedType enumerator) { return(formatRecArray[(int)enumerator].AttributeValue); }
internal protected virtual void LoadMeta(FtMetaField metaField, CultureInfo myCulture, int myMainHeadingIndex) { dataType = metaField.DataType; id = metaField.Id; metaName = metaField.Name; metaHeadings = metaField.Headings; mainHeadingIndex = myMainHeadingIndex; culture = myCulture; fixedWidth = metaField.FixedWidth; width = metaField.Width; constant = metaField.Constant; _null = metaField.Null; valueQuotedType = metaField.ValueQuotedType; valueAlwaysWriteOptionalQuote = metaField.ValueAlwaysWriteOptionalQuote; valueWritePrefixSpace = metaField.ValueWritePrefixSpace; valuePadAlignment = metaField.ValuePadAlignment; valuePadCharType = metaField.ValuePadCharType; valuePadChar = metaField.ValuePadChar; valueTruncateType = metaField.ValueTruncateType; valueTruncateChar = metaField.ValueTruncateChar; valueEndOfValueChar = metaField.ValueEndOfValueChar; valueNullChar = metaField.ValueNullChar; headingConstraint = metaField.HeadingConstraint; headingQuotedType = metaField.HeadingQuotedType; headingAlwaysWriteOptionalQuote = metaField.HeadingAlwaysWriteOptionalQuote; headingWritePrefixSpace = metaField.HeadingWritePrefixSpace; headingPadAlignment = metaField.HeadingPadAlignment; headingPadCharType = metaField.HeadingPadCharType; headingPadChar = metaField.HeadingPadChar; headingTruncateType = metaField.HeadingTruncateType; headingTruncateChar = metaField.HeadingTruncateChar; headingEndOfValueChar = metaField.HeadingEndOfValueChar; formatter.Culture = culture; if ( ((headingConstraint == FtHeadingConstraint.NameIsMain) || (headingConstraint == FtHeadingConstraint.NameConstant)) && (mainHeadingIndex >= 0) && (mainHeadingIndex < MetaHeadingCount) ) { metaHeadings[mainHeadingIndex] = metaName; } switch (headingPadAlignment) { case FtPadAlignment.Left: headingLeftPad = true; break; case FtPadAlignment.Right: headingLeftPad = false; break; case FtPadAlignment.Auto: headingLeftPad = autoLeftPad; break; default: throw FtInternalException.Create(InternalError.FtFieldFieldDefinition_LoadMeta_UnsupportedHeadingPadAlignment, headingPadAlignment.ToString()); } switch (valuePadAlignment) { case FtPadAlignment.Left: valueLeftPad = true; break; case FtPadAlignment.Right: valueLeftPad = false; break; case FtPadAlignment.Auto: valueLeftPad = autoLeftPad; break; default: throw FtInternalException.Create(InternalError.FtFieldFieldDefinition_LoadMeta_UnsupportedValuePadAlignment, headingPadAlignment.ToString()); } if (fixedWidth) { fixedWidthNullValueText = new string(ValueNullChar, Width); } }
internal void InternalLoadMeta(FtMeta meta) { sequenceList.Clear(); substitutionList.Clear(); fieldList.Clear(); fieldDefinitionList.Clear(); string errorMessage; if (!meta.Validate(out errorMessage)) { throw new FtSerializationException(FtSerializationError.InvalidMeta, errorMessage); } else { culture = meta.Culture; endOfLineType = meta.EndOfLineType; endOfLineChar = meta.EndOfLineChar; endOfLineAutoWriteType = meta.EndOfLineAutoWriteType; lastLineEndedType = meta.LastLineEndedType; quoteChar = meta.QuoteChar; delimiterChar = meta.DelimiterChar; lineCommentChar = meta.LineCommentChar; allowEndOfLineCharInQuotes = meta.AllowEndOfLineCharInQuotes; ignoreBlankLines = meta.IgnoreBlankLines; ignoreExtraChars = meta.IgnoreExtraChars; allowIncompleteRecords = meta.AllowIncompleteRecords; stuffedEmbeddedQuotes = meta.StuffedEmbeddedQuotes; substitutionsEnabled = meta.SubstitutionsEnabled; substitutionChar = meta.SubstitutionChar; headingLineCount = meta.HeadingLineCount; mainHeadingLineIndex = meta.MainHeadingLineIndex; headingConstraint = meta.HeadingConstraint; headingQuotedType = meta.HeadingQuotedType; headingAlwaysWriteOptionalQuote = meta.HeadingAlwaysWriteOptionalQuote; headingWritePrefixSpace = meta.HeadingWritePrefixSpace; headingPadAlignment = meta.HeadingPadAlignment; headingPadCharType = meta.HeadingPadCharType; headingPadChar = meta.HeadingPadChar; headingTruncateType = meta.HeadingTruncateType; headingTruncateChar = meta.HeadingTruncateChar; headingEndOfValueChar = meta.HeadingEndOfValueChar; fieldDefinitionList.Capacity = meta.FieldList.Count; fieldList.Capacity = meta.FieldList.Count; for (int i = 0; i < meta.FieldList.Count; i++) { FtFieldDefinition fieldDefinition = fieldDefinitionList.New(meta.FieldList[i].DataType); fieldDefinition.LoadMeta(meta.FieldList[i], culture, mainHeadingLineIndex); } for (int i = 0; i < meta.SubstitutionList.Count; i++) { FtSubstitution substitution = substitutionList.New(); substitution.LoadMeta(meta.SubstitutionList[i], endOfLineAutoWriteType); } if (meta.SequenceList.Count == 0) { // create a root sequence with all field definitions rootSequence = sequenceList.New(fieldDefinitionList); } else { rootSequence = null; for (int i = 0; i < meta.SequenceList.Count; i++) { FtSequence sequence = sequenceList.New(); sequence.LoadMeta(meta.SequenceList[i], meta.FieldList, fieldDefinitionList); if (sequence.Root) { rootSequence = sequence; } } if (rootSequence == null && sequenceList.Count > 0) { rootSequence = sequenceList[0]; rootSequence.SetRoot(true); } // must load redirects after ALL sequences are loaded for (int i = 0; i < sequenceList.Count; i++) { sequenceList[i].LoadMetaSequenceRedirects(meta.SequenceList[i], meta.SequenceList, sequenceList); } } rootFieldCount = rootSequence.ItemList.Count; metaLoaded = true; } }