コード例 #1
0
        public HistoryExportModel()
        {
            this.ExportableProperties = HistoryExportAllFields.GetExportableProperties();

            this.Presets = new List <Preset>();

            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.BirthDate),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.OtherDob)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.NationalId),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.NationalType)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.OtherNationalId),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.OtherNationalIdType)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.Address),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.City),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.StateCode),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.Zip)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.DeceasedDate)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.FirstName),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.MiddleName),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.LastName),
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.PrevFirstName),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.PrevLastName),
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.OtherFirstName),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.OtherLastName)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.IsCeefRecipient),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.CeefId)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.AddCompName),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.AddCompId)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.InternalId)
            });
            this.AddPreset(new[] {
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.LeaveDate),
                ReflectionExtensions.GetPropertyInfo((HistoryExportAllFields f) => f.LeaveReason)
            });
        }
コード例 #2
0
        private void AddPreset(IEnumerable <PropertyInfo> propNames, string Display = null)
        {
            var pds = from a in propNames
                      join b in HistoryExportAllFields.GetExportableProperties() on a.Name equals b.Name
                      select b;

            this.Presets.Add(new Preset
            {
                i       = this.Presets.Count,
                value   = string.Join(",", pds.Select(f => f.Name)),
                display = Display ?? string.Join(", ", pds.Select(f =>
                                                                  f.GetCustomAttributes(typeof(CsvFieldAttribute), false).Cast <CsvFieldAttribute>().Select(a => a.Name).SingleOrDefault() ?? f.Name))
            });
        }