private static IEnumerable <MemberDefinition> GetKeyMembers() { IReadOnlyList <ColumnSelection> effectiveColumns = typeof(TUnwrappedView).GetColumnSelections(); // // Vesszuk az eredeti nezet NEM lista tulajdonsagait // foreach (ColumnSelection column in typeof(TView).GetColumnSelections()) { // // Ha kicsomagolas soran a tulajdonsag at lett nevezve, akkor azt hasznaljuk. // ColumnSelection effectiveColumn = effectiveColumns.SingleOrDefault(ec => ec.ViewProperty.IsRedirectedTo(column.ViewProperty)) ?? effectiveColumns.Single(ec => ec.ViewProperty.CanBeMappedIn(column.ViewProperty)); yield return(new MemberDefinition ( effectiveColumn.ViewProperty.Name, effectiveColumn.ViewProperty.PropertyType, effectiveColumn.ViewProperty .GetCustomAttributes() .OfType <IBuildableAttribute>() .Select(attr => CustomAttributeBuilderFactory.CreateFrom(attr)) .ToArray() )); } }
private static IEnumerable <MemberDefinition> GetMembers() { foreach (IGrouping <string, ColumnSelection> grp in typeof(TView).GetColumnSelectionsDeep().GroupBy(sel => sel.ViewProperty.Name)) { if (grp.Count() == 1) { // // Ha a property csak egyszer szerepel a kicsomagolt nezetben akkor nem kell modositani a nevet // ColumnSelection sel = grp.Single(); yield return(new MemberDefinition ( grp.Key, sel.ViewProperty.PropertyType, CustomAttributeBuilderFactory.CreateFrom(sel.Reason) )); } else { // // Kulonben egyedive kell tenni a tulajdonsag nevet, valamint jelezni kell (MapToAttribute) h mely nezet-tulajdonsaghoz tartozik // int i = 0; foreach (ColumnSelection sel in grp) { // // [BelongsTo(typeof(TTable), column: "Column", ...), MapTo("TView.Column")] // public TValue Column_i {get; set;} // yield return(new MemberDefinition ( $"{grp.Key}_{i++}", sel.ViewProperty.PropertyType, CustomAttributeBuilderFactory.CreateFrom ( sel.Reason, // // A "Column" tulajdonsagot meg ha az eredeti nezet nem is tartalmazta most be kell allitsuk // (mivel a tulajdonsag uj nevet kapott) // new KeyValuePair <PropertyInfo, object> ( typeof(ColumnSelectionAttribute).GetProperty(nameof(ColumnSelectionAttribute.Column)), grp.Key ) ), // // Mappolaskor az eredeti tulajdonsagba kerul vissza a tartalom // CustomAttributeBuilderFactory.CreateFrom <MapToAttribute>(new[] { typeof(string) }, new object[] { sel.ViewProperty.FullName() }) )); } } } }