Пример #1
0
 public ArtifactStateInfo(bool active, object obj, State state, ArtifactStateRule rule)
 {
     Active = active;
     objectCore = obj;
     this.state = state;
     this.rule = rule;
 }
Пример #2
0
 public ArtifactStateInfo(bool active, object obj, State state, ArtifactStateRule rule)
 {
     Active     = active;
     objectCore = obj;
     this.state = state;
     this.rule  = rule;
 }
Пример #3
0
        /// <summary>
        /// Determines whether a passed object satisfies to the target criteria and the editor's customization according to a given business criteria should be performed.
        /// </summary>
        public static bool Fit(object targetObject, ArtifactStateRule artifactStateRule)
        {
            string criteria = artifactStateRule.NormalCriteria;

            return(targetObject == null
                       ? string.IsNullOrEmpty(artifactStateRule.EmptyCriteria) ||
                   fit(new object(), artifactStateRule.EmptyCriteria)
                       : fit(targetObject, criteria));
        }
Пример #4
0
        private bool IsValidNestedType(ArtifactStateRule rule, View view)
        {
            if (view is DetailView)
            {
                return(true);
            }

            return(rule.Nesting == Nesting.Any || view.IsRoot);
        }
Пример #5
0
        protected virtual void ForceCustomizationCore(object currentObject, ArtifactStateRule rule, bool invertCustomization, View view)
        {
            ArtifactStateInfo info = ArtifactStateRuleManager.CalculateArtifactStateInfo(currentObject, rule);

            if (info != null)
            {
                info.InvertingCustomization = invertCustomization;
                info.View = view;
                if (invertCustomization)
                {
                    info.Active = !info.Active;
                }
                CustomizeArtifactState(info);
            }
        }
Пример #6
0
        public static ArtifactStateInfo CalculateArtifactStateInfo(object targetObject, ArtifactStateRule rule)
        {
            Guard.ArgumentNotNull(rule, "rule");

            MethodInfo methodInfo = rule.MethodInfo;
            State      editorState;
            bool       active;

            if (methodInfo != null)
            {
                editorState = GetEditorStateFromMethod(methodInfo, targetObject, out active);
                if (!string.IsNullOrEmpty(rule.NormalCriteria))
                {
                    Tracing.Tracer.LogWarning(
                        ExceptionLocalizerTemplate
                        <ConditionalArtifactStateExceptionResourceLocalizer, ConditionalArtifactStateExceptionId> .
                        GetExceptionMessage(
                            ConditionalArtifactStateExceptionId.BrokenRuleContainsBothCriteriaAndMethodInfoParameters),
                        typeof(ArtifactStateRuleAttribute).Name, rule.TypeInfo.FullName, rule.NormalCriteria,
                        rule.MethodInfo.Name);
                }
            }
            else
            {
                editorState = rule.State;
                active      = Fit(targetObject, rule);
            }
            return(new ArtifactStateInfo(active, targetObject, editorState, rule));
        }
Пример #7
0
 /// <summary>
 /// Determines whether a passed object satisfies to the target criteria and the editor's customization according to a given business criteria should be performed.
 /// </summary>
 public static bool Fit(object targetObject, ArtifactStateRule artifactStateRule) {
     string criteria = artifactStateRule.NormalCriteria;
     return targetObject == null
                ? string.IsNullOrEmpty(artifactStateRule.EmptyCriteria) ||
                  fit(new object(), artifactStateRule.EmptyCriteria)
                : fit(targetObject, criteria);
 }
Пример #8
0
        public static ArtifactStateInfo CalculateArtifactStateInfo(object targetObject,  ArtifactStateRule rule)
        {
            Guard.ArgumentNotNull(rule, "rule");

            MethodInfo methodInfo = rule.MethodInfo;
            State editorState;
            bool active;

            if (methodInfo != null) {
                editorState = GetEditorStateFromMethod(methodInfo, targetObject, out active);
                if (!string.IsNullOrEmpty(rule.NormalCriteria)) {
                    Tracing.Tracer.LogWarning(
                        ExceptionLocalizerTemplate
                            <ConditionalArtifactStateExceptionResourceLocalizer, ConditionalArtifactStateExceptionId>.
                            GetExceptionMessage(
                            ConditionalArtifactStateExceptionId.BrokenRuleContainsBothCriteriaAndMethodInfoParameters),
                        typeof (ArtifactStateRuleAttribute).Name, rule.TypeInfo.FullName, rule.NormalCriteria,
                        rule.MethodInfo.Name);
                }
            }
            else {
                editorState = rule.State;
                active = Fit(targetObject, rule);
            }
            return new ArtifactStateInfo(active, targetObject,  editorState, rule);
        }
Пример #9
0
 private bool IsValidViewType(View view, ArtifactStateRule rule)
 {
     return(rule.ViewType == ViewType.Any || (view is DetailView ? rule.ViewType == ViewType.DetailView : rule.ViewType == ViewType.ListView));
 }
Пример #10
0
 protected virtual bool IsValidRule(ArtifactStateRule rule, View view)
 {
     return(view != null && (string.IsNullOrEmpty(rule.ViewId) || view.Id == rule.ViewId) && view.ObjectTypeInfo != null &&
            IsValidViewType(view, rule) && IsValidNestedType(rule, view) && (rule.TypeInfo.IsAssignableFrom(view.ObjectTypeInfo)));
 }