Esempio n. 1
0
        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;
        }
Esempio n. 2
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);
     return logicRuleObject;
 }
Esempio n. 3
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);
             }
     }
 }
Esempio n. 4
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);
             }
     }
 }
Esempio n. 5
0
 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]);
     }
 }
Esempio n. 6
0
 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];
     }
 }
Esempio n. 7
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);
        }
Esempio n. 8
0
 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;
 }
Esempio n. 9
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);
             }
         }
     }
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
 static bool B(IContextLogicRule contextLogicRule, ITypeInfo info)
 {
     return(typeof(ILogicRule).IsAssignableFrom(info.Type) &&
            info.Type.IsInstanceOfType(contextLogicRule) && info.FindAttribute <ModelAbstractClassAttribute>(false) == null);
 }
Esempio n. 12
0
        ExecutionContext GetExecutionContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic)
        {
            var modelExecutionContexts = modelLogic.ExecutionContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.ExecutionContextGroup);

            return(modelExecutionContexts != null ? modelExecutionContexts.ExecutionContext : ExecutionContext.None);
        }
Esempio n. 13
0
        FrameTemplateContext GetFrameTemplateContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic)
        {
            var templateContexts = modelLogic.FrameTemplateContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.FrameTemplateContextGroup);

            return(templateContexts != null ? templateContexts.FrameTemplateContext : FrameTemplateContext.All);
        }
Esempio n. 14
0
 static bool B(IContextLogicRule contextLogicRule, ITypeInfo info) {
     return  typeof(ILogicRule).IsAssignableFrom(info.Type) 
         && info.Type.IsInstanceOfType(contextLogicRule)&& info.FindAttribute<ModelAbstractClassAttribute>(false)==null;
 }
Esempio n. 15
0
 FrameTemplateContext GetFrameTemplateContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) {
     var templateContexts = modelLogic.FrameTemplateContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.FrameTemplateContextGroup);
     return templateContexts != null ? templateContexts.FrameTemplateContext : FrameTemplateContext.All;
 }
Esempio n. 16
0
 ExecutionContext GetExecutionContext(IContextLogicRule contextLogicRule, IModelLogicWrapper modelLogic) {
     var modelExecutionContexts = modelLogic.ExecutionContextsGroup.FirstOrDefault(contexts => contexts.Id == contextLogicRule.ExecutionContextGroup);
     return modelExecutionContexts != null ? modelExecutionContexts.ExecutionContext : ExecutionContext.None;
 }
Esempio n. 17
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);
             }
         }
     }
 }