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; }
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); } } }
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); } } }
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); } } } }
ExecutionContext GetExecutionContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) { var modelExecutionContexts = modelLogic.ExecutionContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.ExecutionContextGroup); return modelExecutionContexts != null ? modelExecutionContexts.ExecutionContext : ExecutionContext.None; }
FrameTemplateContext GetFrameTemplateContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) { var templateContexts = modelLogic.FrameTemplateContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.FrameTemplateContextGroup); return templateContexts != null ? templateContexts.FrameTemplateContext : FrameTemplateContext.All; }
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); }
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); } } }
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); } } } }
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); }
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)); }
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); } } }
ExecutionContext GetExecutionContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) { var modelExecutionContexts = modelLogic.ExecutionContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.ExecutionContextGroup); return(modelExecutionContexts != null ? modelExecutionContexts.ExecutionContext : ExecutionContext.None); }
FrameTemplateContext GetFrameTemplateContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) { var templateContexts = modelLogic.FrameTemplateContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.FrameTemplateContextGroup); return(templateContexts != null ? templateContexts.FrameTemplateContext : FrameTemplateContext.All); }
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); } } } } }