/// <summary> /// Creates or retrieves the <see cref="IObjectMapping"/> from the classMap. /// </summary> /// <param name="classMap">The mapping.</param> /// <param name="objectCategory">The object category for the object.</param> /// <param name="includeObjectCategory"> /// Indicates if the object category should be included in all queries. /// </param> /// <param name="namingContext">The location of the objects in the directory.</param> /// <param name="objectClasses">The object classes for the object.</param> /// <param name="includeObjectClasses">Indicates if the object classes should be included in all queries.</param> /// <exception cref="MappingException"> /// Thrown if the mapping is invalid. /// </exception> /// <returns></returns> public IObjectMapping Map(IClassMap classMap, string namingContext = null, IEnumerable <string> objectClasses = null, bool includeObjectClasses = true, string objectCategory = null, bool includeObjectCategory = true) { if (classMap == null) { throw new ArgumentNullException(nameof(classMap)); } return(_mappings.GetOrAdd(classMap.Type, t => { var mapped = classMap.PerformMapping(namingContext, objectCategory, includeObjectCategory, objectClasses, includeObjectClasses); mapped.Validate(); var objectMapping = mapped.ToObjectMapping(); MapSubTypes(objectMapping); return objectMapping; })); }