示例#1
0
        public void Main()
        {
            // Name of file containing Meta
            const string MetaFileName = "ExampleSequenceMeta.ftm";
            // Name of file to be written
            const string CsvFileName = "ExampleSequence.csv";

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            finished = false;

            // Create Writer
            using (FtWriter writer = new FtWriter(meta, CsvFileName))
            {
                writer.FieldValueWriteReady += HandleFieldValueWriteReady;
                writer.RecordFinished       += HandleRecordFinished;

                while (!finished)
                {
                    // loop until finished flag is set
                    writer.Write();
                }
            }
        }
示例#2
0
        // Example of using FtWriter to write a declared Fielded Text (CSV) file.
        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "BasicExampleMeta.ftm";
            // Name of file to be written
            const string FtxFileName = "BasicExample.ftx";

            // Define FieldNames
            const string PetNameFieldName      = "PetName";
            const string AgeFieldName          = "Age";
            const string ColorFieldName        = "Color";
            const string DateReceivedFieldName = "DateReceived";
            const string PriceFieldName        = "Price";
            const string NeedsWalkingFieldName = "NeedsWalking";
            const string TypeFieldName         = "Type";

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            meta.LineCommentChar  = '!'; // Is not set as with other examples.  Change to !
            meta.HeadingLineCount = 0;   // Is set to 2 as with other examples.  Change to 0 as we do not want any heading lines in this example

            // Create FtWriterSettings to flag we want Declared file written
            FtWriterSettings settings = new FtWriterSettings();

            settings.Declared          = true;
            settings.MetaReferenceType = FtMetaReferenceType.Embedded;

            // Create Writer
            using (FtWriter writer = new FtWriter(meta, FtxFileName, settings))
            {
                // Write 1st Record
                writer[PetNameFieldName]      = "Rover";
                writer[AgeFieldName]          = 4.5;
                writer[ColorFieldName]        = "Brown";
                writer[DateReceivedFieldName] = new DateTime(2004, 2, 12);
                writer[PriceFieldName]        = 80M;
                writer[NeedsWalkingFieldName] = true;
                writer[TypeFieldName]         = "Dog";

                writer.Write();

                // Write 2nd Record
                writer[PetNameFieldName]      = "Charlie";
                writer[AgeFieldName]          = null;
                writer[ColorFieldName]        = "Gold";
                writer[DateReceivedFieldName] = new DateTime(2007, 4, 5);
                writer[PriceFieldName]        = 12.3M;
                writer[NeedsWalkingFieldName] = false;
                writer[TypeFieldName]         = "Fish";

                writer.Write();
            }
        }
示例#3
0
        // Simple Example of counting records in a CSV file.
        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "BasicExampleMeta.ftm";
            // Name of file to be read
            const string CsvFileName = "BasicExample.csv";

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            // Create Reader
            using (FtReader reader = new FtReader(meta, CsvFileName))
            {
                reader.SeekEnd(); // Use SeekEnd() instead of ReadToEnd().  SeekEnd() is quicker

                Console.WriteLine(string.Format("Count: {0}", reader.RecordCount));
            }
        }
示例#4
0
        // This example shows how to use ordinals when reading fields.
        // An ordinal is actual the index of a field in a record.
        // If you access a field by its field name, then the name has
        // to be converted to the corresponding ordinal.
        // An field's ordinal will remain the same until the table in
        // the file has ended.  So typically, ordinals are calculated
        // from field names after the first record is read in a table.
        // These ordinal values can then be used until all the records
        // in the table have been read.
        //
        // Use ordinals when a file is large and you want to read it
        // as quickly as possible.

        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "ExampleSequenceMeta.ftm";
            // Name of file to be read
            const string CsvFileName = "ExampleSequence.csv";

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            // Create Reader
            using (FtReader reader = new FtReader(meta, CsvFileName))
            {
                int[]    recOrdinals = null;
                object[] recObjects  = null;
                do
                {
                    // Loop for each table in file fl

                    while (reader.Read())
                    {
                        // Read each record in table and write field values to console

                        if (recOrdinals == null)
                        {
                            // Ordinals only need to be calculated for first row of table.
                            // Will be the same for rest of records in table
                            recOrdinals = CalculateRecordOrdinals(reader);
                            recObjects  = new object[recOrdinals.Length];
                        }

                        for (int i = 0; i < recOrdinals.Length; i++)
                        {
                            int ordinal = recOrdinals[i];
                            recObjects[i] = reader[ordinal]; // specify field by ordinal
                        }

                        Console.WriteLine(string.Format("{0},{1}: {2}", reader.RecordCount, reader.TableCount, string.Join(",", recObjects)));
                    }

                    recOrdinals = null; // Ordinals are no longer valid after table is finished
                } while (reader.NextResult());
            }
        }
示例#5
0
        object[] recObjects = new object[7]; // Buffer for values in a record

        public void Main()
        {
            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            // Create Reader
            using (FtReader reader = new FtReader(meta, CsvFileName, false)) // do not read header immediately otherwise heading events will not fire
            {
                reader.FieldHeadingReadReady += HandleFieldHeadingReadReady;
                reader.FieldValueReadReady   += HandleFieldValueReadReady;
                reader.HeadingLineStarted    += HandleHeadingLineStarted;
                reader.HeadingLineFinished   += HandleHeadingLineFinished;
                reader.RecordStarted         += HandleRecordStarted;
                reader.RecordFinished        += HandleRecordFinished;

                // Read all header and then all records.  Headings and values will be obtained via the events
                reader.ReadToEnd();
            }
        }
示例#6
0
        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "BasicExampleMeta.ftm";
            // Name of file to be read
            const string CsvFileName = "BasicExample.csv";

            // Define FieldNames
            const string PetNameFieldName      = "PetName";
            const string AgeFieldName          = "Age";
            const string ColorFieldName        = "Color";
            const string DateReceivedFieldName = "DateReceived";
            const string PriceFieldName        = "Price";
            const string NeedsWalkingFieldName = "NeedsWalking";
            const string TypeFieldName         = "Type";

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            // Create Reader
            using (FtReader reader = new FtReader(meta, CsvFileName))
            {
                // Read each record in text file and write field values to console
                object[] recObjects = new object[7];
                int      recNumber  = 0;
                while (reader.Read())
                {
                    recNumber++;

                    recObjects[0] = reader[PetNameFieldName];
                    recObjects[1] = reader[AgeFieldName];
                    recObjects[2] = reader[ColorFieldName];
                    recObjects[3] = reader[DateReceivedFieldName];
                    recObjects[4] = reader[PriceFieldName];
                    recObjects[5] = reader[NeedsWalkingFieldName];
                    recObjects[6] = reader[TypeFieldName];

                    Console.WriteLine(recNumber.ToString() + ": " + string.Join(",", recObjects));
                }
            }
        }
示例#7
0
        public void Main()
        {
            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            finished = false;

            // Create Writer
            using (FtWriter writer = new FtWriter(meta, CsvFileName))
            {
                writer.FieldHeadingWriteReady += HandleFieldHeadingWriteReady;
                writer.FieldValueWriteReady   += HandleFieldValueWriteReady;
                writer.RecordFinished         += HandleRecordFinished;

                while (!finished)
                {
                    // loop until finished flag is set
                    writer.Write();
                }
            }
        }
示例#8
0
        // Simple Example of using FtWriter to write a CSV file with comments.
        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "BasicExampleMeta.ftm";
            // Name of file to be written
            const string CsvFileName = "BasicExample.csv";

            // Define FieldNames
            const string PetNameFieldName      = "PetName";
            const string AgeFieldName          = "Age";
            const string ColorFieldName        = "Color";
            const string DateReceivedFieldName = "DateReceived";
            const string PriceFieldName        = "Price";
            const string NeedsWalkingFieldName = "NeedsWalking";
            const string TypeFieldName         = "Type";

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            meta.LineCommentChar = '!'; // Is not set as with other examples.  Change to !

            // Create Writer
            using (FtWriter writer = new FtWriter(meta, CsvFileName))
            {
                writer.WriteComment("My Pets");
                writer.WriteComment("(Example writing CSV file with comments)");

                writer.WriteComment("");
                writer.WriteComment("Header");
                writer.WriteComment("");

                // only set up headings in first field
                writer.FieldList[0].Headings[0] = "First Field Heading 1";
                writer.FieldList[0].Headings[1] = "First Field Heading 2";
                writer.WriteHeader();

                writer.WriteComment("");
                writer.WriteComment("Records");
                writer.WriteComment("");

                // Write 1st Record
                writer.WriteComment("First Record");
                writer[PetNameFieldName]      = "Rover";
                writer[AgeFieldName]          = 4.5;
                writer[ColorFieldName]        = "Brown";
                writer[DateReceivedFieldName] = new DateTime(2004, 2, 12);
                writer[PriceFieldName]        = 80M;
                writer[NeedsWalkingFieldName] = true;
                writer[TypeFieldName]         = "Dog";

                writer.Write();

                // Write 2nd Record
                writer.WriteComment("Second Record");
                writer[PetNameFieldName]      = "Charlie";
                writer[AgeFieldName]          = null;
                writer[ColorFieldName]        = "Gold";
                writer[DateReceivedFieldName] = new DateTime(2007, 4, 5);
                writer[PriceFieldName]        = 12.3M;
                writer[NeedsWalkingFieldName] = false;
                writer[TypeFieldName]         = "Fish";

                writer.Write();

                writer.WriteComment("No more records");
            }
        }
示例#9
0
        public void MetaSequence()
        {
            FtMeta meta = new FtMeta();

            FtMetaField rootField1 = meta.FieldList.New(FtStandardDataType.String);

            rootField1.Id = RootField1Id;
            FtMetaField rootField2 = meta.FieldList.New(FtStandardDataType.Integer);

            rootField2.Id = RootField2Id;
            FtMetaField rootField3 = meta.FieldList.New(FtStandardDataType.Boolean);

            rootField3.Id = RootField3Id;
            FtMetaField sequence1Field1 = meta.FieldList.New(FtStandardDataType.Float);

            sequence1Field1.Id = Sequence1Field1Id;
            FtMetaField sequence1Field2 = meta.FieldList.New(FtStandardDataType.Decimal);

            sequence1Field2.Id = Sequence1Field2Id;
            FtMetaField sequence2Field1 = meta.FieldList.New(FtStandardDataType.DateTime);

            sequence2Field1.Id = Sequence2Field1Id;
            FtMetaField sequence2Field2 = meta.FieldList.New(FtStandardDataType.Boolean);

            sequence2Field2.Id = Sequence2Field2Id;
            FtMetaField sequence2Field3 = meta.FieldList.New(FtStandardDataType.String);

            sequence2Field3.Id = Sequence2Field3Id;
            FtMetaField sequence2Field4 = meta.FieldList.New(FtStandardDataType.Integer);

            sequence2Field4.Id = Sequence2Field4Id;
            FtMetaField sequence3Field1 = meta.FieldList.New(FtStandardDataType.Boolean);

            sequence3Field1.Id = Sequence3Field1Id;
            FtMetaField sequence4Field1 = meta.FieldList.New(FtStandardDataType.Float);

            sequence4Field1.Id = Sequence4Field1Id;
            FtMetaField sequence4Field2 = meta.FieldList.New(FtStandardDataType.Decimal);

            sequence4Field2.Id = Sequence4Field2Id;

            FtMetaSequence rootSequence = meta.SequenceList.New();

            rootSequence.Root = true;
            FtMetaSequenceItem rootItem1 = rootSequence.ItemList.New();

            rootItem1.Field = rootField1;
            FtMetaSequenceItem rootItem2 = rootSequence.ItemList.New();

            rootItem2.Field = rootField2;
            FtMetaSequenceItem rootItem3 = rootSequence.ItemList.New();

            rootItem3.Field = rootField3;

            FtMetaSequence sequence1 = meta.SequenceList.New();

            sequence1.Name = Sequence1Name;
            FtMetaSequenceItem sequence1Item1 = sequence1.ItemList.New();

            sequence1Item1.Field = sequence1Field1;
            FtMetaSequenceItem sequence1Item2 = sequence1.ItemList.New();

            sequence1Item2.Field = sequence1Field2;
            FtMetaSequence sequence2 = meta.SequenceList.New();

            sequence2.Name = Sequence2Name;
            FtMetaSequenceItem sequence2Item1 = sequence2.ItemList.New();

            sequence2Item1.Field = sequence2Field1;
            FtMetaSequenceItem sequence2Item2 = sequence2.ItemList.New();

            sequence2Item2.Field = sequence2Field2;
            FtMetaSequenceItem sequence2Item3 = sequence2.ItemList.New();

            sequence2Item3.Field = sequence2Field3;
            FtMetaSequenceItem sequence2Item4 = sequence2.ItemList.New();

            sequence2Item4.Field = sequence2Field4;
            FtMetaSequence sequence3 = meta.SequenceList.New();

            sequence3.Name = Sequence3Name;
            FtMetaSequenceItem sequence3Item1 = sequence3.ItemList.New();

            sequence3Item1.Field = sequence3Field1;
            FtMetaSequence sequence4 = meta.SequenceList.New();

            sequence4.Name = Sequence4Name;
            FtMetaSequenceItem sequence4Item1 = sequence4.ItemList.New();

            sequence4Item1.Field = sequence4Field1;
            FtMetaSequenceItem sequence4Item2 = sequence4.ItemList.New();

            sequence4Item2.Field = sequence4Field2;

            FtExactIntegerMetaSequenceRedirect rootRedirect1 = rootItem2.RedirectList.New(FtStandardSequenceRedirectType.ExactInteger) as FtExactIntegerMetaSequenceRedirect;

            rootRedirect1.InvokationDelay = RootRedirect1InvokationDelay;
            rootRedirect1.Value           = RootRedirect1Value;
            rootRedirect1.Sequence        = sequence1;
            FtExactIntegerMetaSequenceRedirect rootRedirect2 = rootItem2.RedirectList.New(FtStandardSequenceRedirectType.ExactInteger) as FtExactIntegerMetaSequenceRedirect;

            rootRedirect2.InvokationDelay = RootRedirect2InvokationDelay;
            rootRedirect2.Value           = 2;
            rootRedirect2.Sequence        = sequence2;
            FtExactIntegerMetaSequenceRedirect rootRedirect3 = rootItem2.RedirectList.New(FtStandardSequenceRedirectType.ExactInteger) as FtExactIntegerMetaSequenceRedirect;

            rootRedirect3.InvokationDelay = RootRedirect3InvokationDelay;
            rootRedirect3.Value           = 3;
            rootRedirect3.Sequence        = sequence3;

            FtNullMetaSequenceRedirect sequence1Redirect1 = sequence1Item2.RedirectList.New(FtStandardSequenceRedirectType.Null) as FtNullMetaSequenceRedirect;

            sequence1Redirect1.InvokationDelay = Sequence1Redirect1InvokationDelay;
            sequence1Redirect1.Sequence        = sequence4;

            FtCaseInsensitiveStringMetaSequenceRedirect sequence2Redirect1 = sequence2Item3.RedirectList.New(FtStandardSequenceRedirectType.CaseInsensitiveString) as FtCaseInsensitiveStringMetaSequenceRedirect;

            sequence2Redirect1.InvokationDelay = Sequence2Redirect1InvokationDelay;
            sequence2Redirect1.Value           = Sequence2Redirect1Value;
            sequence2Redirect1.Sequence        = sequence4;

            // Serialize Meta
            XmlWriter writer = XmlWriter.Create(filePath, xmlWriterSettings);

            FtMetaSerializer.Serialize(meta, writer);
            writer.Close();

            string DataFilePath = Path.Combine(DataFolder, SequenceFileName);

            if (!TextFilesAreEqual(filePath, DataFilePath))
            {
                Assert.Fail("MetaSequence does not match Test Data");
            }
            else
            {
                FtMeta deserializedMeta = FtMetaSerializer.Deserialize(filePath);
                AssertDeserializedMeta(deserializedMeta);

                string foreignFilePath     = Path.Combine(DataFolder, ForeignFileName);
                FtMeta deserializedForeign = FtMetaSerializer.Deserialize(foreignFilePath);
                AssertDeserializedMeta(deserializedForeign);
            }
        }
示例#10
0
        // Simple Example of using FtWriter to write a CSV file with headings.
        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "BasicExampleMeta.ftm";
            // Name of file to be written
            const string CsvFileName = "BasicExample.csv";

            // Define FieldNames
            const string PetNameFieldName      = "PetName";
            const string AgeFieldName          = "Age";
            const string ColorFieldName        = "Color";
            const string DateReceivedFieldName = "DateReceived";
            const string PriceFieldName        = "Price";
            const string NeedsWalkingFieldName = "NeedsWalking";
            const string TypeFieldName         = "Type";

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            // Create Writer
            using (FtWriter writer = new FtWriter(meta, CsvFileName))
            {
                FtStringField   petNameField      = writer.FieldList[PetNameFieldName] as FtStringField;
                FtFloatField    ageField          = writer.FieldList[AgeFieldName] as FtFloatField;
                FtStringField   colorField        = writer.FieldList[ColorFieldName] as FtStringField;
                FtDateTimeField dateReceivedField = writer.FieldList[DateReceivedFieldName] as FtDateTimeField;
                FtDecimalField  priceField        = writer.FieldList[PriceFieldName] as FtDecimalField;
                FtBooleanField  needsWalkingField = writer.FieldList[NeedsWalkingFieldName] as FtBooleanField;
                FtStringField   typeField         = writer.FieldList[TypeFieldName] as FtStringField;

                // set headings before writing first record
                petNameField.Headings[0]      = "Pet Name";
                ageField.Headings[0]          = "Age";
                ageField.Headings[1]          = "(Years)";
                colorField.Headings[0]        = "Color";
                dateReceivedField.Headings[0] = "Date Received";
                priceField.Headings[0]        = "Price";
                priceField.Headings[1]        = "(Dollars)";
                needsWalkingField.Headings[0] = "Needs Walking";
                typeField.Headings[0]         = "Type";

                // Write 1st Record - this will write header (including heading lines)
                writer[PetNameFieldName]      = "Rover";
                writer[AgeFieldName]          = 4.5;
                writer[ColorFieldName]        = "Brown";
                writer[DateReceivedFieldName] = new DateTime(2004, 2, 12);
                writer[PriceFieldName]        = 80M;
                writer[NeedsWalkingFieldName] = true;
                writer[TypeFieldName]         = "Dog";

                writer.Write();

                // Write 2nd Record
                writer[PetNameFieldName]      = "Charlie";
                writer[AgeFieldName]          = null;
                writer[ColorFieldName]        = "Gold";
                writer[DateReceivedFieldName] = new DateTime(2007, 4, 5);
                writer[PriceFieldName]        = 12.3M;
                writer[NeedsWalkingFieldName] = false;
                writer[TypeFieldName]         = "Fish";

                writer.Write();
            }
        }
示例#11
0
        public void MetaVariations()
        {
            foreach (MetaVariation variation in metaVariationArray)
            {
                FtMeta meta = new FtMeta();
                variation.Properties.LoadIntoMeta(ref meta);

                foreach (MetaFieldDefinition metaFieldDefinition in metaFieldDefinitionArray)
                {
                    FtMetaField metaField = meta.FieldList.New(metaFieldDefinition.DataType);
                    // metaField.Name = "Field" + idx++.ToString();
                    metaFieldDefinition.Properties.LoadIntoMetaField(ref metaField, true);

                    switch (metaFieldDefinition.DataType)
                    {
                    case FtStandardDataType.Boolean:
                        FtBooleanMetaField booleanMetaField = metaField as FtBooleanMetaField;
                        booleanMetaField.Styles    = BooleanMetaFieldStyles;
                        booleanMetaField.FalseText = BooleanMetaFieldFalseText;
                        booleanMetaField.TrueText  = BooleanMetaFieldTrueText;
                        break;

                    case FtStandardDataType.String:
                        FtStringMetaField stringMetaField = metaField as FtStringMetaField;
                        stringMetaField.Value = StringMetaFieldValue;
                        break;

                    case FtStandardDataType.Float:
                        FtFloatMetaField floatMetaField = metaField as FtFloatMetaField;
                        floatMetaField.Format = FloatMetaFieldFormat;
                        floatMetaField.Styles = FloatMetaFieldStyles;
                        break;

                    case FtStandardDataType.DateTime:
                        FtDateTimeMetaField dateTimeMetaField = metaField as FtDateTimeMetaField;
                        dateTimeMetaField.Format = DateTimeMetaFieldFormat;
                        dateTimeMetaField.Styles = DateTimeMetaFieldStyles;
                        dateTimeMetaField.Value  = DateTimeMetaFieldValue;
                        break;
                    }
                }

                string    filePath = Path.Combine(TestFolder, variation.FileName);
                XmlWriter writer   = XmlWriter.Create(filePath, xmlWriterSettings);
                FtMetaSerializer.Serialize(meta, writer);
                writer.Close();

                string DataFilePath = Path.Combine(DataFolder, variation.FileName);
                if (!TextFilesAreEqual(filePath, DataFilePath))
                {
                    Assert.Fail(variation.FileName + " does not match Test Data");
                }
                else
                {
                    FtMeta deserialisedMeta = FtMetaSerializer.Deserialize(filePath);

                    variation.Properties.AssertMetaAreEqual(meta);

                    Assert.AreEqual <int>(metaFieldDefinitionArray.Length, deserialisedMeta.FieldList.Count);

                    for (int i = 0; i < deserialisedMeta.FieldList.Count; i++)
                    {
                        FtMetaField metaField = deserialisedMeta.FieldList[i];
                        metaFieldDefinitionArray[i].Properties.AssertMetaFieldAreEqual(metaField, true);

                        switch (metaFieldDefinitionArray[i].DataType)
                        {
                        case FtStandardDataType.Boolean:
                            FtBooleanMetaField booleanMetaField = metaField as FtBooleanMetaField;
                            Assert.AreEqual <FtBooleanStyles>(BooleanMetaFieldStyles, booleanMetaField.Styles);
                            Assert.AreEqual <string>(BooleanMetaFieldFalseText, booleanMetaField.FalseText);
                            Assert.AreEqual <string>(BooleanMetaFieldTrueText, booleanMetaField.TrueText);
                            break;

                        case FtStandardDataType.String:
                            FtStringMetaField stringMetaField = metaField as FtStringMetaField;
                            Assert.AreEqual <string>(StringMetaFieldValue, stringMetaField.Value);
                            break;

                        case FtStandardDataType.Float:
                            FtFloatMetaField floatMetaField = metaField as FtFloatMetaField;
                            Assert.AreEqual <string>(FloatMetaFieldFormat, floatMetaField.Format);
                            Assert.AreEqual <NumberStyles>(FloatMetaFieldStyles, floatMetaField.Styles);
                            break;

                        case FtStandardDataType.DateTime:
                            FtDateTimeMetaField dateTimeMetaField = metaField as FtDateTimeMetaField;
                            Assert.AreEqual <string>(DateTimeMetaFieldFormat, dateTimeMetaField.Format);
                            Assert.AreEqual <DateTimeStyles>(DateTimeMetaFieldStyles, dateTimeMetaField.Styles);
                            Assert.AreEqual <DateTime>(DateTimeMetaFieldValue, dateTimeMetaField.Value);
                            break;
                        }
                    }
                }
            }
        }
示例#12
0
        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "ExampleSequenceMeta.ftm";
            // Name of file to be read
            const string CsvFileName = "ExampleSequence.csv";

            // Define Field Names
            const string TypeFieldName                  = "Type";
            const string NameFieldName                  = "Name";
            const string RunningSpeedFieldName          = "RunningSpeed";
            const string WalkDistanceFieldName          = "WalkDistance";
            const string TrainingFieldName              = "Training";
            const string TrainerFieldName               = "Trainer";
            const string SessionCostFieldName           = "SessionCost";
            const string ColorFieldName                 = "Color";
            const string ChineseClassificationFieldName = "ChineseClassification";

            // Define Type values
            const long CatType      = 1;
            const long DogType      = 2;
            const long GoldFishType = 3;

            const int MaxFieldCount = 7;

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            // Create Reader
            using (FtReader reader = new FtReader(meta, CsvFileName))
            {
                // Normally a reader.Read() will return false when a new table starts in a file.
                // You would then need to call reader.NextResult() (or reader.NextTable()) to
                // read the record from the next table.
                // When a new table starts, you would need to get new field ordinal values with
                // reader.GetOrdinal() if you are using field ordinals.
                // However this example does not use field ordinal values.  It just uses field names.
                // Accordingly we want to reader.Read() to return true until no more records.
                // Set AutoNextTable to true for this behaviour.
                reader.AutoNextTable = true;

                // Read each record in text file and write field values to console
                int recNumber = 0;
                while (reader.Read())
                {
                    recNumber++;
                    object[] recObjects = new object[MaxFieldCount];

                    // read Root Sequence Fields
                    recObjects[0] = reader[TypeFieldName];
                    recObjects[1] = reader[NameFieldName];

                    int fieldCount;

                    // Type Field specifies what type of record this is and what fields there are
                    long type = (long)recObjects[0];
                    switch (type)
                    {
                    case CatType:
                        recObjects[2] = reader[RunningSpeedFieldName];
                        fieldCount    = 3;
                        break;

                    case DogType:
                        recObjects[2] = reader[WalkDistanceFieldName];
                        recObjects[3] = reader[RunningSpeedFieldName];
                        recObjects[4] = reader[TrainingFieldName];
                        bool training = (bool)recObjects[4];
                        if (!training)
                        {
                            fieldCount = 5;
                        }
                        else
                        {
                            recObjects[5] = reader[TrainerFieldName];
                            recObjects[6] = reader[SessionCostFieldName];
                            fieldCount    = 7;
                        }
                        break;

                    case GoldFishType:
                        recObjects[2] = reader[ColorFieldName];
                        recObjects[3] = reader[ChineseClassificationFieldName];
                        fieldCount    = 4;
                        break;

                    default:
                        fieldCount = 2;
                        break;
                    }

                    Array.Resize <object>(ref recObjects, fieldCount);

                    Console.WriteLine(recNumber.ToString() + ": " + string.Join(",", recObjects));
                }
            }
        }
示例#13
0
        // Write a CSV file containing sequences
        // Uses ExampleSequenceMeta.ftm from BuildMetaWithSequences project
        static void Main(string[] args)
        {
            // Name of file containing Meta
            const string MetaFileName = "ExampleSequenceMeta.ftm";
            // Name of file to be written
            const string CsvFileName = "ExampleSequence.csv";

            // Define Field Names
            const string TypeFieldName                  = "Type";
            const string NameFieldName                  = "Name";
            const string RunningSpeedFieldName          = "RunningSpeed";
            const string WalkDistanceFieldName          = "WalkDistance";
            const string TrainingFieldName              = "Training";
            const string TrainerFieldName               = "Trainer";
            const string SessionCostFieldName           = "SessionCost";
            const string ColorFieldName                 = "Color";
            const string ChineseClassificationFieldName = "ChineseClassification";

            // Define Type values
            const long CatType      = 1;
            const long DogType      = 2;
            const long GoldFishType = 3;

            // Create Meta from file
            FtMeta meta = FtMetaSerializer.Deserialize(MetaFileName);

            // Create Writer
            using (FtWriter writer = new FtWriter(meta, CsvFileName))
            {
                // When writing records with sequences, you must not set a field's value
                // if its sequence has not yet been invoked by a redirect.
                // When writing, whenever a sequence is invoked by a redirect, its field
                // values are initialized to null
                // Root Sequence is always automatically invoked

                // Write 1st Record (1st table)
                writer[TypeFieldName]         = CatType; // invoke Cat Sequence (after Root Sequence is finished)
                writer[NameFieldName]         = "Misty";
                writer[RunningSpeedFieldName] = 45.0;
                writer.Write();

                // Write 2nd Record
                writer[TypeFieldName]         = CatType; // invoke Cat Sequence (after Root Sequence is finished)
                writer[NameFieldName]         = "Oscar";
                writer[RunningSpeedFieldName] = 35.0;
                writer.Write();

                // Write 3rd Record  (2nd table)
                writer[TypeFieldName]         = DogType; // invoke Dog Sequence (after Root Sequence is finished)
                writer[NameFieldName]         = "Buddy";
                writer[WalkDistanceFieldName] = 0.5;
                writer[RunningSpeedFieldName] = 35.0;
                writer[TrainingFieldName]     = false;
                writer.Write();

                // Write 4th Record (3rd table)
                writer[TypeFieldName]         = DogType; // invoke Dog Sequence (after Root Sequence is finished)
                writer[NameFieldName]         = "Charlie";
                writer[WalkDistanceFieldName] = 2.0;
                writer[RunningSpeedFieldName] = 48.0;
                writer[TrainingFieldName]     = true; // invoke Training Sequence (after this field)
                writer[TrainerFieldName]      = "John";
                writer[SessionCostFieldName]  = 32.0M;
                writer.Write();

                // Write 5th Record (4th table)
                writer[TypeFieldName]         = DogType; // invoke Dog Sequence (after Root Sequence is finished)
                writer[NameFieldName]         = "Max";
                writer[WalkDistanceFieldName] = 0.5;
                writer[RunningSpeedFieldName] = 30.0;
                writer[TrainingFieldName]     = false;
                writer.Write();

                // Write 6th Record (5th table)
                writer[TypeFieldName]  = GoldFishType; // invoke Gold Fish Sequence (after Root Sequence is finished)
                writer[NameFieldName]  = "Bubbles";
                writer[ColorFieldName] = "Orange";
                writer[ChineseClassificationFieldName] = "Wen";
                writer.Write();

                // Write 7th Record
                writer[TypeFieldName]  = GoldFishType; // invoke Gold Fish Sequence (after Root Sequence is finished)
                writer[NameFieldName]  = "Flash";
                writer[ColorFieldName] = "Yellow";
                writer[ChineseClassificationFieldName] = "Crucian";
                writer.Write();
            }
        }
示例#14
0
        public void Sequence()
        {
            int fieldsAffectedFromIndex;

            string metaFilePath = Path.Combine(DataFolder, SequenceMetaFileName);
            FtMeta meta         = FtMetaSerializer.Deserialize(metaFilePath);

            FtWriter writer = new FtWriter(meta, filePath);

            // root fields
            FtStringField   root1_StrConstField;
            FtDateTimeField root2_DateTimeField;
            FtIntegerField  root3_IntRedirField;
            FtDecimalField  level1_1_DecimalField;
            FtFloatField    level1_1_FloatRedirField;
            FtBooleanField  level1_Null_BooleanField;
            FtStringField   level1_1_StringField;
            FtDateTimeField level1_2_DateTimeField;
            //FtStringField level1_3_StringField;
            FtStringField level2_10_StringField;
            FtStringField level2_11_StringField;

            // in this case, root fields are never affected by redirects
            root1_StrConstField = writer.FieldList[Root1_StrConstFieldName] as FtStringField;
            root2_DateTimeField = writer.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
            root3_IntRedirField = writer.FieldList[Root3_IntRedirFieldName] as FtIntegerField;

            // Record 1 - no redirect
            root2_DateTimeField.Value = Record1_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record1_Root3IntRedirValue, out fieldsAffectedFromIndex);
            Assert.AreEqual(-1, fieldsAffectedFromIndex);
            Assert.AreEqual(Record1_FieldListCount, writer.FieldList.Count);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);
            writer.Write();

            Assert.AreEqual(1, writer.RecordCount);
            Assert.AreEqual(Record1_TableListCount, writer.TableCount);
            Assert.AreEqual(Record1_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 2 - no redirect
            root2_DateTimeField.Value = Record2_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record2_Root3IntRedirValue, out fieldsAffectedFromIndex);
            Assert.AreEqual(-1, fieldsAffectedFromIndex);
            Assert.AreEqual(Record2_FieldListCount, writer.FieldList.Count);
            Assert.AreEqual(Record2_SequenceInvokationListCount, writer.SequenceInvokationList.Count);
            writer.Write();

            Assert.AreEqual(2, writer.RecordCount);
            Assert.AreEqual(Record2_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 3 - root redirect 1
            root2_DateTimeField.Value = Record3_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record3_Root3IntRedirValue, out fieldsAffectedFromIndex);
            // redirect to level1_1 sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(Record3_FieldListCount, writer.FieldList.Count);
                Assert.AreEqual(Record3_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

                // remove redirection
                root3_IntRedirField.SetValue(20, out fieldsAffectedFromIndex);
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(Root_FieldListCount, writer.FieldList.Count);
                Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

                root3_IntRedirField.SetValue(Record3_Root3IntRedirValue, out fieldsAffectedFromIndex);
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(Record3_FieldListCount, writer.FieldList.Count);
                Assert.AreEqual(Record3_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

                level1_1_DecimalField    = writer.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = writer.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = writer.FieldList[Level1_1_StringFieldName] as FtStringField;

                level1_1_DecimalField.Value    = Record3_Level1_1_DecimalValue;
                level1_1_FloatRedirField.Value = Record3_Level1_1_FloatRedirValue;
                level1_1_StringField.Value     = Record3_Level1_1_StringValue;
            }
            writer.Write();

            Assert.AreEqual(3, writer.RecordCount);
            Assert.AreEqual(Record3_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 4 - root redirect 1
            root2_DateTimeField.Value = Record4_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record4_Root3IntRedirValue, out fieldsAffectedFromIndex);
            // redirect to level1_1 sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(Record4_FieldListCount, writer.FieldList.Count);
                Assert.AreEqual(Record4_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

                level1_1_DecimalField    = writer.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = writer.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = writer.FieldList[Level1_1_StringFieldName] as FtStringField;

                level1_1_DecimalField.Value    = Record4_Level1_1_DecimalValue;
                level1_1_FloatRedirField.Value = Record4_Level1_1_FloatRedirValue;
                level1_1_StringField.Value     = Record4_Level1_1_StringValue;
            }
            writer.Write();

            Assert.AreEqual(4, writer.RecordCount);
            Assert.AreEqual(Record4_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 5 - root redirect 1
            root2_DateTimeField.Value = Record5_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record5_Root3IntRedirValue, out fieldsAffectedFromIndex);
            // redirect to level1_1 sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(Record5_FieldListCount, writer.FieldList.Count);
                Assert.AreEqual(Record4_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

                level1_1_DecimalField    = writer.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = writer.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = writer.FieldList[Level1_1_StringFieldName] as FtStringField;

                level1_1_DecimalField.Value    = Record5_Level1_1_DecimalValue;
                level1_1_FloatRedirField.Value = Record5_Level1_1_FloatRedirValue;
                level1_1_StringField.Value     = Record5_Level1_1_StringValue;
            }
            writer.Write();

            Assert.AreEqual(5, writer.RecordCount);
            Assert.AreEqual(Record5_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 6 - root redirect Null
            root2_DateTimeField.Value = Record6_Root2DateTimeValue;
            root3_IntRedirField.SetNull(out fieldsAffectedFromIndex);
            // redirect to level1_Null sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(Record6_FieldListCount, writer.FieldList.Count);
                Assert.AreEqual(Record6_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

                level1_Null_BooleanField = writer.FieldList[Level1_Null_BooleanFieldName] as FtBooleanField;

                level1_Null_BooleanField.Value = Record6_level1_Null_BooleanValue;
            }
            writer.Write();

            Assert.AreEqual(6, writer.RecordCount);
            Assert.AreEqual(Record6_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 7 - root redirect 2
            root2_DateTimeField.Value = Record7_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record7_Root3IntRedirValue, out fieldsAffectedFromIndex);
            // redirect to level1_2 sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(Record7_FieldListCount, writer.FieldList.Count);
                Assert.AreEqual(Record7_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

                level1_2_DateTimeField = writer.FieldList[Level1_2_DateTimeFieldName] as FtDateTimeField;

                // leave it null
            }
            writer.Write();

            Assert.AreEqual(7, writer.RecordCount);
            Assert.AreEqual(Record7_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 8 - root redirect 1
            root2_DateTimeField.Value = Record8_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record8_Root3IntRedirValue, out fieldsAffectedFromIndex);
            // redirect to level1_1 sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(6, writer.FieldList.Count);
                Assert.AreEqual(2, writer.SequenceInvokationList.Count);

                level1_1_DecimalField    = writer.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = writer.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = writer.FieldList[Level1_1_StringFieldName] as FtStringField;

                level1_1_DecimalField.Value = Record8_Level1_1_DecimalValue;
                level1_1_FloatRedirField.SetValue(Record8_Level1_1_FloatRedirValue, out fieldsAffectedFromIndex); // redirect
                // redirect to Level2_10 sequence
                {
                    Assert.AreEqual(5, fieldsAffectedFromIndex);
                    Assert.AreEqual(Record8_FieldListCount, writer.FieldList.Count);
                    Assert.AreEqual(Record8_SequenceInvokationListCount, writer.SequenceInvokationList.Count);
                    Assert.AreEqual(-1, writer.FieldList.IndexOfName(Level1_1_StringFieldName)); // should have been discarded by Redirect

                    level2_10_StringField       = writer.FieldList[Level2_10_StringFieldName] as FtStringField;
                    level2_10_StringField.Value = Record8_level2_10_StringValue;
                }
            }
            writer.Write();

            Assert.AreEqual(8, writer.RecordCount);
            Assert.AreEqual(Record8_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 9 - root redirect 1
            root2_DateTimeField.Value = Record9_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record9_Root3IntRedirValue, out fieldsAffectedFromIndex);
            // redirect to level1_1 sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(6, writer.FieldList.Count);
                Assert.AreEqual(2, writer.SequenceInvokationList.Count);

                level1_1_DecimalField    = writer.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = writer.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = writer.FieldList[Level1_1_StringFieldName] as FtStringField;

                level1_1_DecimalField.Value = Record9_Level1_1_DecimalValue;
                level1_1_FloatRedirField.SetValue(Record9_Level1_1_FloatRedirValue, out fieldsAffectedFromIndex); // redirect
                // redirect to Level2_10 sequence
                {
                    Assert.AreEqual(5, fieldsAffectedFromIndex);
                    Assert.AreEqual(Record9_FieldListCount, writer.FieldList.Count);
                    Assert.AreEqual(Record9_SequenceInvokationListCount, writer.SequenceInvokationList.Count);
                    Assert.AreEqual(-1, writer.FieldList.IndexOfName(Level1_1_StringFieldName)); // should have been discarded by Redirect

                    level2_10_StringField       = writer.FieldList[Level2_10_StringFieldName] as FtStringField;
                    level2_10_StringField.Value = Record9_level2_10_StringValue;
                }
            }
            writer.Write();

            Assert.AreEqual(9, writer.RecordCount);
            Assert.AreEqual(Record9_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 10 - root redirect 1
            root2_DateTimeField.Value = Record10_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record10_Root3IntRedirValue, out fieldsAffectedFromIndex);
            // redirect to level1_1 sequence
            {
                Assert.AreEqual(3, fieldsAffectedFromIndex);
                Assert.AreEqual(6, writer.FieldList.Count);
                Assert.AreEqual(2, writer.SequenceInvokationList.Count);

                level1_1_DecimalField    = writer.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = writer.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = writer.FieldList[Level1_1_StringFieldName] as FtStringField;

                level1_1_DecimalField.Value = Record10_Level1_1_DecimalValue;
                level1_1_StringField.Value  = Record10_Level1_1_StringValue;
                level1_1_FloatRedirField.SetValue(Record10_Level1_1_FloatRedirValue, out fieldsAffectedFromIndex); // redirect
                // redirect to Level2_11 sequence
                {
                    Assert.AreEqual(6, fieldsAffectedFromIndex);
                    Assert.AreEqual(Record10_FieldListCount, writer.FieldList.Count);
                    Assert.AreEqual(Record10_SequenceInvokationListCount, writer.SequenceInvokationList.Count);
                    Assert.AreEqual(5, writer.FieldList.IndexOfName(Level1_1_StringFieldName)); // confirm not discarded
                    Assert.AreEqual(Record10_Level1_1_StringValue, level1_1_StringField.Value);

                    level2_11_StringField       = writer.FieldList[Level2_11_StringFieldName] as FtStringField;
                    level2_11_StringField.Value = Record10_level2_11_StringValue;
                }
            }
            writer.Write();

            Assert.AreEqual(10, writer.RecordCount);
            Assert.AreEqual(Record10_TableListCount, writer.TableCount);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            // Record 11 - no redirect
            root2_DateTimeField.Value = Record11_Root2DateTimeValue;
            root3_IntRedirField.SetValue(Record11_Root3IntRedirValue, out fieldsAffectedFromIndex);
            Assert.AreEqual(-1, fieldsAffectedFromIndex);
            Assert.AreEqual(Record11_FieldListCount, writer.FieldList.Count);
            Assert.AreEqual(Root_SequenceInvokationListCount, writer.SequenceInvokationList.Count);
            writer.Write();

            Assert.AreEqual(11, writer.RecordCount);
            Assert.AreEqual(Record11_TableListCount, writer.TableCount);
            Assert.AreEqual(Record11_SequenceInvokationListCount, writer.SequenceInvokationList.Count);

            writer.Close();

            string dataFilePath = Path.Combine(DataFolder, SequenceFileName);

            if (!TextFilesAreEqual(filePath, dataFilePath))
            {
                Assert.Fail("Sequence does not match Test Data");
            }
            else
            {
                FtReader reader = new FtReader(meta);
                reader.Open(filePath);

                Assert.AreEqual <bool>(false, reader.Declared);
                Assert.AreEqual <bool>(true, reader.HeaderRead);
                Assert.AreEqual <int>(1, reader.HeadingLineReadCount);
                Assert.AreEqual <FtMetaReferenceType>(FtMetaReferenceType.None, reader.MetaReferenceType);
                Assert.AreEqual <FtLineType>(FtLineType.Heading, reader.LineType); // last line in header

                root1_StrConstField = reader.FieldList[Root1_StrConstFieldName] as FtStringField;
                root2_DateTimeField = reader.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
                root3_IntRedirField = reader.FieldList[Root3_IntRedirFieldName] as FtIntegerField;

                // Record 1
                reader.Read();

                Assert.AreEqual(Record1_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record1_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(1, reader.RecordCount);
                Assert.AreEqual(Record1_TableListCount, reader.TableCount);

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record1_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record1_Root3IntRedirValue, root3_IntRedirField.Value);

                // Record 2
                reader.Read();

                Assert.AreEqual(Record2_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record2_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(2, reader.RecordCount);
                Assert.AreEqual(Record2_TableListCount, reader.TableCount);

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record2_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record2_Root3IntRedirValue, root3_IntRedirField.Value);

                // Record 3
                bool readResult = reader.Read();
                Assert.AreEqual <bool>(false, readResult);
                Assert.AreEqual(2, reader.RecordCount);
                Assert.AreEqual(Record2_TableListCount, reader.TableCount);

                reader.AutoNextTable = true;
                readResult           = reader.Read();
                Assert.AreEqual <bool>(true, readResult);

                Assert.AreEqual(Record3_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record3_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(3, reader.RecordCount);
                Assert.AreEqual(Record3_TableListCount, reader.TableCount);

                root1_StrConstField      = reader.FieldList[Root1_StrConstFieldName] as FtStringField;
                root2_DateTimeField      = reader.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
                root3_IntRedirField      = reader.FieldList[Root3_IntRedirFieldName] as FtIntegerField;
                level1_1_DecimalField    = reader.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = reader.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = reader.FieldList[Level1_1_StringFieldName] as FtStringField;

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record3_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record3_Root3IntRedirValue, root3_IntRedirField.Value);
                Assert.AreEqual <decimal>(Record3_Level1_1_DecimalValue, level1_1_DecimalField.Value);
                Assert.AreEqual <double>(Record3_Level1_1_FloatRedirValue, level1_1_FloatRedirField.Value);
                Assert.AreEqual <string>(Record3_Level1_1_StringValue, level1_1_StringField.Value);

                // Record 4
                reader.Read();

                Assert.AreEqual(Record4_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record4_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(4, reader.RecordCount);
                Assert.AreEqual(Record4_TableListCount, reader.TableCount);

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record4_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record4_Root3IntRedirValue, root3_IntRedirField.Value);
                Assert.AreEqual <decimal>(Record4_Level1_1_DecimalValue, level1_1_DecimalField.Value);
                Assert.AreEqual <double>(Record4_Level1_1_FloatRedirValue, level1_1_FloatRedirField.Value);
                Assert.AreEqual <string>(Record4_Level1_1_StringValue, level1_1_StringField.Value);

                // Record 5
                reader.Read();

                Assert.AreEqual(Record5_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record5_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(5, reader.RecordCount);
                Assert.AreEqual(Record5_TableListCount, reader.TableCount);

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record5_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record5_Root3IntRedirValue, root3_IntRedirField.Value);
                Assert.AreEqual <decimal>(Record5_Level1_1_DecimalValue, level1_1_DecimalField.Value);
                Assert.AreEqual <double>(Record5_Level1_1_FloatRedirValue, level1_1_FloatRedirField.Value);
                Assert.AreEqual <string>(Record5_Level1_1_StringValue, level1_1_StringField.Value);

                // Record 6
                reader.Read();

                Assert.AreEqual(Record6_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record6_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(6, reader.RecordCount);
                Assert.AreEqual(Record6_TableListCount, reader.TableCount);

                root1_StrConstField      = reader.FieldList[Root1_StrConstFieldName] as FtStringField;
                root2_DateTimeField      = reader.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
                root3_IntRedirField      = reader.FieldList[Root3_IntRedirFieldName] as FtIntegerField;
                level1_Null_BooleanField = reader.FieldList[Level1_Null_BooleanFieldName] as FtBooleanField;

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record6_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <bool>(true, root3_IntRedirField.IsNull());
                Assert.AreEqual <bool>(Record6_level1_Null_BooleanValue, level1_Null_BooleanField.Value);

                // Record 7
                reader.Read();

                Assert.AreEqual(Record7_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record7_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(7, reader.RecordCount);
                Assert.AreEqual(Record7_TableListCount, reader.TableCount);

                root1_StrConstField    = reader.FieldList[Root1_StrConstFieldName] as FtStringField;
                root2_DateTimeField    = reader.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
                root3_IntRedirField    = reader.FieldList[Root3_IntRedirFieldName] as FtIntegerField;
                level1_2_DateTimeField = reader.FieldList[Level1_2_DateTimeFieldName] as FtDateTimeField;

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record7_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record7_Root3IntRedirValue, root3_IntRedirField.Value);
                Assert.AreEqual <bool>(true, level1_2_DateTimeField.IsNull());

                // Record 8
                reader.Read();

                Assert.AreEqual(Record8_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record8_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(8, reader.RecordCount);
                Assert.AreEqual(Record8_TableListCount, reader.TableCount);

                root1_StrConstField      = reader.FieldList[Root1_StrConstFieldName] as FtStringField;
                root2_DateTimeField      = reader.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
                root3_IntRedirField      = reader.FieldList[Root3_IntRedirFieldName] as FtIntegerField;
                level1_1_DecimalField    = reader.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = reader.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                Assert.AreEqual <int>(-1, reader.FieldList.IndexOfName(Level1_1_StringFieldName));
                level2_10_StringField = reader.FieldList[Level2_10_StringFieldName] as FtStringField;

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record8_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record8_Root3IntRedirValue, root3_IntRedirField.Value);
                Assert.AreEqual <decimal>(Record8_Level1_1_DecimalValue, level1_1_DecimalField.Value);
                Assert.AreEqual <double>(Record8_Level1_1_FloatRedirValue, level1_1_FloatRedirField.Value);
                Assert.AreEqual <string>(Record8_level2_10_StringValue, level2_10_StringField.Value);

                // Record 9
                reader.Read();

                Assert.AreEqual <int>(-1, reader.FieldList.IndexOfName(Level1_1_StringFieldName));

                Assert.AreEqual(Record9_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record9_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(9, reader.RecordCount);
                Assert.AreEqual(Record9_TableListCount, reader.TableCount);

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record9_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record9_Root3IntRedirValue, root3_IntRedirField.Value);
                Assert.AreEqual <decimal>(Record9_Level1_1_DecimalValue, level1_1_DecimalField.Value);
                Assert.AreEqual <double>(Record9_Level1_1_FloatRedirValue, level1_1_FloatRedirField.Value);
                Assert.AreEqual <string>(Record9_level2_10_StringValue, level2_10_StringField.Value);

                // Record 10
                reader.Read();

                Assert.AreEqual(Record10_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record10_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(10, reader.RecordCount);
                Assert.AreEqual(Record10_TableListCount, reader.TableCount);

                root1_StrConstField      = reader.FieldList[Root1_StrConstFieldName] as FtStringField;
                root2_DateTimeField      = reader.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
                root3_IntRedirField      = reader.FieldList[Root3_IntRedirFieldName] as FtIntegerField;
                level1_1_DecimalField    = reader.FieldList[Level1_1_DecimalFieldName] as FtDecimalField;
                level1_1_FloatRedirField = reader.FieldList[Level1_1_FloatRedirFieldName] as FtFloatField;
                level1_1_StringField     = reader.FieldList[Level1_1_StringFieldName] as FtStringField;
                level2_11_StringField    = reader.FieldList[Level2_11_StringFieldName] as FtStringField;

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record10_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record10_Root3IntRedirValue, root3_IntRedirField.Value);
                Assert.AreEqual <decimal>(Record10_Level1_1_DecimalValue, level1_1_DecimalField.Value);
                Assert.AreEqual <double>(Record10_Level1_1_FloatRedirValue, level1_1_FloatRedirField.Value);
                Assert.AreEqual <string>(Record10_Level1_1_StringValue, level1_1_StringField.Value);
                Assert.AreEqual <string>(Record10_level2_11_StringValue, level2_11_StringField.Value);

                // Record 11
                reader.Read();

                Assert.AreEqual(Record11_FieldListCount, reader.FieldList.Count);
                Assert.AreEqual(Record11_SequenceInvokationListCount, reader.SequenceInvokationList.Count);
                Assert.AreEqual(11, reader.RecordCount);
                Assert.AreEqual(Record11_TableListCount, reader.TableCount);

                root1_StrConstField = reader.FieldList[Root1_StrConstFieldName] as FtStringField;
                root2_DateTimeField = reader.FieldList[Root2_DateTimeFieldName] as FtDateTimeField;
                root3_IntRedirField = reader.FieldList[Root3_IntRedirFieldName] as FtIntegerField;

                Assert.AreEqual <string>(Root1StrConstValue, root1_StrConstField.Value);
                Assert.AreEqual <DateTime>(Record11_Root2DateTimeValue, root2_DateTimeField.Value);
                Assert.AreEqual <long>(Record11_Root3IntRedirValue, root3_IntRedirField.Value);

                reader.Close();
            }
        }
示例#15
0
        public void AllDefaults()
        {
            // Creates Meta with one sequence with one field of each type
            // Sets Meta and fields and sequence redirects properties to default values
            // Saves to XML (Serialize)
            // Compares XML to Expected
            // Creates Meta from XML (Deserialize)
            // Checks properties are as originally set

            state = State.Initialise;

            // Create Meta and set default properties
            FtMeta meta = new FtMeta();

            defaultMetaProperties.LoadIntoMeta(ref meta);

            FtStringMetaField stringField = meta.FieldList.New(FtStandardDataType.String) as FtStringMetaField;

            stringField.Name = StringFieldName;
            FtBooleanMetaField booleanField = meta.FieldList.New(FtStandardDataType.Boolean) as FtBooleanMetaField;

            booleanField.Name = BooleanFieldName;
            FtIntegerMetaField integerField = meta.FieldList.New(FtStandardDataType.Integer) as FtIntegerMetaField;

            integerField.Name = IntegerFieldName;
            FtFloatMetaField floatField = meta.FieldList.New(FtStandardDataType.Float) as FtFloatMetaField;

            floatField.Name = FloatFieldName;
            FtDecimalMetaField decimalField = meta.FieldList.New(FtStandardDataType.Decimal) as FtDecimalMetaField;

            decimalField.Name = DecimalFieldName;
            FtDateTimeMetaField dateTimeField = meta.FieldList.New(FtStandardDataType.DateTime) as FtDateTimeMetaField;

            dateTimeField.Name = DateTimeFieldName;

            FtStringMetaField redirectStringField1 = meta.FieldList.New(FtStandardDataType.String) as FtStringMetaField;

            redirectStringField1.Name = RedirectStringField1Name;
            FtBooleanMetaField redirectBooleanField2 = meta.FieldList.New(FtStandardDataType.Boolean) as FtBooleanMetaField;

            redirectBooleanField2.Name = RedirectBooleanField2Name;
            FtIntegerMetaField redirectIntegerField3 = meta.FieldList.New(FtStandardDataType.Integer) as FtIntegerMetaField;

            redirectIntegerField3.Name = RedirectIntegerField3Name;
            FtFloatMetaField redirectFloatField4 = meta.FieldList.New(FtStandardDataType.Float) as FtFloatMetaField;

            redirectFloatField4.Name = RedirectFloatField4Name;
            FtDecimalMetaField redirectDecimalField5 = meta.FieldList.New(FtStandardDataType.Decimal) as FtDecimalMetaField;

            redirectDecimalField5.Name = RedirectDecimalField5Name;
            FtDateTimeMetaField redirectDateTimeField6 = meta.FieldList.New(FtStandardDataType.DateTime) as FtDateTimeMetaField;

            redirectDateTimeField6.Name = RedirectDateTimeField6Name;

            // Create root sequence
            FtMetaSequence rootSequence = meta.SequenceList.New();

            rootSequence.Name = "Root";
            rootSequence.Root = true;

            // Create redirect target sequence
            FtMetaSequence redirectTargetSequence = meta.SequenceList.New();

            redirectTargetSequence.Name = "RedirectTarget";
            FtMetaSequenceItem     sequenceItem;
            FtMetaSequenceRedirect sequenceRedirect;

            sequenceItem              = redirectTargetSequence.ItemList.New();
            sequenceItem.Field        = redirectStringField1;
            sequenceItem              = redirectTargetSequence.ItemList.New();
            sequenceItem.Field        = redirectBooleanField2;
            sequenceRedirect          = sequenceItem.RedirectList.New(FtStandardSequenceRedirectType.Null);
            sequenceRedirect.Sequence = rootSequence;
            sequenceItem              = redirectTargetSequence.ItemList.New();
            sequenceItem.Field        = redirectIntegerField3;
            sequenceItem              = redirectTargetSequence.ItemList.New();
            sequenceItem.Field        = redirectFloatField4;
            sequenceRedirect          = sequenceItem.RedirectList.New(FtStandardSequenceRedirectType.Null);
            sequenceRedirect.Sequence = rootSequence;
            sequenceItem              = redirectTargetSequence.ItemList.New();
            sequenceItem.Field        = redirectDecimalField5;
            sequenceItem              = redirectTargetSequence.ItemList.New();
            sequenceItem.Field        = redirectDateTimeField6;

            // Create one field of each type and set properties to defaults and put in sequence.  Add default redirect to sequence item redirect list
            AllDefaults_Field(stringField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactString, 0);
            AllDefaults_Field(booleanField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.Boolean, 1);
            booleanField.FalseText = BooleanFalseText;
            booleanField.TrueText  = BooleanTrueText;
            booleanField.Styles    = BooleanStyles;
            AllDefaults_Field(integerField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactInteger, 2);
            integerField.Format = IntegerFieldFormat;
            integerField.Styles = IntegerFieldStyles;
            AllDefaults_Field(floatField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactFloat, 3);
            floatField.Format = FloatFieldFormat;
            floatField.Styles = FloatFieldStyles;
            AllDefaults_Field(decimalField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactDecimal, 4);
            decimalField.Format = DecimalFieldFormat;
            decimalField.Styles = DecimalFieldStyles;
            AllDefaults_Field(dateTimeField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactDateTime, 5);
            dateTimeField.Format = DateTimeFieldFormat;
            dateTimeField.Styles = DateTimeFieldStyles;

            // Add one substitution of default substitution type
            FtMetaSubstitution substitution = meta.SubstitutionList.New();

            substitution.Type  = SubstitutionType;
            substitution.Token = SubstitutionToken;
            substitution.Value = SubstitutionValue;

            // Serialize Meta
            XmlWriter writer = XmlWriter.Create(filePath, xmlWriterSettings);

            FtMetaSerializer.Serialize(meta, writer);
            writer.Close();

            state = State.Assert;

            string DataFilePath = Path.Combine(DataFolder, AllDefaultsFileName);

            if (!TextFilesAreEqual(filePath, DataFilePath))
            {
                Assert.Fail("AllDefaults does not match Test Data");
            }
            else
            {
                FtMeta deserialisedMeta = FtMetaSerializer.Deserialize(filePath);

                defaultMetaProperties.AssertMetaAreEqual(meta);

                rootSequence = meta.SequenceList[0];
                Assert.AreEqual <bool>(true, rootSequence.Root);
                Assert.AreEqual <int>(6, rootSequence.ItemList.Count);
                redirectTargetSequence = meta.SequenceList[1];
                Assert.AreEqual <bool>(false, redirectTargetSequence.Root);
                Assert.AreEqual <int>(6, redirectTargetSequence.ItemList.Count);

                stringField = meta.FieldList[0] as FtStringMetaField;
                Assert.AreEqual <string>(StringFieldName, stringField.Name);
                AllDefaults_Field(stringField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactString, 0);
                booleanField = meta.FieldList[1] as FtBooleanMetaField;
                Assert.AreEqual <string>(BooleanFieldName, booleanField.Name);
                AllDefaults_Field(booleanField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.Boolean, 1);
                Assert.AreEqual <string>(BooleanFalseText, booleanField.FalseText);
                Assert.AreEqual <string>(BooleanTrueText, booleanField.TrueText);
                Assert.AreEqual <FtBooleanStyles>(BooleanStyles, booleanField.Styles);
                integerField = meta.FieldList[2] as FtIntegerMetaField;
                Assert.AreEqual <string>(IntegerFieldName, integerField.Name);
                AllDefaults_Field(integerField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactInteger, 2);
                Assert.AreEqual <string>(IntegerFieldFormat, integerField.Format);
                Assert.AreEqual <NumberStyles>(IntegerFieldStyles, integerField.Styles);
                floatField = meta.FieldList[3] as FtFloatMetaField;
                Assert.AreEqual <string>(FloatFieldName, floatField.Name);
                AllDefaults_Field(floatField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactFloat, 3);
                Assert.AreEqual <string>(FloatFieldFormat, floatField.Format);
                Assert.AreEqual <NumberStyles>(FloatFieldStyles, floatField.Styles);
                decimalField = meta.FieldList[4] as FtDecimalMetaField;
                Assert.AreEqual <string>(DecimalFieldName, decimalField.Name);
                AllDefaults_Field(decimalField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactDecimal, 4);
                Assert.AreEqual <string>(DecimalFieldFormat, decimalField.Format);
                Assert.AreEqual <NumberStyles>(DecimalFieldStyles, decimalField.Styles);
                dateTimeField = meta.FieldList[5] as FtDateTimeMetaField;
                Assert.AreEqual <string>(DateTimeFieldName, dateTimeField.Name);
                AllDefaults_Field(dateTimeField, rootSequence, redirectTargetSequence, FtStandardSequenceRedirectType.ExactDateTime, 5);
                Assert.AreEqual <string>(DateTimeFieldFormat, dateTimeField.Format);
                Assert.AreEqual <DateTimeStyles>(DateTimeFieldStyles, dateTimeField.Styles);

                redirectStringField1 = meta.FieldList[6] as FtStringMetaField;
                Assert.AreEqual <string>(RedirectStringField1Name, redirectStringField1.Name);
                redirectBooleanField2 = meta.FieldList[7] as FtBooleanMetaField;
                Assert.AreEqual <string>(RedirectBooleanField2Name, redirectBooleanField2.Name);
                Assert.AreEqual <string>(BooleanFalseText, redirectBooleanField2.FalseText);
                Assert.AreEqual <string>(BooleanTrueText, redirectBooleanField2.TrueText);
                Assert.AreEqual <FtBooleanStyles>(BooleanStyles, redirectBooleanField2.Styles);
                redirectIntegerField3 = meta.FieldList[8] as FtIntegerMetaField;
                Assert.AreEqual <string>(RedirectIntegerField3Name, redirectIntegerField3.Name);
                Assert.AreEqual <string>(IntegerFieldFormat, redirectIntegerField3.Format);
                Assert.AreEqual <NumberStyles>(IntegerFieldStyles, redirectIntegerField3.Styles);
                redirectFloatField4 = meta.FieldList[9] as FtFloatMetaField;
                Assert.AreEqual <string>(RedirectFloatField4Name, redirectFloatField4.Name);
                Assert.AreEqual <string>(FloatFieldFormat, redirectFloatField4.Format);
                Assert.AreEqual <NumberStyles>(FloatFieldStyles, redirectFloatField4.Styles);
                redirectDecimalField5 = meta.FieldList[10] as FtDecimalMetaField;
                Assert.AreEqual <string>(RedirectDecimalField5Name, redirectDecimalField5.Name);
                Assert.AreEqual <string>(DecimalFieldFormat, redirectDecimalField5.Format);
                Assert.AreEqual <NumberStyles>(DecimalFieldStyles, redirectDecimalField5.Styles);
                redirectDateTimeField6 = meta.FieldList[11] as FtDateTimeMetaField;
                Assert.AreEqual <string>(RedirectDateTimeField6Name, redirectDateTimeField6.Name);
                Assert.AreEqual <string>(DateTimeFieldFormat, redirectDateTimeField6.Format);
                Assert.AreEqual <DateTimeStyles>(DateTimeFieldStyles, redirectDateTimeField6.Styles);

                Assert.AreEqual <FtMetaField>(redirectStringField1, redirectTargetSequence.ItemList[0].Field);
                Assert.AreEqual <int>(0, redirectTargetSequence.ItemList[0].RedirectList.Count);
                Assert.AreEqual <FtMetaField>(redirectBooleanField2, redirectTargetSequence.ItemList[1].Field);
                Assert.AreEqual <int>(1, redirectTargetSequence.ItemList[1].RedirectList.Count);
                Assert.AreEqual <int>(FtStandardSequenceRedirectType.Null, redirectTargetSequence.ItemList[1].RedirectList[0].Type);
                Assert.AreEqual <FtMetaField>(redirectIntegerField3, redirectTargetSequence.ItemList[2].Field);
                Assert.AreEqual <int>(0, redirectTargetSequence.ItemList[2].RedirectList.Count);
                Assert.AreEqual <FtMetaField>(redirectFloatField4, redirectTargetSequence.ItemList[3].Field);
                Assert.AreEqual <int>(1, redirectTargetSequence.ItemList[3].RedirectList.Count);
                Assert.AreEqual <int>(FtStandardSequenceRedirectType.Null, redirectTargetSequence.ItemList[3].RedirectList[0].Type);
                Assert.AreEqual <FtMetaField>(redirectDecimalField5, redirectTargetSequence.ItemList[4].Field);
                Assert.AreEqual <int>(0, redirectTargetSequence.ItemList[4].RedirectList.Count);
                Assert.AreEqual <FtMetaField>(redirectDateTimeField6, redirectTargetSequence.ItemList[5].Field);
                Assert.AreEqual <int>(0, redirectTargetSequence.ItemList[5].RedirectList.Count);
            }
        }