/// <summary> /// Initializes a new instance of the <see cref="ReportData"/> class. /// </summary> /// <param name="property">The property.</param> /// <param name="ancestor">The ancestor.</param> /// <param name="attributes">The attributes.</param> /// <param name="report">The report.</param> public ReportData(PropertyInfo property, IInfoClass ancestor, FieldParametres attributes, Report report) { PropertyType = property.PropertyType; PropertyValue = GetValue(property, ancestor); PropertyAttributes = attributes; CurrentReport = report; Width = GetWidth(); Height = GetHeight(); }
/// <summary> /// Gets the field attributes. /// </summary> /// <param name="properties">The properties.</param> /// <returns>Dictionary{PropertyInfoFieldParametres}.</returns> private Dictionary<PropertyInfo, FieldParametres> GetFieldAttributes(IEnumerable<PropertyInfo> properties) { var dict = new Dictionary<PropertyInfo, FieldParametres>(); foreach (var propertyInfo in properties) { var attributes = propertyInfo.GetCustomAttributes(false); var parametres = new FieldParametres(); foreach (var attribute in attributes) { if (attribute is CommonSettingsAttribute) { var attr = attribute as CommonSettingsAttribute; parametres.SectionName = attr.Section; parametres.FieldPosition = attr.Position; parametres.WidthPercentage = attr.Width / 100; } else if (attribute is FieldTypeAttribute) { parametres.FieldType = (FieldTypeAttribute)attribute; } else if (attribute is DisplayAttribute) { var attr = attribute as DisplayAttribute; parametres.DisplayName = attr.GetName(); } else if (attribute is FieldEditorAttribute) { var attr = attribute as FieldEditorAttribute; parametres.FieldEditor = attr.DataType; } else if (attribute is CrossRefFieldAttribute) { var attr = attribute as CrossRefFieldAttribute; if (attr.AllowMultiple) { parametres.IsMultiCrossRef = true; } else { parametres.IsSingleCrossRef = true; parametres.DisplayFieldList.Add(attr.RefFieldName); } parametres.CrossRefProcessName = attr.ReferenceTableName; } else if (attribute is ReverseCrossRefFieldAttribute) { var attr = attribute as ReverseCrossRefFieldAttribute; parametres.IsReverseCrossRef = !attr.DisplayMultiple; parametres.IsMultiReverseCrossRef = attr.DisplayMultiple; } else if (attribute is PictureOptionsAttribute) { var attr = attribute as PictureOptionsAttribute; parametres.ImageFieldSize = new PictureOptionsAttribute(attr.SearchWidth, attr.SearchHeight, attr.DetailsWidth, attr.DetailsHeight, false); } else if (attribute is UndefinedLabelAttribute) { parametres.UndefinedLabel = (UndefinedLabelAttribute)attribute; } else if (attribute is IsSwitchToggleAttribute) { parametres.IsSwitchToggle = (IsSwitchToggleAttribute)attribute; } else if (attribute is TrueLabelAttribute) { parametres.TrueLabel = (TrueLabelAttribute)attribute; } else if (attribute is FalseLabelAttribute) { parametres.FalseLabel = (FalseLabelAttribute)attribute; } else if (attribute is DateTimeFormatAttribute) { parametres.DateTimeFormat = (DateTimeFormatAttribute)attribute; } else if (attribute is NumericAttribute) { parametres.Numeric = (NumericAttribute)attribute; } else if (attribute is DisplayListFieldAttribute) { parametres.DisplayListField = (DisplayListFieldAttribute)attribute; } } dict.Add(propertyInfo, parametres); } return dict; }