protected override void OnActivated() { base.OnActivated(); if (LogicRuleManager.HasRules(View.ObjectTypeInfo)) { View.SelectionChanged += ViewOnSelectionChanged; View.CurrentObjectChanged += ViewOnCurrentObjectChanged; View.QueryCanChangeCurrentObject += ViewOnQueryCanChangeCurrentObject; ObjectSpace.ObjectChanged += ObjectSpaceOnObjectChanged; ObjectSpace.Committed += ObjectSpaceOnCommitted; ObjectSpace.Refreshing += ObjectSpace_Refreshing; ObjectSpace.Reloaded += ObjectSpace_Reloaded; Frame.TemplateViewChanged += FrameOnTemplateViewChanged; _logicRuleExecutor.Execute(ExecutionContext.ControllerActivated, EventArgs.Empty, View); if (View is ListView) { Frame.GetController <ListViewProcessCurrentObjectController>(controller => { controller.CustomProcessSelectedItem += OnCustomProcessSelectedItem; controller.CustomizeShowViewParameters += CustomizeShowViewParameters; }); } } }
protected override void OnDeactivated() { base.OnDeactivated(); if (LogicRuleManager.HasActionContextRules(View.ObjectTypeInfo)) { UnsubscribeFromActionEvents(); } if (LogicRuleManager.HasRules(View.ObjectTypeInfo)) { _logicRuleExecutor.Execute(ExecutionContext.ControllerDeActivated, EventArgs.Empty, View); View.SelectionChanged -= ViewOnSelectionChanged; View.CurrentObjectChanged -= ViewOnCurrentObjectChanged; View.QueryCanChangeCurrentObject -= ViewOnQueryCanChangeCurrentObject; if (ObjectSpace != null) { ObjectSpace.ObjectChanged -= ObjectSpaceOnObjectChanged; ObjectSpace.Refreshing -= ObjectSpace_Refreshing; ObjectSpace.Reloaded -= ObjectSpace_Reloaded; ObjectSpace.Committed -= ObjectSpaceOnCommitted; } Frame.TemplateViewChanged -= FrameOnTemplateViewChanged; if (View is ListView) { Frame.GetController <ListViewProcessCurrentObjectController>(controller => { controller.CustomProcessSelectedItem -= OnCustomProcessSelectedItem; controller.CustomizeShowViewParameters -= CustomizeShowViewParameters; }); } } }
protected override void OnViewControllersActivated() { base.OnViewControllersActivated(); if (LogicRuleManager.HasActionContextRules(View.ObjectTypeInfo)) { SubscribeToActionEvents(); } }
void ForceExecutioning(View view, ExecutionContext executionContext) { if (View != null) { InvertExecution(View, executionContext); } Active[ActiveObjectTypeHasRules] = LogicRuleManager <TModelLogicRule> .HasRules(view); ForceExecution(Active[ActiveObjectTypeHasRules] && view != null && view.ObjectTypeInfo != null, view, false, executionContext); }
void FrameOnTemplateChanged(object sender, EventArgs eventArgs) { var supportViewChanged = (Frame.Template) as ISupportViewChanged; if (supportViewChanged != null) { supportViewChanged.ViewChanged += (o, args) => { Active[ActiveObjectTypeHasRules] = LogicRuleManager <TModelLogicRule> .HasRules(args.View); ForceExecution(ExecutionContext.ViewChanged, args.View); } } ; }
void ApplicationOnViewCreating(object sender, ViewCreatingEventArgs viewCreatingEventArgs) { if (Application != null) { var modelObjectView = Application.Model.Views.Single(modelView => modelView.Id == viewCreatingEventArgs.ViewID).AsObjectView; if (modelObjectView != null) { var typeInfo = modelObjectView.ModelClass.TypeInfo; Active[ActiveObjectTypeHasRules] = LogicRuleManager <TModelLogicRule> .HasRules(typeInfo); ForceExecution(Active[ActiveObjectTypeHasRules], null, false, ExecutionContext.ViewCreating); } } }
public bool HasRules(View view) { return(LogicRuleManager <TLogicRule> .HasRules(view)); }
void ForceExecution(ActionBaseEventArgs args) { Active[ActiveObjectTypeHasRules] = LogicRuleManager <TModelLogicRule> .HasRules(args.ShowViewParameters.CreatedView.ObjectTypeInfo); ForceExecution(IsReady, args.ShowViewParameters.CreatedView, false, ExecutionContext.None, args.ShowViewParameters.CreatedView.CurrentObject, args.Action); }