protected LogicRulePermission(string operation, IContextLogicRule contextLogicRule) : base(operation) { IsNew = contextLogicRule.IsNew; ObjectChangedExecutionContextGroup = contextLogicRule.ObjectChangedExecutionContextGroup; ExecutionContextGroup = contextLogicRule.ExecutionContextGroup; FrameTemplateContextGroup = contextLogicRule.FrameTemplateContextGroup; ViewContextGroup = contextLogicRule.ViewContextGroup; ActionExecutionContextGroup = contextLogicRule.ActionExecutionContextGroup; var viewId = (string)contextLogicRule.GetPropertyValue(nameof(ILogicRuleOperationPermissionData.ViewId), Flags.TrimExplicitlyImplemented | Flags.AllMembers); View = CaptionHelper.ApplicationModel.Views[viewId]; Description = contextLogicRule.Description; ID = (string)contextLogicRule.GetPropertyValue(nameof(ILogicRuleOperationPermissionData.ID)); Index = contextLogicRule.Index; IsRootView = contextLogicRule.IsRootView; Nesting = contextLogicRule.Nesting; if (!string.IsNullOrEmpty(viewId)) { ((ILogicRule)this).View = CaptionHelper.ApplicationModel.Views[viewId]; } ViewEditMode = contextLogicRule.ViewEditMode; ViewType = contextLogicRule.ViewType; var objectTypeData = (Type)contextLogicRule.GetPropertyValue(nameof(ILogicRuleOperationPermissionData.ObjectTypeData)); if (objectTypeData != null) { ObjectType = objectTypeData; } NormalCriteria = contextLogicRule.NormalCriteria; EmptyCriteria = contextLogicRule.EmptyCriteria; }
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); } } }
public ILogicInstaller this[IContextLogicRule contextLogicRule] { get { var xafApplication = ApplicationHelper.Instance.Application; var typeInfos = xafApplication.TypesInfo.FindTypeInfo(typeof(IContextLogicRule)).Descendants; var infos = typeInfos.SelectMany(info => info.ImplementedInterfaces); var typeInfo = infos.First(info => B(contextLogicRule, info)); return(this[typeInfo.Type]); } }
public ILogicInstaller this[IContextLogicRule contextLogicRule] { get { var xafApplication = ApplicationHelper.Instance.Application; var typeInfos = xafApplication.TypesInfo.FindTypeInfo(typeof(IContextLogicRule)).Descendants; var infos = typeInfos.SelectMany(info => info.ImplementedInterfaces); var typeInfo = infos.First(info => B(contextLogicRule, info)); return this[typeInfo.Type]; } }
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 LogicRule(IContextLogicRule logicRule) { Description = logicRule.Description; ID = logicRule.Id; Index = logicRule.Index; IsRootView = logicRule.IsRootView; Nesting = logicRule.Nesting; TypeInfo = logicRule.TypeInfo; View = logicRule.View; ViewType = logicRule.ViewType; ViewEditMode = logicRule.ViewEditMode; NormalCriteria=logicRule.NormalCriteria; EmptyCriteria=logicRule.EmptyCriteria; IsNew = logicRule.IsNew; }
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); } } } }
protected LogicRule(IContextLogicRule logicRule) { Description = logicRule.Description; ID = logicRule.Id; Index = logicRule.Index; IsRootView = logicRule.IsRootView; Nesting = logicRule.Nesting; TypeInfo = logicRule.TypeInfo; View = logicRule.View; ViewType = logicRule.ViewType; ViewEditMode = logicRule.ViewEditMode; NormalCriteria = logicRule.NormalCriteria; EmptyCriteria = logicRule.EmptyCriteria; IsNew = logicRule.IsNew; }
static bool B(IContextLogicRule contextLogicRule, ITypeInfo info) { return(typeof(ILogicRule).IsAssignableFrom(info.Type) && info.Type.IsInstanceOfType(contextLogicRule) && info.FindAttribute <ModelAbstractClassAttribute>(false) == null); }
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); }
static bool B(IContextLogicRule contextLogicRule, ITypeInfo info) { return typeof(ILogicRule).IsAssignableFrom(info.Type) && info.Type.IsInstanceOfType(contextLogicRule)&& info.FindAttribute<ModelAbstractClassAttribute>(false)==null; }
FrameTemplateContext GetFrameTemplateContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) { var templateContexts = modelLogic.FrameTemplateContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.FrameTemplateContextGroup); return templateContexts != null ? templateContexts.FrameTemplateContext : FrameTemplateContext.All; }
ExecutionContext GetExecutionContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) { var modelExecutionContexts = modelLogic.ExecutionContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.ExecutionContextGroup); return modelExecutionContexts != null ? modelExecutionContexts.ExecutionContext : ExecutionContext.None; }
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); } } } }