예제 #1
0
        internal static bool TryParseAttributeValue(string attributeValue, out FtEndOfLineType enumerator)
        {
            enumerator = FtEndOfLineType.Auto; // 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);
        }
예제 #2
0
 internal static string ToAttributeValue(FtEndOfLineType enumerator)
 {
     return(formatRecArray[(int)enumerator].AttributeValue);
 }
예제 #3
0
        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;
            }
        }