Esempio n. 1
0
        /// <summary>
        /// Creates an empty record of <code>type</code> and <code>subtype</code> specified by <code>header</code>.
        /// </summary>
        /// <param name="header">The header of the record.</param>
        /// <returns>A record of type and subtype.</returns>
        /// <exception cref="InvalidOperationException">If the type has no public constructor and hence no instance can be created.</exception>
        /// <exception cref="StdfException">If the record instance cannot be created.</exception>
        /// <exception cref="RecordNotFoundException">If the record with specified header does not exist.</exception>
        internal StdfRecord CreateRecord(StdfHeader header)
        {
            StdfRecord record = CreateRecord(header.Type, header.Subtype);

            record.Length = header.Lenght;
            return(record);
        }
Esempio n. 2
0
        public static IList <Type> GetIFieldTypes(StdfRecord record)
        {
            FieldInfo[]  fields    = record.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            IList <Type> fieldList = new List <Type>();

            foreach (FieldInfo info in fields)
            {
                Type[]       interfacesTypes = info.FieldType.GetInterfaces();
                IList <Type> interfacesList  = new List <Type>(interfacesTypes);
                if (interfacesList.Contains(typeof(IField)))
                {
                    fieldList.Add(info.FieldType);
                }
            }
            return(fieldList);
        }
Esempio n. 3
0
 private static void RegisterRecords(Type[] types, StringBuilder s)
 {
     foreach (Type type in types)
     {
         if (type.IsSubclassOf(typeof(StdfRecord)) && (!type.IsAbstract))
         {
             StdfRecordAttribute attribute = StdfRecord.GetStdfRecordAttribute(type);
             if (attribute == null)
             {
                 if (s.Length > 0)
                 {
                     s.Append(", ");
                 }
                 s.Append(type.Name);
                 continue;
             }
             Instance.RegisterRecord(attribute.Type, attribute.Subtype, type);
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Creates a STDF record instance of the specified <code>type</code> and <code>subtype</code>.
        /// </summary>
        /// <param name="type">The type of record to create.</param>
        /// <param name="subtype">The subtype of record to create.</param>
        /// <returns>A record of specified type and subtype.</returns>
        /// <exception cref="RecordNotFoundException">If the record was not found.</exception>
        /// <exception cref="StdfException">If the record cannot be created.</exception>
        public StdfRecord CreateRecord(byte type, byte subtype)
        {
            Dictionary <byte, StdfRecord> dict = null;

            if (recordsBuffer.TryGetValue(type, out dict))
            {
                StdfRecord bufRecord;
                if (dict.TryGetValue(subtype, out bufRecord))
                {
                    bufRecord.Clear();
                    return(bufRecord);
                }
            }
            StdfRecord record = factory.CreateRecord(type, subtype);

            if (dict == null)
            {
                dict = new Dictionary <byte, StdfRecord>();
                recordsBuffer.Add(type, dict);
            }
            dict.Add(subtype, record);
            return(record);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a STDF record instance of the specified <code>Type</code>.
        /// </summary>
        /// <param name="recordType">
        /// A <see cref="Type"/> which represents the type of <code>StdfRecord</code>.
        /// </param>
        /// <returns>
        /// A <see cref="StdfRecord"/> which represents the instance of the record.
        /// </returns>
        public StdfRecord CreateRecord(Type recordType)
        {
            StdfRecordAttribute attribute = StdfRecord.GetStdfRecordAttribute(recordType);

            return(CreateRecord(attribute.Type, attribute.Subtype));
        }