Example #1
0
        private static bool Resolve(IColumnCreationInterceptorContext context, ref string path)
        {
            var newItem = Activator.CreateInstance(context.Property.PropertyType);

            if (string.Equals(newItem.ToString(), context.Property.PropertyType.ToString(),
                              StringComparison.OrdinalIgnoreCase))
            {
                if (context.Property.GetCustomAttribute <SelectFromAttribute>() is SelectFromAttribute
                    selectFromAttribute && !string.IsNullOrEmpty(selectFromAttribute.DisplayPath))
                {
                    path =
                        $"{context.Property.Name}.{context.Property.PropertyType.GetProperty(selectFromAttribute.DisplayPath)?.Name}";
                }
                else if (context.Property.GetCustomAttribute <DisplayNameAttribute>() is DisplayNameAttribute
                         displayNameAttribute && !string.IsNullOrEmpty(displayNameAttribute.DisplayName))
                {
                    path =
                        $"{context.Property.Name}.{context.Property.PropertyType.GetProperty(displayNameAttribute.DisplayName)?.Name}";
                }
        public DataGridColumn GetColumn(PropertyInfo propertyInfo, DynamicDataGrid dataGrid)
        {
            IColumnCreationInterceptorContext column = null;

            foreach (var columnCreationInterceptor in dataGrid.ColumnCreationInterceptors)
            {
                var interceptorContext = columnCreationInterceptor.Intercept(
                    new ColumnCreationInterceptorContext(propertyInfo, dataGrid, dataGrid.ItemType, null));

                if (interceptorContext == null)
                {
                    return(null);
                }

                column = interceptorContext;
            }

            return(column?.Column);
        }