Exemple #1
0
        //Create corresponding views in the application model first! See the Model.DesignedDiffs.XAFML file for an example.
        void Application_ViewCreating(object sender, ViewCreatingEventArgs e)
        {
            string roleBasedViewId = String.Format("{0}_{1}", e.ViewID, ((ISecurityUserWithRoles)SecuritySystem.CurrentUser).IsUserInRole(AdministratorsViewSuffix) ? AdministratorsViewSuffix : UsersViewSuffix);

            if (Application.FindModelView(roleBasedViewId) != null)
            {
                e.ViewID = roleBasedViewId;
            }
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
        private void ApplicationOnViewCreating(object sender, ViewCreatingEventArgs e)
        {
            var detailView = Application.Model.Views[e.ViewID] as IModelDetailView;

            if (detailView != null)
            {
                var modelNodeAttributeValueItems = detailView.Items.OfType <IModelNodeAttributeValue>().SelectMany(item => item.AttributeValueItems);
                _models = modelNodeAttributeValueItems.Where(item => ValidByCriteria(item.Criteria, ((DetailViewCreatingEventArgs)e).Obj)).ToArray();
                foreach (var item in _models)
                {
                    var modelNode           = ((ModelNode)item);
                    var modelPropertyEditor = modelNode.GetParent <IModelPropertyEditor>();
                    var propertyType        = ((ModelNode)modelPropertyEditor).NodeInfo.GetValueInfo(item.Attribute).PropertyType;
                    item.CurrentAttributeValue = new CurrentAttributeValue(modelNode.Parent.Parent.GetValue(item.Attribute));
                    modelPropertyEditor.SetValue(item.Attribute, propertyType, item.Value.Change(propertyType));
                }
            }
        }