コード例 #1
0
        /// <summary>
        /// Validates the data object properties using .NET validation attributes.
        /// </summary>
        /// <returns>A collection of validation results.</returns>
        protected virtual IEnumerable <ValidationResult> ValidateProperties()
        {
            IList <ValidationResult> results;

            DataObjectValidator.TryValidate(DataObject, out results);
            WitsmlValidator.ValidateResults(Context.Function, results);
            yield break;
        }
コード例 #2
0
        /// <summary>
        /// Validates the updated entity.
        /// </summary>
        /// <param name="function">The WITSML API function.</param>
        /// <param name="uri">The URI.</param>
        protected virtual void ValidateUpdatedEntity(Functions function, EtpUri uri)
        {
            IList <ValidationResult> results;

            var entity = Get(uri);

            DataObjectValidator.TryValidate(entity, out results);
            WitsmlValidator.ValidateResults(function, results);
        }
コード例 #3
0
        /// <summary>
        /// Validates the specified data object while executing a WITSML API method.
        /// </summary>
        /// <param name="function">The WITSML API method.</param>
        /// <param name="parser">The input template parser.</param>
        /// <param name="dataObject">The data object.</param>
        /// <exception cref="PDS.WITSMLstudio.WitsmlException">If any validation errors are detected.</exception>
        public void Validate(Functions function, WitsmlQueryParser parser, T dataObject)
        {
            Logger.DebugFormat("Validating data object for {0}; Type: {1}", function, typeof(T).FullName);

            Context.Function = function;
            DataObject       = dataObject;
            Parser           = parser;
            ConfigureContext();

            IList <ValidationResult> results;

            DataObjectValidator.TryValidate(this, out results);
            WitsmlValidator.ValidateResults(function, results);

            WitsmlOperationContext.Current.Warnings.AddRange(Context.Warnings);
        }