Exemple #1
0
        public Type SelectType(Func <Type, bool> filterType)
        {
            if (CleanType.IsEmbeddedEntity())
            {
                return(CleanType);
            }

            if (Implementations.Value.IsByAll)
            {
                throw new InvalidOperationException("ImplementedByAll is not supported for this operation, override the event");
            }

            return(Navigator.SelectType(Window.GetWindow(this), Implementations.Value.Types, filterType));
        }
Exemple #2
0
        private object _OnViewing(object entity, bool creating)
        {
            if (Viewing != null)
            {
                return(Viewing(entity));
            }

            var options = new ViewOptions
            {
                PropertyRoute = CleanType.IsEmbeddedEntity() ? GetEntityPropertyRoute() : null,
            };

            bool isReadOnly = (ReadonlyEntity ?? Common.GetIsReadOnly(this)) && !creating;

            if (isReadOnly)
            {
                options.ReadOnly = isReadOnly;
            }

            return(Navigator.ViewUntyped(entity, options));
        }
Exemple #3
0
        public override void OnLoad(object sender, RoutedEventArgs e)
        {
            base.OnLoad(sender, e);

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            if (this.NotSet(EntityBase.EntityTemplateProperty) && this.NotSet(EntityBase.EntityTemplateSelectorProperty))
            {
                var type = Type;

                if (this is EntityCombo && !type.IsLite()) //Allways going to be lite
                {
                    type = Lite.Generate(type);
                }

                EntityTemplate = Navigator.FindDataTemplate(this, type);
            }

            if (this.NotSet(EntityBase.ImplementationsProperty) && CleanType.IsEntity() && !CleanType.IsAbstract)
            {
                Implementations = Signum.Entities.Implementations.By(CleanType);
            }

            if (this.NotSet(EntityBase.CreateProperty) && Create)
            {
                Create =
                    CleanType.IsEmbeddedEntity() ? Navigator.IsCreable(CleanType) :
                    Implementations.Value.IsByAll ? false:
                    Implementations.Value.Types.Any(t => Navigator.IsCreable(t, isSearch: false));
            }

            if (this.NotSet(EntityBase.ViewProperty) && View)
            {
                View = CleanType.IsEmbeddedEntity() ? Navigator.IsViewable(CleanType) :
                       Implementations.Value.IsByAll ? true :
                       Implementations.Value.Types.Any(t => Navigator.IsViewable(t));
            }

            if (this.NotSet(EntityBase.NavigateProperty) && Navigate)
            {
                Navigate = CleanType.IsEmbeddedEntity() ? Navigator.IsNavigable(CleanType, isSearch: false) :
                           Implementations.Value.IsByAll ? true :
                           Implementations.Value.Types.Any(t => Navigator.IsNavigable(t, isSearch: false));
            }

            if (this.NotSet(EntityBase.FindProperty) && Find)
            {
                Find = CleanType.IsEmbeddedEntity() ? false:
                       Implementations.Value.IsByAll ? false :
                       Implementations.Value.Types.Any(t => Finder.IsFindable(t));
            }

            if (this.NotSet(EntityBase.ViewOnCreateProperty) && ViewOnCreate && !View)
            {
                ViewOnCreate = false;
            }

            UpdateVisibility();
        }