protected internal virtual IPageType CreateNewPageType(PageTypeDefinition definition)
        {
            IPageType pageType = PageTypeRepository.CreateNew();

            PageTypeAttribute attribute = definition.Attribute;

            string name = attribute.Name;

            if (name == null)
            {
                name = definition.Type.Name;
            }
            pageType.Name = name;

            if (definition.Attribute.Guid.HasValue)
            {
                pageType.GUID = definition.Attribute.Guid.Value;
            }

            string filename = attribute.Filename;

            if (string.IsNullOrEmpty(filename))
            {
                filename = DefaultFilename;
            }
            pageType.FileName = filename;

            PageTypeRepository.Save(pageType);

            NewlyCreatedPageTypes.Add(pageType);
            return(pageType);
        }
        protected internal virtual void UpdatePageType(PageTypeDefinition definition)
        {
            IPageType         pageType       = GetExistingPageType(definition);
            PageTypeAttribute attribute      = definition.Attribute;
            string            oldValueString = SerializeValues(pageType);

            UpdateName(pageType, definition);
            UpdateFilename(pageType, attribute);
            UpdateSortOrder(pageType, attribute);
            UpdateDescription(pageType, attribute);
            UpdateIsAvailable(pageType, attribute);
            UpdateDefaultArchivePageLink(pageType, attribute);
            UpdateDefaultChildOrderRule(pageType, attribute);
            UpdateDefaultPageName(pageType, attribute);
            UpdateDefaultPeerOrder(pageType, attribute);
            UpdateDefaultStartPublishOffset(pageType, attribute);
            UpdateDefaultStopPublishOffset(pageType, attribute);
            UpdateDefaultVisibleInMenu(pageType, attribute);
            UpdateFrame(pageType, attribute);

            bool availablePageTypesSet = false;

            if (CanModifyProperty(pageType, attribute.AvailablePageTypesSet))
            {
                UpdateAvailablePageTypes(pageType, attribute.AvailablePageTypes);

                if (attribute.AvailablePageTypes != null && attribute.AvailablePageTypes.Length > 0)
                {
                    availablePageTypesSet = true;
                }
            }

            if (!availablePageTypesSet && CanModifyProperty(pageType, attribute.ExcludedPageTypesSet) && attribute.ExcludedPageTypes != null)
            {
                UpdateAvailablePageTypesExcluded(pageType, attribute.ExcludedPageTypes);
            }

            string newValuesString = SerializeValues(pageType);

            if (newValuesString != oldValueString)
            {
                PageTypeRepository.Save(pageType);
            }
        }