Пример #1
0
        private void DiscoverRecordFields(Type recordType, bool clear = true)
        {
            if (clear)
            {
                //SupportsMultiRecordTypes = false;
                FixedLengthRecordFieldConfigurations.Clear();
            }
            //else
            //    SupportsMultiRecordTypes = true;

            DiscoverRecordFields(recordType, null,
                                 ChoTypeDescriptor.GetProperties(recordType).Where(pd => pd.Attributes.OfType <ChoFixedLengthRecordFieldAttribute>().Any()).Any());
        }
        private void DiscoverRecordFields(Type recordType)
        {
            if (!IsDynamicObject)
            {
                FixedLengthRecordFieldConfigurations.Clear();

                foreach (PropertyDescriptor pd in ChoTypeDescriptor.GetProperties(recordType).Where(pd => pd.Attributes.OfType <ChoFixedLengthRecordFieldAttribute>().Any()))
                {
                    //if (!pd.PropertyType.IsSimple())
                    //    throw new ChoRecordConfigurationException("Property '{0}' is not a simple type.".FormatString(pd.Name));
                    var obj = new ChoFixedLengthRecordFieldConfiguration(pd.Name, pd.Attributes.OfType <ChoFixedLengthRecordFieldAttribute>().First());
                    obj.FieldType = pd.PropertyType;
                    FixedLengthRecordFieldConfigurations.Add(obj);
                }
            }
        }
 public ChoFixedLengthRecordConfiguration ClearFields()
 {
     //FixedLengthRecordFieldConfigurationsForType.Clear();
     FixedLengthRecordFieldConfigurations.Clear();
     return(this);
 }