Exemple #1
0
 public ArtifactStateInfo(bool active, object obj, State state, ArtifactStateRule rule)
 {
     Active = active;
     objectCore = obj;
     this.state = state;
     this.rule = rule;
 }
        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);
        }
 /// <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;
     if (targetObject == null){
         if (string.IsNullOrEmpty(artifactStateRule.EmptyCriteria)){
             return true;
         }
         return !fit(new object(), artifactStateRule.EmptyCriteria);
     }
     return fit(targetObject, criteria);
 }