コード例 #1
0
        internal protected virtual bool OnIsNavigable(Type type, IEntity entity, bool isSearchEntity)
        {
            EntitySettings es = EntitySettings.TryGetC(type);

            return
                (es != null &&
                 es.HasView() &&
                 IsViewableBase(type, (ModifiableEntity)entity) &&
                 es.OnIsNavigable(isSearchEntity));
        }
コード例 #2
0
        public virtual void Navigate(object entityOrLite, NavigateOptions options)
        {
            if (entityOrLite == null)
            {
                throw new ArgumentNullException("entity");
            }

            Type type = entityOrLite is Lite <Entity>?((Lite <Entity>)entityOrLite).EntityType : entityOrLite.GetType();

            OpenIndependentWindow(() =>
            {
                NormalWindow win = CreateNormalWindow();
                win.SetTitleText(NormalWindowMessage.Loading0.NiceToString().FormatWith(type.NiceName()));
                return(win);
            },
                                  afterShown: win =>
            {
                try
                {
                    ModifiableEntity entity = entityOrLite as ModifiableEntity;
                    if (entity == null)
                    {
                        Lite <Entity> lite = (Lite <Entity>)entityOrLite;
                        entity             = lite.EntityOrNull ?? Server.RetrieveAndForget(lite);
                    }

                    EntitySettings es = AssertViewableEntitySettings(entity);
                    if (!es.OnIsNavigable(true))
                    {
                        throw new Exception("{0} is not navigable".FormatWith(entity));
                    }

                    if (entity is EmbeddedEntity)
                    {
                        throw new InvalidOperationException("ViewSave is not allowed for EmbeddedEntities");
                    }

                    Control ctrl = options.View != null ? options.View() : es.CreateView(entity, null);
                    ctrl         = es.OnOverrideView(entity, ctrl);


                    SetNormalWindowEntity(win, (ModifiableEntity)entity, options, es, ctrl);
                }
                catch
                {
                    win.Close();
                    throw;
                }
            },
                                  closed: options.Closed);
        }