public ILayeredClassificationType CreateClassificationType(ClassificationLayer layer, string type, IEnumerable <IClassificationType> baseTypes)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (baseTypes == null)
            {
                throw new ArgumentNullException(nameof(baseTypes));
            }

            ClassificationKey key = new ClassificationKey(type, layer);

            if (ClassificationTypes.ContainsKey(key))
            {
                throw new InvalidOperationException(LookUp.Strings.ClassificationAlreadyAdded);
            }

            // Use the non-canonical name for the actual type
            ClassificationTypeImpl classificationType = new ClassificationTypeImpl(type);

            foreach (var baseType in baseTypes)
            {
                classificationType.AddBaseType(baseType);
            }

            ClassificationTypes.Add(key, classificationType);

            return(classificationType);
        }
        /// <summary>
        /// Consumes all of the IClassificationTypeProvisions in the system to build the
        /// list of classification types in the system.
        /// </summary>
        private void BuildClassificationTypes(Dictionary <ClassificationKey, ClassificationTypeImpl> classificationTypes)
        {
            // For each content baseType provision, create an IClassificationType.
            foreach (Lazy <ClassificationTypeDefinition, IClassificationTypeDefinitionMetadata> classificationTypeDefinition in _classificationTypeDefinitions)
            {
                string                 classificationName = classificationTypeDefinition.Metadata.Name;
                ClassificationKey      key  = new ClassificationKey(classificationName);
                ClassificationTypeImpl type = null;

                if (!classificationTypes.TryGetValue(key, out type))
                {
                    type = new ClassificationTypeImpl(classificationName);
                    classificationTypes.Add(key, type);
                }

                IEnumerable <string> baseTypes = classificationTypeDefinition.Metadata.BaseDefinition;
                if (baseTypes != null)
                {
                    ClassificationTypeImpl baseType = null;

                    foreach (string baseClassificationType in baseTypes)
                    {
                        ClassificationKey baseKey = new ClassificationKey(baseClassificationType);
                        if (!classificationTypes.TryGetValue(baseKey, out baseType))
                        {
                            baseType = new ClassificationTypeImpl(baseClassificationType);
                            classificationTypes.Add(baseKey, baseType);
                        }

                        type.AddBaseType(baseType);
                    }
                }
            }
        }
 internal ClassificationTypeImpl(ClassificationKey key)
 {
     this.key = key;
 }