Beispiel #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));
        }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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);
        }
Beispiel #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;
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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));
 }
Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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));
 }
Beispiel #14
0
 bool IsValidNewObject(ILogicRuleObject rule)
 {
     return(!rule.IsNew.HasValue || (rule.IsNew.Value ? IsNew : !IsNew));
 }
Beispiel #15
0
 protected virtual bool IsValidViewEditMode(ViewInfo viewInfo, ILogicRuleObject rule)
 {
     return(!rule.ViewEditMode.HasValue || viewInfo.ViewEditMode == rule.ViewEditMode);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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()));
        }
Beispiel #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);
 }
Beispiel #20
0
 protected virtual bool IsValidNestedType(ILogicRuleObject rule, ViewInfo viewInfo)
 {
     return(viewInfo.IsDetailView || (rule.Nesting == Nesting.Any || viewInfo.IsRoot));
 }
Beispiel #21
0
 protected virtual bool ViewIsRoot(ILogicRuleObject ruleObject) {
     return !(ruleObject.IsRootView.HasValue) || ruleObject.IsRootView == Frame.View.IsRoot;
 }
Beispiel #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());
 }
Beispiel #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));
 }
Beispiel #24
0
 protected virtual bool IsValidNestedType(ILogicRuleObject rule, ViewInfo viewInfo) {
     return viewInfo.IsDetailView || (rule.Nesting == Nesting.Any || viewInfo.IsRoot);
 }
Beispiel #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));
 }
Beispiel #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;
 }
Beispiel #27
0
 protected virtual bool ViewIsRoot(ILogicRuleObject ruleObject)
 {
     return(!(ruleObject.IsRootView.HasValue) || ruleObject.IsRootView == Frame.View.IsRoot);
 }
Beispiel #28
0
 bool IsValidNewObject(ILogicRuleObject rule) {
     return !rule.IsNew.HasValue || (rule.IsNew.Value ? IsNew : !IsNew);
 }
Beispiel #29
0
 protected virtual bool IsValidViewEditMode(ViewInfo viewInfo, ILogicRuleObject rule) {
     return !rule.ViewEditMode.HasValue || viewInfo.ViewEditMode == rule.ViewEditMode;
 }
Beispiel #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));
 }