public Column(string name, int width, string format, ShowIn showIn, Func <TResult, object> getterFunc) { Name = name; Width = width; Format = format; GetterFunc = getterFunc; ShowIn = showIn; }
/// <summary> /// Prepares information about individuals columns of the table. /// </summary> private void PrepareColumns() { var type = typeof(TResult); var propertiesWithOrder = new List <Tuple <PropertyInfo, int> >(); // Get properties together with their order foreach (var property in type.GetProperties()) { // Skip properties that should not be shown if (property.GetCustomAttribute <ShowAttribute>()?.Type == ShowIn.None) { continue; } var orderAttribute = property.GetCustomAttribute <OrderAttribute>(); var order = orderAttribute?.Order ?? int.MaxValue; propertiesWithOrder.Add(Tuple.Create(property, order)); } // Sort properties by their order propertiesWithOrder.Sort((p1, p2) => p1.Item2.CompareTo(p2.Item2)); defaultLength = typeof(TResult).GetCustomAttribute <LengthAttribute>()?.Length ?? 20; defaultFormat = typeof(TResult).GetCustomAttribute <ValueFormatAttribute>()?.Format; defaultShow = typeof(TResult).GetCustomAttribute <ShowAttribute>()?.Type ?? ShowIn.All; // Use reflection to call the CreateColumn generic method. // This is done to get into a strongly-typed context and make the code simpler. var createColumnMethod = GetType().GetMethod(nameof(CreateColumn), BindingFlags.NonPublic | BindingFlags.Instance); foreach (var propertyTuple in propertiesWithOrder) { var property = propertyTuple.Item1; var createColumnGeneric = createColumnMethod.MakeGenericMethod(property.PropertyType); var column = (Column)createColumnGeneric.Invoke(this, new object[] { property }); columns.Add(column); } }
/// <summary> /// Specifies where the icon of the button will be displayed. Applicable only for the children of a ButtonGroup. /// </summary> /// <param name="value">The value that configures the showicon.</param> public ToolBarItemButtonBuilder ShowIcon(ShowIn value) { container.ShowIcon = value; return this; }
/// <summary> /// Specifies where the text will be displayed. /// </summary> /// <param name="value">The value that configures the showtext.</param> public ToolBarItemBuilder ShowText(ShowIn value) { container.ShowText = value; return this; }
/// <summary> /// /// </summary> /// <param name="type">Where should be the column shown.</param> public ShowAttribute(ShowIn type) { Type = type; }