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); }
protected void _OnNavigating(object entity) { if (Navigating != null) { Navigating(entity); } else { var options = new NavigateOptions(); bool isReadOnly = (ReadonlyEntity ?? Common.GetIsReadOnly(this)); if (isReadOnly) { options.ReadOnly = isReadOnly; } Navigator.NavigateUntyped(entity, options); } }
public static void Navigate <T>(T entity, NavigateOptions options = null) where T : IEntity { Manager.Navigate(entity, options ?? new NavigateOptions()); }
public static void NavigateUntyped(object entity, NavigateOptions options = null) { Manager.Navigate(entity, options ?? new NavigateOptions()); }
protected void _OnNavigating(object entity) { if (Navigating != null) Navigating(entity); else { var options = new NavigateOptions(); bool isReadOnly = (ReadonlyEntity ?? Common.GetIsReadOnly(this)); if (isReadOnly) options.ReadOnly = isReadOnly; Navigator.NavigateUntyped(entity, options); } }