Пример #1
0
        /// <summary>
        /// Create an engine on the record info provided
        /// </summary>
        /// <param name="ri">Record information</param>
        internal EngineBase(RecordInfo ri)
        {
            mRecordType = ri.RecordType;
            RecordInfo = ri;

            CreateRecordOptions();
        }
Пример #2
0
        /// <summary>
        /// Create and engine on type with specified encoding
        /// </summary>
        /// <param name="recordType">Class to base engine on</param>
        /// <param name="encoding">encoding of the file</param>
        internal EngineBase(Type recordType, Encoding encoding)
        {
            if (recordType == null)
                throw new BadUsageException(Messages.Errors.NullRecordClass.Text);

            if (recordType.IsValueType)
                throw new BadUsageException(Messages.Errors.StructRecordClass
                                                .RecordType(recordType.Name)
                                                .Text);

            mRecordType = recordType;
            mRecordInfo = RecordInfo.Resolve(recordType); // Container.Resolve<IRecordInfo>(recordType);
            mEncoding = encoding;

            CreateRecordOptions();
        }
Пример #3
0
        private void CompareRecordInfo(IRecordInfo recordInfo1, IRecordInfo recordInfo2)
        {
            var comp = new CompareObjects();
            comp.CompareChildren = true;
            comp.ElementsToIgnore.Add("Cache");
            comp.ElementsToIgnore.Add("RecordType");
            comp.ElementsToIgnore.Add("FieldTypeInternal");
            comp.ElementsToIgnore.Add("FieldInfo");
            comp.ElementsToIgnore.Add("Operations");

            comp.ElementsToIgnore.Add("FieldType");
            comp.ElementsToIgnore.Add("TypeId");

            comp.CompareFields = true;
            //comp.ComparePrivateFields = true;
            comp.ComparePrivateProperties = true;
            comp.CompareReadOnly = true;

            Check.That(comp.Compare(recordInfo1, recordInfo2)).IsTrue();
        }
Пример #4
0
 /// <summary>
 /// Create a set of operations for a particular type
 /// </summary>
 /// <param name="recordInfo">Record details we create objects off</param>
 public RecordOperations(IRecordInfo recordInfo)
 {
     RecordInfo = recordInfo;
 }
Пример #5
0
        /// <summary>
        /// Converts any collection of records to a DataTable using reflection.
        /// If the number of records is 0 this methods returns an empty
        /// DataTable with the columns based on the fields of the
        /// Type.
        /// </summary>
        /// <param name="records">The records to be converted to a DataTable</param>
        /// <returns>The DataTable containing the records as DataRows</returns>
        /// <param name="maxRecords">The max number of records to add to the DataTable. -1 for all.</param>
        /// <param name="recordType">The type of the inner records.</param>
        public static DataTable RecordsToDataTable(ICollection records, Type recordType, int maxRecords)
        {
            IRecordInfo ri = RecordInfo.Resolve(recordType);

            return(ri.Operations.RecordsToDataTable(records, maxRecords));
        }
 /// <summary>
 /// This class allows you to set some options of the delimited records
 /// at runtime. With options the library is more flexible.
 /// </summary>
 /// <param name="info">Record information</param>
 internal DelimitedRecordOptions(IRecordInfo info)
     : base(info)
 {
 }
Пример #7
0
        internal static RecordOptions CreateRecordOptionsCore(IRecordInfo info)
        {
            RecordOptions options;

            if (info.IsDelimited)
                options = new DelimitedRecordOptions(info);
            else
                options = new FixedRecordOptions(info);

            for (int index = 0; index < options.Fields.Count; index++)
            {
                var field = options.Fields[index];
                field.Parent = options;
                field.ParentIndex = index;
            }

            return options;
        }
Пример #8
0
 /// <summary>
 /// Deep copies content from src instance to this.
 /// <param name="source">Source for copy.</param>
 /// <returns>this.</returns>
 /// </summary>
 public new IntegralDataType CopyFrom(IRecordInfo source)
 {
     return((IntegralDataType)(this.CopyFromImpl(source)));
 }
Пример #9
0
 /// <summary>
 /// Deep copies content from src instance to this.
 /// <param name="source">Source for copy.</param>
 /// <returns>this.</returns>
 /// </summary>
 protected override IRecordInterface CopyFromImpl(IRecordInfo source)
 {
     base.CopyFromImpl(source);
     if (typeof(IRecordClassDescriptorInfo).IsInstanceOfType(source))
     {
         IRecordClassDescriptorInfo typedSource = ((IRecordClassDescriptorInfo)(source));
         if ((typedSource.Parent != null))
         {
             if (((this.Parent == null) ||
                  (this.Parent.GetType() == typedSource.Parent.GetType())))
             {
                 this.Parent = ((RecordClassDescriptor)(typedSource.Parent.Clone()));
             }
             else
             {
                 this.Parent.CopyFrom(typedSource.Parent);
             }
         }
         else
         {
             this.Parent = null;
         }
         if ((typedSource.HasIsAbstract() == true))
         {
             this.IsAbstract = typedSource.IsAbstract;
         }
         else
         {
             this.NullifyIsAbstract();
         }
         if ((typedSource.HasIsContentClass() == true))
         {
             this.IsContentClass = typedSource.IsContentClass;
         }
         else
         {
             this.NullifyIsContentClass();
         }
         if ((typedSource.DataFields != null))
         {
             this.DataFields = new List <IDataFieldInterface>(typedSource.DataFields.Count);
             int i;
             for (i = 0; (i < typedSource.DataFields.Count); i = (i + 1))
             {
                 IDataFieldInfo item = typedSource.DataFields[i];
                 if ((item == null))
                 {
                     this.DataFields.Add(null);
                 }
                 else
                 {
                     this.DataFields.Add(((IDataFieldInterface)(item.Clone())));
                 }
             }
         }
         else
         {
             this.DataFields = null;
         }
     }
     return(this);
 }
 /// <summary>
 /// Indicates that the engine must ignore the lines with this
 /// comment marker.
 /// </summary>
 /// <param name="ri">Record information</param>
 internal IgnoreCommentInfo(IRecordInfo ri)
 {
     mRecordInfo = ri;
 }
 /// <summary>
 /// This class allows you to set some options of the records at runtime.
 /// With these options the library is now more flexible than ever.
 /// </summary>
 /// <param name="info">Record information</param>
 internal RecordOptions(IRecordInfo info)
 {
     mRecordInfo = info;
     mRecordConditionInfo = new RecordConditionInfo(info);
     mIgnoreCommentInfo = new IgnoreCommentInfo(info);
 }
Пример #12
0
 /// <summary>
 /// Indicates that the engine must ignore the lines with this
 /// comment marker.
 /// </summary>
 /// <param name="ri">Record information</param>
 internal IgnoreCommentInfo(IRecordInfo ri)
 {
     mRecordInfo = ri;
 }
 /// <summary>
 /// Creates an instance DataStorage for Type
 /// </summary>
 /// <param name="recordClass">Type of the record object</param>
 protected DataStorage(Type recordClass)
 {
     mRecordType = recordClass;
     mRecordInfo = RecordInfo.Resolve(recordClass);
 }
Пример #14
0
 /// <summary>
 /// This class allows you to set some options of the records at runtime.
 /// With these options the library is now more flexible than ever.
 /// </summary>
 /// <param name="info">Record information</param>
 internal RecordOptions(IRecordInfo info)
 {
     mRecordInfo          = info;
     mRecordConditionInfo = new RecordConditionInfo(info);
     mIgnoreCommentInfo   = new IgnoreCommentInfo(info);
 }
Пример #15
0
 /// <summary>
 /// Used to tell the engine which records must be included or
 /// excluded while reading.
 /// </summary>
 /// <param name="ri">Record information</param>
 internal RecordConditionInfo(IRecordInfo ri)
 {
     mRecordInfo = ri;
 }
Пример #16
0
 /// <summary>
 /// This class allows you to set some options of the fixed length
 /// records but at runtime.
 /// With this options the library is more flexible than never.
 /// </summary>
 /// <param name="info">Record information</param>
 public FixedRecordOptions(IRecordInfo info) : base(info)
 {
 }
Пример #17
0
 /// <summary>
 /// Deep copies content from src instance to this.
 /// <param name="source">Source for copy.</param>
 /// <returns>this.</returns>
 /// </summary>
 public new RecordClassDescriptor CopyFrom(IRecordInfo source)
 {
     return((RecordClassDescriptor)(this.CopyFromImpl(source)));
 }
Пример #18
0
 /// <summary>
 /// Deep copies content from src instance to this.
 /// <param name="source">Source for copy.</param>
 /// <returns>this.</returns>
 /// </summary>
 IRecordClassDescriptorInterface IRecordClassDescriptorInterface.CopyFrom(IRecordInfo source)
 {
     return((IRecordClassDescriptorInterface)(this.CopyFromImpl(source)));
 }
Пример #19
0
 /// <summary>
 /// This class allows you to set some options of the fixed length
 /// records but at runtime.
 /// With this options the library is more flexible than never.
 /// </summary>
 /// <param name="info">Record information</param>
 internal FixedRecordOptions(IRecordInfo info)
     : base(info)
 {
 }
Пример #20
0
 /// <summary>
 /// Create a set of operations for a particular type
 /// </summary>
 /// <param name="recordInfo">Record details we create objects off</param>
 public RecordOperations(IRecordInfo recordInfo)
 {
     RecordInfo = recordInfo;
 }
 /// <summary>
 /// Used to tell the engine which records must be included or
 /// excluded while reading.
 /// </summary>
 /// <param name="ri">Record information</param>
 internal RecordConditionInfo(IRecordInfo ri)
 {
     mRecordInfo = ri;
 }
Пример #22
0
 public int IsMatchingType([In, MarshalAs(UnmanagedType.Interface)] IRecordInfo pRecordInfo)
 {
     throw new NotImplementedException();
 }
Пример #23
0
 internal FixedRecordOptions(IRecordInfo info)
     : base(info)
 {
 }
Пример #24
0
 /// <summary>
 /// Deep copies content from src instance to this.
 /// <param name="source">Source for copy.</param>
 /// <returns>this.</returns>
 /// </summary>
 IIntegralDataTypeInterface IIntegralDataTypeInterface.CopyFrom(IRecordInfo source)
 {
     return((IIntegralDataTypeInterface)(this.CopyFromImpl(source)));
 }