コード例 #1
0
ファイル: EnumPropertyEditor.cs プロジェクト: noxe/eXpand
        public WebFilterableEnumPropertyEditor(Type objectType, IModelMemberViewItem model)
            : base(objectType, model) {
            PropertyInfo propertyInfo = ObjectType.GetProperty(PropertyName);
            if (propertyInfo != null) {
                _propertyType = propertyInfo.PropertyType;
                foreach (object item in propertyInfo.GetCustomAttributes(false)) {
                    var propAttr = item as DataSourcePropertyAttribute;
                    if (propAttr != null && !string.IsNullOrEmpty(propAttr.DataSourceProperty)) {
                        PropertyInfo dataSourceProperty = ObjectType.GetProperty(propAttr.DataSourceProperty);
                        _isNullMode = propAttr.DataSourcePropertyIsNullMode;
                        _isNullCriteria = propAttr.DataSourcePropertyIsNullCriteria;
                        if (dataSourceProperty != null) {
                            if (typeof(IEnumerable).IsAssignableFrom(dataSourceProperty.PropertyType) &&
                                dataSourceProperty.PropertyType.IsGenericType &&
                                dataSourceProperty.PropertyType.GetGenericArguments()[0].IsAssignableFrom(
                                    propertyInfo.PropertyType))
                                _dataSourceProperty = dataSourceProperty;
                        }
                    }

                    var criteriaAttr = item as DataSourceCriteriaAttribute;
                    if (criteriaAttr != null)
                        _isNullCriteria = criteriaAttr.DataSourceCriteria;
                }
            }
        }
コード例 #2
0
ファイル: EnumPropertyEditor.cs プロジェクト: xwagner2/eXpand
        public WebFilterableEnumPropertyEditor(Type objectType, IModelMemberViewItem model)
            : base(objectType, model)
        {
            PropertyInfo propertyInfo = ObjectType.GetProperty(PropertyName);

            if (propertyInfo != null)
            {
                _propertyType = propertyInfo.PropertyType;
                foreach (object item in propertyInfo.GetCustomAttributes(false))
                {
                    var propAttr = item as DataSourcePropertyAttribute;
                    if (propAttr != null && !string.IsNullOrEmpty(propAttr.DataSourceProperty))
                    {
                        PropertyInfo dataSourceProperty = ObjectType.GetProperty(propAttr.DataSourceProperty);
                        _isNullMode     = propAttr.DataSourcePropertyIsNullMode;
                        _isNullCriteria = propAttr.DataSourcePropertyIsNullCriteria;
                        if (dataSourceProperty != null)
                        {
                            if (typeof(IEnumerable).IsAssignableFrom(dataSourceProperty.PropertyType) &&
                                dataSourceProperty.PropertyType.IsGenericType &&
                                dataSourceProperty.PropertyType.GetGenericArguments()[0].IsAssignableFrom(
                                    propertyInfo.PropertyType))
                            {
                                _dataSourceProperty = dataSourceProperty;
                            }
                        }
                    }

                    var criteriaAttr = item as DataSourceCriteriaAttribute;
                    if (criteriaAttr != null)
                    {
                        _isNullCriteria = criteriaAttr.DataSourceCriteria;
                    }
                }
            }
        }
コード例 #3
0
        public static PropertyBuilder <TType, T> UsingDataSourceProperty <TType, T>(this PropertyBuilder <TType, T> builder, string datasourceProperty, DataSourcePropertyIsNullMode nullMode = DataSourcePropertyIsNullMode.SelectNothing, CriteriaOperator isNullCriteria = null) where TType : class
        {
            var crit = ReferenceEquals(isNullCriteria, null) ? string.Empty : isNullCriteria.ToString();

            return(builder.WithAttribute(new DataSourcePropertyAttribute(datasourceProperty, nullMode, crit)));
        }
コード例 #4
0
 public static PropertyBuilder <TType, T> UsingDataSourceProperty <TType, T, TProp>(this PropertyBuilder <TType, T> builder, Expression <Func <T, TProp> > datasourceProperty, DataSourcePropertyIsNullMode nullMode = DataSourcePropertyIsNullMode.SelectNothing, CriteriaOperator isNullCriteria = null)
     where TType : class
     where T : class
 {
     return(builder.UsingDataSourceProperty(builder._Fields.GetPropertyName(datasourceProperty), nullMode, isNullCriteria));
 }