예제 #1
0
        /// <summary>
        /// Check a folder and all sub folders in Sitecore for templates
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="sqlDataProvider">The SQL data provider.</param>
        /// <param name="context">The context.</param>
        /// <returns>
        /// True of the folder is deleted itself.
        /// </returns>
        private bool RemoveDeletedClasses(ItemDefinition folder, DataProvider sqlDataProvider, CallContext context)
        {
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }
            if (sqlDataProvider == null)
            {
                throw new ArgumentNullException("sqlDataProvider");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var childIds = sqlDataProvider.GetChildIDs(folder, context);

            //check child items
            foreach (ID childId in childIds.ToArray())
            {
                var childDefinition = sqlDataProvider.GetItemDefinition(childId, context);

                //if child is template check the template still exists in the code base
                if (childDefinition.TemplateID == TemplateTemplateId)
                {
                    if (TypeConfigurations.Any(x => x.Value.TemplateId == childDefinition.ID && x.Value.CodeFirst))
                    {
                        continue;
                    }

                    sqlDataProvider.DeleteItem(childDefinition, context);
                    childIds.Remove(childDefinition.ID);
                }
                // if the child is a folder check the children of the folder
                else if (childDefinition.TemplateID == FolderTemplateId)
                {
                    //if the folder itself is deleted then remove from the parent
                    if (RemoveDeletedClasses(childDefinition, sqlDataProvider, context))
                    {
                        childIds.Remove(childDefinition.ID);
                    }
                }
            }

            //if there are no children left delete the folder
            if (childIds.Count == 0 && folder.ID != GlassFolderId)
            {
                sqlDataProvider.DeleteItem(folder, context);
                return(true);
            }

            return(false);
        }
예제 #2
0
        TypeMap IProfileConfiguration.ConfigureConventionTypeMap(TypeMapRegistry typeMapRegistry, TypePair types)
        {
            if (!TypeConfigurations.Any(c => c.IsMatch(types)))
            {
                return(null);
            }

            var typeMap = _typeMapFactory.CreateTypeMap(types.SourceType, types.DestinationType, this, MemberList.Destination);

            var config = new MappingExpression(typeMap.Types, typeMap.ConfiguredMemberList);

            config.Configure(this, typeMap);

            Configure(typeMapRegistry, typeMap);

            return(typeMap);
        }
예제 #3
0
 public bool IsConventionMap(TypePair types) => TypeConfigurations.Any(c => c.IsMatch(types));