예제 #1
0
        /// <summary>
        /// Performs validation on the current shape.
        /// </summary>
        /// <param name="validationData">Context dependent validation data.</param>
        /// <returns>An instance of the ShapeError class if more than one error occured with
        /// the current shape, otherwise null.</returns>
        public virtual ShapeError Validate(object validationData)
        {
            ShapeError error;

            string e1 = null;

            if (Form.IsValid == false)
            {
                e1 = "Invalid properties. ";
            }

            string e2 = DoContextValidation(validationData);

            string e = string.Format("{0}{1}", e1, e2);

            if (e != null && e.Length > 0)
            {
                PaintAsInvalid();
                error = new ShapeError(this, e);
            }
            else
            {
                error = null;
                if (!PaintAsValid())
                {
                    error = new ShapeError(this, "Invalid connection.");
                }
            }

            return(error);
        }
예제 #2
0
파일: BaseShape.cs 프로젝트: zi-yu/midgard
        /// <summary>
        /// Performs validation on the current shape.
        /// </summary>
        /// <param name="validationData">Context dependent validation data.</param>
        /// <returns>An instance of the ShapeError class if more than one error occured with
        /// the current shape, otherwise null.</returns>
        public virtual ShapeError Validate( object validationData )
        {
            ShapeError error;

            string e1 = null;

            if ( Form.IsValid == false )
            {
                e1 = "Invalid properties. ";
            }

            string e2 = DoContextValidation( validationData );

            string e = string.Format( "{0}{1}", e1, e2 );

            if ( e != null && e.Length > 0 )
            {
                PaintAsInvalid();
                error = new ShapeError( this, e );
            }
            else
            {
                error = null;
                if (!PaintAsValid())
                    error = new ShapeError(this, "Invalid connection.");

            }

            return error;
        }