상속: EntityBase
예제 #1
0
        static void TaskSetNullValueEntityCombo(FrameworkElement fe, string route, PropertyRoute context)
        {
            EntityCombo ec = fe as EntityCombo;

            if (ec != null && ec.NotSet(EntityCombo.NullValueProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
            {
                if (Validator.TryGetPropertyValidator(context).Let(pv => pv != null && pv.Validators.OfType <NotNullValidatorAttribute>().Any()))
                {
                    ec.NullValue = false;
                }
            }
        }
예제 #2
0
        public static Control GetValueControl(QueryToken token, string bindingPath)
        {
            Type type = token.Type;

            if (type.IsLite())
            {
                Implementations implementations = token.GetImplementations().Value;

                Type cleanType = Lite.Extract(type);

                if (EntityKindCache.IsLowPopulation(cleanType) && !implementations.IsByAll)
                {
                    EntityCombo ec = new EntityCombo
                    {
                        Type            = type,
                        Implementations = implementations,
                    };

                    ec.SetBinding(EntityCombo.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors   = true,
                        ValidatesOnExceptions   = true,
                    });

                    return(ec);
                }
                else
                {
                    EntityLine el = new EntityLine
                    {
                        Type            = type,
                        Create          = false,
                        Implementations = implementations,
                    };

                    el.SetBinding(EntityLine.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors   = true,
                        ValidatesOnExceptions   = true
                    });

                    return(el);
                }
            }
            else if (type.IsEmbeddedEntity())
            {
                EntityLine el = new EntityLine
                {
                    Type            = type,
                    Create          = false,
                    Autocomplete    = false,
                    Find            = false,
                    Implementations = null,
                };

                el.SetBinding(EntityLine.EntityProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath),
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors   = true,
                    ValidatesOnExceptions   = true
                });

                return(el);
            }
            else
            {
                ValueLine vl = new ValueLine()
                {
                    Type     = type,
                    Format   = token.Format,
                    UnitText = token.Unit,
                };

                if (type.UnNullify().IsEnum)
                {
                    vl.ItemSource = EnumEntity.GetValues(type.UnNullify()).PreAndNull(type.IsNullable()).ToObservableCollection();
                }

                vl.SetBinding(ValueLine.ValueProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath), //odd
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors   = true,
                    ValidatesOnExceptions   = true,
                    Converter = Reflector.IsNumber(type) ? Converters.Identity : null,
                });

                return(vl);
            }
        }
예제 #3
0
        public static Control GetValueControl(QueryToken token, string bindingPath)
        {
            Type type = token.Type;
            if (type.IsLite())
            {
                Implementations implementations = token.GetImplementations().Value;

                Type cleanType = Lite.Extract(type);

                if (EntityKindCache.IsLowPopulation(cleanType) && !implementations.IsByAll)
                {
                    EntityCombo ec = new EntityCombo
                    {
                        Type = type,
                        Implementations = implementations,
                    };

                    ec.SetBinding(EntityCombo.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors = true,
                        ValidatesOnExceptions = true,
                    });

                    return ec;
                }
                else
                {
                    EntityLine el = new EntityLine
                    {
                        Type = type,
                        Create = false,
                        Implementations = implementations,
                    };

                    el.SetBinding(EntityLine.EntityProperty, new Binding
                    {
                        Path = new PropertyPath(bindingPath),
                        NotifyOnValidationError = true,
                        ValidatesOnDataErrors = true,
                        ValidatesOnExceptions = true
                    });

                    return el;
                }
            }
            else if (type.IsEmbeddedEntity())
            {
                EntityLine el = new EntityLine
                {
                    Type = type,
                    Create = false,
                    Autocomplete = false,
                    Find = false,
                    Implementations = null,
                };

                el.SetBinding(EntityLine.EntityProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath),
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors = true,
                    ValidatesOnExceptions = true
                });

                return el;
            }
            else
            {
                ValueLine vl = new ValueLine()
                {
                    Type = type,
                    Format = token.Format,
                    UnitText = token.Unit,
                };

                if (type.UnNullify().IsEnum)
                {
                    vl.ItemSource = EnumEntity.GetValues(type.UnNullify()).PreAndNull(type.IsNullable()).ToObservableCollection();
                }

                vl.SetBinding(ValueLine.ValueProperty, new Binding
                {
                    Path = new PropertyPath(bindingPath), //odd
                    NotifyOnValidationError = true,
                    ValidatesOnDataErrors = true,
                    ValidatesOnExceptions = true,
                    Converter = Reflector.IsNumber(type) ? Converters.Identity : null,
                });

                return vl;
            }
        }