예제 #1
0
        /// <summary>
        /// Gets a duplication record to use for adding property annotation.
        /// </summary>
        /// <param name="propertyName">The name of the property to get the duplication record for.</param>
        /// <param name="annotationName">The name of the annotation being added (only for error reporting).</param>
        /// <returns>The duplication record to use. This will never be null.</returns>
        private DuplicationRecord GetDuplicationRecordToAddPropertyAnnotation(string propertyName, string annotationName)
        {
            Debug.Assert(propertyName != null, "propertyName != null");
            Debug.Assert(!string.IsNullOrEmpty(annotationName), "!string.IsNullOrEmpty(annotationName)");

            DuplicationRecord duplicationRecord;

            if (!this.TryGetDuplicationRecord(propertyName, out duplicationRecord))
            {
                duplicationRecord = new DuplicationRecord(DuplicationKind.PropertyAnnotationSeen);
                this.propertyNameCache.Add(propertyName, duplicationRecord);
            }

            if (object.ReferenceEquals(duplicationRecord.PropertyODataAnnotations, propertyAnnotationsProcessedToken))
            {
                throw new ODataException(Strings.DuplicatePropertyNamesChecker_PropertyAnnotationAfterTheProperty(annotationName, propertyName));
            }

            Debug.Assert(duplicationRecord != null, "duplicationRecord != null");
            return(duplicationRecord);
        }