コード例 #1
0
        private BulkObject Peek()
        {
            if (!_passedFirstRow)
            {
                var firstRowObject = _bulkObjectReader.ReadNextBulkObject();

                var formatVersion = firstRowObject as FormatVersion;

                if (formatVersion != null)
                {
                    if (formatVersion.Value != "4" && formatVersion.Value != "4.0")
                    {
                        throw new InvalidOperationException(ErrorMessages.FormatVersionIsNotSupported +
                                                            formatVersion.Value);
                    }
                }
                else
                {
                    _nextObject = firstRowObject;
                }

                _passedFirstRow = true;
            }

            if (_nextObject != null)
            {
                return(_nextObject);
            }

            return(_nextObject = _bulkObjectReader.ReadNextBulkObject());
        }
コード例 #2
0
        public void WriteObjectRow(BulkObject bulkObject, bool excludeReadonlyData)
        {
            var values = new RowValues();

            bulkObject.WriteToRowValues(values, excludeReadonlyData);

            values[StringTable.Type] = _bulkObjectFactory.GetBulkRowType(bulkObject);

            _streamWriter.WriteLine(_formatter.FormatCsvRow(values.Columns));
        }
コード例 #3
0
        public string GetBulkRowType(BulkObject bulkObject)
        {
            if (bulkObject is BulkTargetIdentifier)
            {
                var identifier = (BulkTargetIdentifier)bulkObject;

                return(TargetIdentifierTypeReverseMap[identifier.GetType()][identifier.TargetBidType]);
            }

            return(TypeReverseMap[bulkObject.GetType()]);
        }
コード例 #4
0
        /// <summary>
        /// Reads the object only if it matches a predicate
        /// </summary>
        /// <typeparam name="T">Type of the object</typeparam>
        /// <param name="predicate">Predicate that needs to be matched</param>
        /// <param name="result">The next object from the file if the object matches the predicate, null otherwise</param>
        /// <returns>True is object matches the predicate, false otherwise</returns>
        public bool TryRead <T>(Predicate <T> predicate, out T result)
            where T : BulkObject
        {
            var peeked = Peek();

            var instanceOfT = peeked as T;

            if (instanceOfT != null && predicate(instanceOfT))
            {
                _nextObject = null;

                instanceOfT.ReadRelatedDataFromStream(this);

                result = instanceOfT;

                return(true);
            }

            result = null;

            return(false);
        }
コード例 #5
0
        public string GetBulkRowType(BulkObject bulkObject)
        {
            if (bulkObject is BulkTargetIdentifier)
            {
                var identifier = (BulkTargetIdentifier)bulkObject;

                return TargetIdentifierTypeReverseMap[identifier.GetType()][identifier.TargetBidType];
            }

            return TypeReverseMap[bulkObject.GetType()];
        }
コード例 #6
0
 public void WriteObjectRow(BulkObject bulkObject)
 {
     WriteObjectRow(bulkObject, false);
 }
コード例 #7
0
 public void WriteObjectRow(BulkObject bulkObject)
 {
     WriteObjectRow(bulkObject, false);
 }
コード例 #8
0
        public void WriteObjectRow(BulkObject bulkObject, bool excludeReadonlyData)
        {            
            var values = new RowValues();

            bulkObject.WriteToRowValues(values, excludeReadonlyData);

            values[StringTable.Type] = _bulkObjectFactory.GetBulkRowType(bulkObject);

            _streamWriter.WriteLine(_formatter.FormatCsvRow(values.Columns));
        }