예제 #1
0
        protected virtual bool IsValidRule(ILogicRuleObject rule, View view, EventArgs eventArgs, ExecutionContext executionContext)
        {
            var detailView   = view as DetailView;
            var viewEditMode = detailView != null ? detailView.ViewEditMode : (ViewEditMode?)null;

            return(view != null && IsValidRule(rule, new ViewInfo(view.Id, view is DetailView, view.IsRoot, view.ObjectTypeInfo, viewEditMode), eventArgs, executionContext));
        }
예제 #2
0
 protected virtual bool IsVailidExecutionContext(ILogicRuleObject rule, ExecutionContext executionContext, EventArgs eventArgs)
 {
     if (executionContext == ExecutionContext.ObjectSpaceObjectChanged)
     {
         return(rule.ObjectChangedPropertyNames.Contains(((ObjectChangedEventArgs)eventArgs).PropertyName));
     }
     return(true);
 }
예제 #3
0
 protected virtual bool TemplateContextGroupIsValid(ILogicRuleObject ruleObject) {
     var frameTemplateContext = ruleObject.FrameTemplateContext;
     if (frameTemplateContext!=FrameTemplateContext.All) {
         var templateContextStringValue = Frame.Context.ToString().TrimEnd("Context".ToCharArray());
         var templateContext =(FrameTemplateContext) Enum.Parse(typeof (FrameTemplateContext), templateContextStringValue);
         return (frameTemplateContext | templateContext) == frameTemplateContext;
     }
     return true;
 }
예제 #4
0
        void AddRuleCore(ITypeInfo typeInfo, ExecutionContext executionContext, ILogicRuleObject logicRuleObject)
        {
            var tuple = new Tuple <ITypeInfo, ExecutionContext>(typeInfo, executionContext);

            if (!Instance._rules.ContainsKey(tuple))
            {
                Instance._rules.Add(tuple, new List <ILogicRuleObject>());
            }
            Instance._rules[tuple].Add(logicRuleObject);
        }
예제 #5
0
 protected virtual bool IsValidRule(ILogicRuleObject rule, ViewInfo viewInfo,EventArgs eventArgs,ExecutionContext executionContext){
     var isValidViewId = IsValidViewId(viewInfo.ViewId, rule);
     var isValidNewObject = IsValidNewObject(rule);
     var isValidViewType = IsValidViewType(viewInfo, rule);
     var isValidNestedType = IsValidNestedType(rule, viewInfo);
     var isValidTypeInfo = IsValidTypeInfo(viewInfo, rule);
     var isValidViewEditMode = IsValidViewEditMode(viewInfo, rule);
     var templateContextGroupIsValid = TemplateContextGroupIsValid(rule);
     var viewIsRoot = ViewIsRoot(rule);
     var isVailidExecutionContext = IsVailidExecutionContext(rule,executionContext,eventArgs);
     return isValidViewId &&isValidNewObject&&isValidViewType && isValidNestedType && isValidTypeInfo&& isValidViewEditMode && templateContextGroupIsValid && viewIsRoot&&isVailidExecutionContext;
 }
예제 #6
0
        protected virtual bool TemplateContextGroupIsValid(ILogicRuleObject ruleObject)
        {
            var frameTemplateContext = ruleObject.FrameTemplateContext;

            if (frameTemplateContext != FrameTemplateContext.All)
            {
                var templateContextStringValue = Frame.Context.ToString().TrimEnd("Context".ToCharArray());
                var templateContext            = (FrameTemplateContext)Enum.Parse(typeof(FrameTemplateContext), templateContextStringValue);
                return((frameTemplateContext | templateContext) == frameTemplateContext);
            }
            return(true);
        }
예제 #7
0
        protected virtual bool IsValidRule(ILogicRuleObject rule, ViewInfo viewInfo, EventArgs eventArgs, ExecutionContext executionContext)
        {
            var isValidViewId               = IsValidViewId(viewInfo.ViewId, rule);
            var isValidNewObject            = IsValidNewObject(rule);
            var isValidViewType             = IsValidViewType(viewInfo, rule);
            var isValidNestedType           = IsValidNestedType(rule, viewInfo);
            var isValidTypeInfo             = IsValidTypeInfo(viewInfo, rule);
            var isValidViewEditMode         = IsValidViewEditMode(viewInfo, rule);
            var templateContextGroupIsValid = TemplateContextGroupIsValid(rule);
            var viewIsRoot = ViewIsRoot(rule);
            var isVailidExecutionContext = IsVailidExecutionContext(rule, executionContext, eventArgs);

            return(isValidViewId && isValidNewObject && isValidViewType && isValidNestedType && isValidTypeInfo && isValidViewEditMode && templateContextGroupIsValid && viewIsRoot && isVailidExecutionContext);
        }
예제 #8
0
 protected virtual bool IsValidDCTypeInfo(ViewInfo viewInfo, ILogicRuleObject rule)
 {
     if (viewInfo.ObjectTypeInfo.IsDomainComponent)
     {
         var entityType = XpoTypesInfoHelper.GetXpoTypeInfoSource().GetGeneratedEntityType(viewInfo.ObjectTypeInfo.Type);
         var types      = new List <Type> {
             entityType
         };
         while (entityType != null && entityType != typeof(object))
         {
             entityType = entityType.BaseType;
             types.Add(entityType);
         }
         return(types.Contains(rule.TypeInfo.Type));
     }
     return(true);
 }
예제 #9
0
 protected virtual bool IsValidViewId(string viewId, ILogicRuleObject rule) {
     return rule.View != null ? viewId == rule.View.Id : !rule.Views.Any() || rule.Views.Contains(viewId);
 }
예제 #10
0
 protected virtual bool IsValidViewId(string viewId, ILogicRuleObject rule)
 {
     return(rule.View != null ? viewId == rule.View.Id : !rule.Views.Any() || rule.Views.Contains(viewId));
 }
예제 #11
0
 protected virtual bool IsValidTypeInfo(ViewInfo viewInfo, ILogicRuleObject rule)
 {
     return(rule.TypeInfo.Type == typeof(AllViews) || ((rule.TypeInfo != null && rule.TypeInfo.IsAssignableFrom(viewInfo.ObjectTypeInfo)) ||
                                                       IsValidDCTypeInfo(viewInfo, rule)) || rule.TypeInfo == null);
 }
예제 #12
0
 protected virtual bool IsValidDCTypeInfo(ViewInfo viewInfo, ILogicRuleObject rule) {
     if (viewInfo.ObjectTypeInfo.IsDomainComponent) {
         var entityType = XpoTypesInfoHelper.GetXpoTypeInfoSource().GetGeneratedEntityType(viewInfo.ObjectTypeInfo.Type);
         var types = new List<Type> { entityType };
         while (entityType != null && entityType != typeof(object)) {
             entityType = entityType.BaseType;
             types.Add(entityType);
         }
         return types.Contains(rule.TypeInfo.Type);
     }
     return true;
 }
예제 #13
0
 protected virtual bool IsValidRule(ILogicRuleObject rule, View view) {
     var viewEditMode = view is DetailView ? ((DetailView)view).ViewEditMode : (ViewEditMode?)null;
     return view != null && IsValidRule(rule, new ViewInfo(view.Id, view is DetailView, view.IsRoot, view.ObjectTypeInfo, viewEditMode));
 }
예제 #14
0
 bool IsValidNewObject(ILogicRuleObject rule)
 {
     return(!rule.IsNew.HasValue || (rule.IsNew.Value ? IsNew : !IsNew));
 }
예제 #15
0
 protected virtual bool IsValidViewEditMode(ViewInfo viewInfo, ILogicRuleObject rule)
 {
     return(!rule.ViewEditMode.HasValue || viewInfo.ViewEditMode == rule.ViewEditMode);
 }
예제 #16
0
 protected virtual bool IsValidRule(ILogicRuleObject rule, ViewInfo viewInfo) {
     return (IsValidViewId(viewInfo.ViewId, rule)) &&IsValidNewObject(rule)&&
            IsValidViewType(viewInfo, rule) && IsValidNestedType(rule, viewInfo) && IsValidTypeInfo(viewInfo, rule)
            && IsValidViewEditMode(viewInfo, rule) && TemplateContextGroupIsValid(rule) && ViewIsRoot(rule);
 }
예제 #17
0
 protected virtual bool IsValidRule(ILogicRuleObject rule, View view, EventArgs eventArgs, ExecutionContext executionContext) {
     var viewEditMode = view is DetailView ? ((DetailView)view).ViewEditMode : (ViewEditMode?)null;
     return view != null && IsValidRule(rule, new ViewInfo(view.Id, view is DetailView, view.IsRoot, view.ObjectTypeInfo, viewEditMode),eventArgs,executionContext);
 }
예제 #18
0
        public virtual bool Fit(object targetObject, ILogicRuleObject logicRule)
        {
            var criteria = CriteriaOperator.Parse(logicRule.NormalCriteria);

            return(targetObject != null?criteria.Fit(targetObject) : CriteriaOperator.Parse(logicRule.EmptyCriteria).Fit(new object()));
        }
예제 #19
0
 protected virtual bool IsValidTypeInfo(ViewInfo viewInfo, ILogicRuleObject rule) {
     return (((rule.TypeInfo != null && rule.TypeInfo.IsAssignableFrom(viewInfo.ObjectTypeInfo)) 
         || IsValidDCTypeInfo(viewInfo, rule)) || rule.TypeInfo == null);
 }
예제 #20
0
 protected virtual bool IsValidNestedType(ILogicRuleObject rule, ViewInfo viewInfo)
 {
     return(viewInfo.IsDetailView || (rule.Nesting == Nesting.Any || viewInfo.IsRoot));
 }
예제 #21
0
 protected virtual bool ViewIsRoot(ILogicRuleObject ruleObject) {
     return !(ruleObject.IsRootView.HasValue) || ruleObject.IsRootView == Frame.View.IsRoot;
 }
예제 #22
0
 public virtual bool Fit(object targetObject, ILogicRuleObject logicRule) {
     var criteria = CriteriaOperator.Parse(logicRule.NormalCriteria);
     return targetObject != null ? criteria.Fit(targetObject) : string.IsNullOrEmpty(logicRule.EmptyCriteria) || CriteriaOperator.Parse(logicRule.EmptyCriteria).Fit(new object());
 }
예제 #23
0
 protected virtual bool IsValidViewType(ViewInfo viewInfo, ILogicRuleObject rule) {
     return (rule.ViewType == ViewType.Any || (viewInfo.IsDetailView ? rule.ViewType == ViewType.DetailView : rule.ViewType == ViewType.ListView));
 }
예제 #24
0
 protected virtual bool IsValidNestedType(ILogicRuleObject rule, ViewInfo viewInfo) {
     return viewInfo.IsDetailView || (rule.Nesting == Nesting.Any || viewInfo.IsRoot);
 }
예제 #25
0
 protected virtual bool IsValidViewType(ViewInfo viewInfo, ILogicRuleObject rule)
 {
     return(rule.ViewType == ViewType.Any || (viewInfo.IsDetailView ? rule.ViewType == ViewType.DetailView : rule.ViewType == ViewType.ListView));
 }
예제 #26
0
 protected virtual bool IsVailidExecutionContext(ILogicRuleObject rule, ExecutionContext executionContext, EventArgs eventArgs){
     if (executionContext == ExecutionContext.ObjectSpaceObjectChanged){
         return rule.ObjectChangedPropertyNames.Contains(((ObjectChangedEventArgs) eventArgs).PropertyName);
     }
     return true;
 }
예제 #27
0
 protected virtual bool ViewIsRoot(ILogicRuleObject ruleObject)
 {
     return(!(ruleObject.IsRootView.HasValue) || ruleObject.IsRootView == Frame.View.IsRoot);
 }
예제 #28
0
 bool IsValidNewObject(ILogicRuleObject rule) {
     return !rule.IsNew.HasValue || (rule.IsNew.Value ? IsNew : !IsNew);
 }
예제 #29
0
 protected virtual bool IsValidViewEditMode(ViewInfo viewInfo, ILogicRuleObject rule) {
     return !rule.ViewEditMode.HasValue || viewInfo.ViewEditMode == rule.ViewEditMode;
 }
예제 #30
0
 protected virtual bool IsValidRule(ILogicRuleObject rule, ViewInfo viewInfo, EventArgs eventArgs, ExecutionContext executionContext)
 {
     return((IsValidViewId(viewInfo.ViewId, rule)) && IsValidNewObject(rule) &&
            IsValidViewType(viewInfo, rule) && IsValidNestedType(rule, viewInfo) && IsValidTypeInfo(viewInfo, rule) &&
            IsValidViewEditMode(viewInfo, rule) && TemplateContextGroupIsValid(rule) && ViewIsRoot(rule) && IsVailidExecutionContext(rule, executionContext, eventArgs));
 }