Monday, March 22, 2010

The ModelArtifactState Module

This one is the most complex implementation of the logic architecture cause this module is really a facade module. ActionState and ControllerState modules are hosted within it. But the implementation for each one of them as you see in the image bellow really looks alike

image  

image

In order to control the different in model schema than the one that is provided bu defaul I have override the require methods of ControllerStateModule

public class ControllerStateModule :ConditionalLogicRuleProviderModuleBase<TArtifactStateRule> where TArtifactStateRule : IConditionalLogicRule {

        public override string LogicRulesNodeAttributeName {

            get { return ControllerStateRulesNodeWrapper.NodeNameAttribute; }

        }

 

        public override string RootNodePath {

            get { return ModelArtifactStateModule.ModelArtifactStateAttributeName; }

        }

        protected override System.Collections.Generic.IEnumerable<IControllerStateRule> CollectRulesFromModelCore(LogicRulesNodeWrapper<IControllerStateRule> wrapper, DevExpress.ExpressApp.DC.ITypeInfo typeInfo) {

            var collectRulesFromModelCore = base.CollectRulesFromModelCore(wrapper, typeInfo).ToList();

            foreach (ControllerStateRule controllerStateRule in collectRulesFromModelCore) {

                var controllerType = ((IControllerStateRule)controllerStateRule).ControllerType;

                controllerStateRule.ControllerType = Application.Modules[0].ModuleManager.ControllersManager.CollectControllers(

                                        info => info.FullName == controllerType).

                                        Single().GetType();

            }

 

            return collectRulesFromModelCore;

        }

 

        protected override bool IsDefaultContext(ExecutionContext context) {

            return true;

        }

and ActionStateModule

public class ActionStateModule : ConditionalLogicRuleProviderModuleBase<TArtifactStateRule> where TArtifactStateRule : IConditionalLogicRule

{

     public override string LogicRulesNodeAttributeName {

         get { return ActionStateRulesNodeWrapper.NodeNameAttribute; }

     }

 

 

     public override string RootNodePath {

         get { return ModelArtifactStateModule.ModelArtifactStateAttributeName; }

     }

     protected override void ModifySchemaAttributes(Core.DictionaryHelpers.AttibuteCreatedEventArgs args)

     {

         base.ModifySchemaAttributes(args);

         if (args.Attribute.IndexOf("ActionId") > -1)

             args.AddTag(@"Required=""True"" RefNodeName=""/Application/ActionDesign/Actions/*""");

     }

 

     protected override bool IsDefaultContext(ExecutionContext context) {

         return true;

     }

 

     public override Schema GetSchema() {

         var schema = base.GetSchema();

         var dictionaryNode = schema.RootNode.GetChildNode("Element", "Name", ModelArtifactStateModule.ModelArtifactStateAttributeName);

         var findChildNode = schema.RootNode.FindChildNode("Element","Name",LogicRulesNodeAttributeName);

         schema.RootNode.RemoveChildNode(findChildNode);

         dictionaryNode.AddChildNode(findChildNode);

         return schema;

     }

As you can see with the logic architecture everything is well defined and very flexible

Subscribe to XAF feed
Subscribe to community feed

DiggIt!
blog comments powered by Disqus