Beispiel #1
0
        public IConsent IsValid(INakedObjectAdapter nakedObjectAdapter, INakedObjectAdapter proposedValue)
        {
            if (proposedValue != null && !proposedValue.Spec.IsOfType(Spec))
            {
                string msg = string.Format(Resources.NakedObjects.TypeMismatchError, Spec.SingularName);
                return(GetConsent(msg));
            }

            var buf = new InteractionBuffer();
            IInteractionContext ic = InteractionContext.ModifyingPropParam(session, false, parentAction.RealTarget(nakedObjectAdapter), Identifier, proposedValue);

            InteractionUtils.IsValid(this, ic, buf);
            return(InteractionUtils.IsValid(buf));
        }
Beispiel #2
0
        /// <summary>
        ///     Checks declarative constraints, and then checks imperatively.
        /// </summary>
        public IConsent IsParameterSetValid(INakedObjectAdapter nakedObjectAdapter, INakedObjectAdapter[] parameterSet)
        {
            IInteractionContext ic;
            var buf = new InteractionBuffer();

            if (parameterSet != null)
            {
                INakedObjectAdapter[] parms = RealParameters(nakedObjectAdapter, parameterSet);
                for (int i = 0; i < parms.Length; i++)
                {
                    ic = InteractionContext.ModifyingPropParam(Session, false, RealTarget(nakedObjectAdapter), Identifier, parameterSet[i]);
                    InteractionUtils.IsValid(GetParameter(i), ic, buf);
                }
            }
            INakedObjectAdapter target = RealTarget(nakedObjectAdapter);

            ic = InteractionContext.InvokingAction(Session, false, target, Identifier, parameterSet);
            InteractionUtils.IsValid(this, ic, buf);
            return(InteractionUtils.IsValid(buf));
        }
        public virtual IConsent IsAssociationValid(INakedObject inObject, INakedObject reference)
        {
            if (reference != null && !reference.Spec.IsOfType(ReturnSpec))
            {
                return(GetConsent(string.Format(Resources.NakedObjects.TypeMismatchError, ReturnSpec.SingularName)));
            }

            if (!inObject.ResolveState.IsNotPersistent())
            {
                if (reference != null && !reference.Spec.IsParseable && reference.ResolveState.IsNotPersistent())
                {
                    return(GetConsent(Resources.NakedObjects.TransientFieldMessage));
                }
            }

            var buf = new InteractionBuffer();
            InteractionContext ic = InteractionContext.ModifyingPropParam(Session, false, inObject, Identifier, reference);

            InteractionUtils.IsValid(this, ic, buf);
            return(InteractionUtils.IsValid(buf));
        }