Пример #1
0
        private static bool CompareAllowedTemplates(IContentType contentType, DocumentTypeAttribute docTypeAttr, Type typeDocType)
        {
            List<ITemplate> allowedTemplates = DocumentTypeManager.GetAllowedTemplates(docTypeAttr, typeDocType);

            IEnumerable<ITemplate> existingTemplates = contentType.AllowedTemplates;

            if (allowedTemplates.Count != existingTemplates.Count())
            {
                return false;
            }

            foreach (Template template in allowedTemplates)
            {
                if (!existingTemplates.Any(t => t.Alias == template.Alias))
                {
                    return false;
                }
            }

            ITemplate defaultTemplate = DocumentTypeManager.GetDefaultTemplate(docTypeAttr, typeDocType, allowedTemplates);

            if (defaultTemplate != null)
            {
                return (contentType.DefaultTemplate.Id == defaultTemplate.Id);
            }

            if (allowedTemplates.Count == 1)
            {
                return (contentType.DefaultTemplate.Id == allowedTemplates.First().Id);
            }

            return true;
        }
Пример #2
0
        private static bool CompareAllowedTemplates(IContentType contentType, DocumentTypeAttribute docTypeAttr, Type typeDocType)
        {
            List <ITemplate> allowedTemplates = DocumentTypeManager.GetAllowedTemplates(docTypeAttr, typeDocType);

            IEnumerable <ITemplate> existingTemplates = contentType.AllowedTemplates;

            if (allowedTemplates.Count != existingTemplates.Count())
            {
                return(false);
            }

            foreach (Template template in allowedTemplates)
            {
                if (!existingTemplates.Any(t => t.Alias == template.Alias))
                {
                    return(false);
                }
            }

            ITemplate defaultTemplate = DocumentTypeManager.GetDefaultTemplate(docTypeAttr, typeDocType, allowedTemplates);

            if (defaultTemplate != null)
            {
                return(contentType.DefaultTemplate.Id == defaultTemplate.Id);
            }

            if (allowedTemplates.Count == 1)
            {
                return(contentType.DefaultTemplate.Id == allowedTemplates.First().Id);
            }

            return(true);
        }
 public DocumentTypeRegistration(IEnumerable <PropertyRegistration> properties, IEnumerable <TabRegistration> tabs, IEnumerable <ContentTypeCompositionRegistration> compositions, string alias, string name, Type clrType, DocumentTypeAttribute documentTypeAttribute)
     : base(properties, tabs, compositions, alias, name, clrType, documentTypeAttribute)
 {
 }
Пример #4
0
        private static bool IsUnchanged(Type typeDocType, Type parentDocType, IContentType contentType)
        {
            DocumentTypeAttribute docTypeAttr = DocumentTypeManager.GetDocumentTypeAttribute(typeDocType);

            if (docTypeAttr.Mixins != null)
            {
                // update this document type since it depends on others
                return(false);
            }

            string docTypeName  = String.IsNullOrEmpty(docTypeAttr.Name) ? typeDocType.Name : docTypeAttr.Name;
            string docTypeAlias = DocumentTypeManager.GetDocumentTypeAlias(typeDocType);


            if (contentType.Name != docTypeName)
            {
                return(false);
            }

            if (contentType.Alias != docTypeAlias)
            {
                return(false);
            }

            if (contentType.Icon != docTypeAttr.IconUrl)
            {
                return(false);
            }

            if (contentType.Thumbnail != docTypeAttr.Thumbnail)
            {
                return(false);
            }

            if (contentType.Description != docTypeAttr.Description)
            {
                return(false);
            }

            if (contentType.ParentId != -1)
            {
                if (parentDocType == typeof(DocumentTypeBase))
                {
                    return(false);
                }

                var existingParentDocumentType = ContentTypeService.GetContentType(contentType.ParentId);

                if (existingParentDocumentType.Alias != DocumentTypeManager.GetDocumentTypeAlias(parentDocType))
                {
                    return(false);
                }
            }
            else
            {
                if (parentDocType != typeof(DocumentTypeBase))
                {
                    return(false);
                }
            }

#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            if (!CompareContentTypeProperties(typeDocType, contentType))
            {
                return(false);
            }

#if DEBUG
            timer.Stop();
            //StopwatchLogger.AddToLog(string.Format("Total elapsed time for method 'DocumentTypeComparer.IsUnchanged' - CompareContentTypeProperties: {0}ms.", timer.ElapsedMilliseconds));
            timer.Restart();
#endif

            if (!CompareAllowedTemplates(contentType, docTypeAttr, typeDocType))
            {
                return(false);
            }

            if (contentType.AllowedAsRoot != docTypeAttr.AllowAtRoot)
            {
                return(false);
            }

            return(true);
        }
 private static void SetDocumentTypeValues(DocumentType documentType, int masterDocumentTypeId, DocumentTypeAttribute attribute)
 {
     SetDocumentTypeNameIfDifferent(documentType, attribute.Name);
     SetDocumentTypeDescriptionIfDifferent(documentType, attribute.Description);
     SetDocumentTypeIconIfDifferent(documentType, attribute.IconUrl);
     SetDocumentTypeThumbnailIfDifferent(documentType, attribute.ThumbnailUrl);
     SetDocumentTypeMasterIfDifferent(documentType, masterDocumentTypeId);
 }