コード例 #1
0
ファイル: LogicRuleCollector.cs プロジェクト: noxe/eXpand
 protected virtual ILogicRuleObject CreateRuleObject(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) {
     var logicRuleObjectType = LogicRuleObjectType(contextLogicRule);
     var logicRuleObject = ((ILogicRuleObject)logicRuleObjectType.CreateInstance(contextLogicRule));
     logicRuleObject.TypeInfo = contextLogicRule.TypeInfo;
     logicRuleObject.ExecutionContext = GetExecutionContext(contextLogicRule, modelLogic);
     logicRuleObject.FrameTemplateContext = GetFrameTemplateContext(contextLogicRule, modelLogic);
     AddViews(logicRuleObject.Views,modelLogic,contextLogicRule);
     return logicRuleObject;
 }
コード例 #2
0
ファイル: LogicRuleCollector.cs プロジェクト: aries544/eXpand
 void AddViews(HashSet<string> views, IModelLogicWrapper modelLogic, IContextLogicRule contextLogicRule) {
     if (!string.IsNullOrEmpty(contextLogicRule.ViewContextGroup)) {
         var modelViewContexts =modelLogic.ViewContextsGroup.FirstOrDefault(
                 contexts => contexts.Id == contextLogicRule.ViewContextGroup);
         if (modelViewContexts != null)
             foreach (var modelViewContext in modelViewContexts) {
                 views.Add(modelViewContext.Name);
             }
     }
 }
コード例 #3
0
ファイル: LogicRuleCollector.cs プロジェクト: aries544/eXpand
 private void AddObjectChangedProperties(HashSet<string> objectChangedPropertyNames, IModelLogicWrapper modelLogic, IContextLogicRule contextLogicRule){
     if (!string.IsNullOrEmpty(contextLogicRule.ObjectChangedExecutionContextGroup)) {
         var executionContexts = modelLogic.ObjectChangedExecutionContextGroup.FirstOrDefault(
                 contexts => contexts.Id == contextLogicRule.ObjectChangedExecutionContextGroup);
         if (executionContexts != null)
             foreach (var s in executionContexts.SelectMany(executionContext => executionContext.PropertyNames.Split(';'))){
                 objectChangedPropertyNames.Add(s);
             }
     }
 }
コード例 #4
0
 void AddViews(HashSet <string> views, IModelLogicWrapper modelLogic, IContextLogicRule contextLogicRule)
 {
     if (!string.IsNullOrEmpty(contextLogicRule.ViewContextGroup))
     {
         var modelViewContexts = modelLogic.ViewContextsGroup.FirstOrDefault(
             contexts => contexts.Id == contextLogicRule.ViewContextGroup);
         if (modelViewContexts != null)
         {
             foreach (var modelViewContext in modelViewContexts)
             {
                 views.Add(modelViewContext.Name);
             }
         }
     }
 }
コード例 #5
0
ファイル: LogicRuleCollector.cs プロジェクト: aries544/eXpand
 ExecutionContext GetExecutionContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) {
     var modelExecutionContexts = modelLogic.ExecutionContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.ExecutionContextGroup);
     return modelExecutionContexts != null ? modelExecutionContexts.ExecutionContext : ExecutionContext.None;
 }
コード例 #6
0
ファイル: LogicRuleCollector.cs プロジェクト: aries544/eXpand
 FrameTemplateContext GetFrameTemplateContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) {
     var templateContexts = modelLogic.FrameTemplateContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.FrameTemplateContextGroup);
     return templateContexts != null ? templateContexts.FrameTemplateContext : FrameTemplateContext.All;
 }
コード例 #7
0
ファイル: LogicRuleCollector.cs プロジェクト: aries544/eXpand
 protected virtual IEnumerable<ILogicRule> CollectRulesFromPermissions(IModelLogicWrapper modelLogic, ITypeInfo typeInfo) {
     return  GetPermissions().Where(permission =>permission.TypeInfo != null && permission.TypeInfo.Type == typeInfo.Type)
         .OrderBy(rule => rule.Index);
 }
コード例 #8
0
ファイル: LogicRuleCollector.cs プロジェクト: aries544/eXpand
 protected virtual void CollectRules(IEnumerable<IContextLogicRule> logicRules, IModelLogicWrapper modelLogic) {
     var ruleObjects = logicRules.Select(rule => CreateRuleObject(rule, modelLogic));
     var groupings = ruleObjects.GroupBy(rule => rule.TypeInfo).Select(grouping => new { grouping.Key, Rules = grouping }).ToList();
     foreach (var grouping in groupings) {
         LogicRuleManager.Instance.AddRules(grouping.Key,grouping.Rules);
         foreach (var info in grouping.Key.Descendants) {
             LogicRuleManager.Instance.AddRules(info, grouping.Rules);
         }
     }
 }
コード例 #9
0
 private void AddObjectChangedProperties(HashSet <string> objectChangedPropertyNames, IModelLogicWrapper modelLogic, IContextLogicRule contextLogicRule)
 {
     if (!string.IsNullOrEmpty(contextLogicRule.ObjectChangedExecutionContextGroup))
     {
         var executionContexts = modelLogic.ObjectChangedExecutionContextGroup.FirstOrDefault(
             contexts => contexts.Id == contextLogicRule.ObjectChangedExecutionContextGroup);
         if (executionContexts != null)
         {
             foreach (var s in executionContexts.SelectMany(executionContext => executionContext.PropertyNames.Split(';')))
             {
                 objectChangedPropertyNames.Add(s);
             }
         }
     }
 }
コード例 #10
0
        protected virtual ILogicRuleObject CreateRuleObject(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic)
        {
            var logicRuleObjectType = LogicRuleObjectType(contextLogicRule);
            var logicRuleObject     = ((ILogicRuleObject)logicRuleObjectType.CreateInstance(contextLogicRule));

            logicRuleObject.TypeInfo             = contextLogicRule.TypeInfo;
            logicRuleObject.ExecutionContext     = GetExecutionContext(contextLogicRule, modelLogic);
            logicRuleObject.FrameTemplateContext = GetFrameTemplateContext(contextLogicRule, modelLogic);
            AddViews(logicRuleObject.Views, modelLogic, contextLogicRule);
            AddObjectChangedProperties(logicRuleObject.ObjectChangedPropertyNames, modelLogic, contextLogicRule);
            return(logicRuleObject);
        }
コード例 #11
0
 protected virtual IEnumerable <ILogicRule> CollectRulesFromPermissions(IModelLogicWrapper modelLogic, ITypeInfo typeInfo)
 {
     return(GetPermissions().Where(permission => permission.TypeInfo != null && permission.TypeInfo.Type == typeInfo.Type)
            .OrderBy(rule => rule.Index));
 }
コード例 #12
0
        protected virtual void CollectRules(IEnumerable <IContextLogicRule> logicRules, IModelLogicWrapper modelLogic)
        {
            var ruleObjects = logicRules.Select(rule => CreateRuleObject(rule, modelLogic));
            var groupings   = ruleObjects.GroupBy(rule => rule.TypeInfo).Select(grouping => new { grouping.Key, Rules = grouping }).ToList();

            foreach (var grouping in groupings)
            {
                LogicRuleManager.Instance.AddRules(grouping.Key, grouping.Rules);
                foreach (var info in grouping.Key.Descendants)
                {
                    LogicRuleManager.Instance.AddRules(info, grouping.Rules);
                }
            }
        }
コード例 #13
0
        ExecutionContext GetExecutionContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic)
        {
            var modelExecutionContexts = modelLogic.ExecutionContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.ExecutionContextGroup);

            return(modelExecutionContexts != null ? modelExecutionContexts.ExecutionContext : ExecutionContext.None);
        }
コード例 #14
0
        FrameTemplateContext GetFrameTemplateContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic)
        {
            var templateContexts = modelLogic.FrameTemplateContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.FrameTemplateContextGroup);

            return(templateContexts != null ? templateContexts.FrameTemplateContext : FrameTemplateContext.All);
        }
コード例 #15
0
ファイル: LogicRuleCollector.cs プロジェクト: scsi110/eXpand
        protected virtual void CollectRules(IEnumerable <IContextLogicRule> logicRules, IModelLogicWrapper modelLogic)
        {
            var ruleObjects = logicRules.Select(rule => CreateRuleObject(rule, modelLogic));
            var groupings   = ruleObjects.GroupBy(rule => rule.TypeInfo).Select(grouping => new { grouping.Key, Rules = grouping }).ToList();

            foreach (var grouping in groupings)
            {
                LogicRuleManager.Instance.AddRules(grouping.Key, grouping.Rules);
                if (grouping.Key.Type == typeof(AllViews))
                {
                    foreach (var typeInfo in XafTypesInfo.Instance.PersistentTypes)
                    {
                        LogicRuleManager.Instance.AddRules(typeInfo, grouping.Rules);
                    }
                }
                else
                {
                    foreach (var info in grouping.Key.Descendants)
                    {
                        LogicRuleManager.Instance.AddRules(info, grouping.Rules);
                    }
                    foreach (var generatedType in _generatedTypes)
                    {
                        if (grouping.Key.Type.IsAssignableFrom(generatedType))
                        {
                            LogicRuleManager.Instance.AddRules(generatedType.GetTypeInfo(), grouping.Rules);
                        }
                    }
                }
            }
        }