private List <Localization> LoadContentTypes(PnP.Framework.Provisioning.Model.ContentTypeCollection coll)
        {
            List <Localization> loc = new List <Localization>();

            foreach (PnP.Framework.Provisioning.Model.ContentType item in coll)
            {
                loc.Add(new Localization(item.Id, item.Name, item.Description));
            }

            return(loc);
        }
        /// <summary>
        /// Constructor for ProvisioningTemplate class
        /// </summary>
        public ProvisioningTemplate()
        {
            this.connector = new FileSystemConnector(".", "");

            this._localizations = new LocalizationCollection(this);
            this._siteFields    = new FieldCollection(this);
            this._contentTypes  = new ContentTypeCollection(this);
            this._propertyBags  = new PropertyBagEntryCollection(this);
            this._lists         = new ListInstanceCollection(this);

            this._siteSecurity = new SiteSecurity
            {
                ParentTemplate = this
            };

            this._composedLook = new ComposedLook
            {
                ParentTemplate = this
            };
            this._features = new Features
            {
                ParentTemplate = this
            };
            this._customActions = new CustomActions
            {
                ParentTemplate = this
            };

            this._files                 = new FileCollection(this);
            this._directories           = new DirectoryCollection(this);
            this._providers             = new ProviderCollection(this); // Deprecated
            this._extensibilityHandlers = new ExtensibilityHandlerCollection(this);
            this._pages                 = new PageCollection(this);
            this._termGroups            = new TermGroupCollection(this);

            this._supportedUILanguages = new SupportedUILanguageCollection(this);
            this._addins = new AddInCollection(this);

            this._siteWebhooks    = new SiteWebhookCollection(this);
            this._clientSidePages = new ClientSidePageCollection(this);

            this._tenant = new ProvisioningTenant
            {
                ParentTemplate = this
            };

            this._applicationLifecycleManagement = new ApplicationLifecycleManagement
            {
                ParentTemplate = this
            };

            this._provisioningTemplateWebhooks = new ProvisioningTemplateWebhookCollection(this);
        }
        public bool ValidateContentTypes(PnP.Framework.Provisioning.Model.ContentTypeCollection sElements, PnP.Framework.Provisioning.Model.ContentTypeCollection tElements, TokenParser sParser, TokenParser tParser)
        {
            List <Localization> sColl = LoadContentTypes(sElements);
            List <Localization> tColl = LoadContentTypes(tElements);

            if (sColl.Count > 0)
            {
                if (!Validatelocalization(sColl, tColl, sParser, tParser))
                {
                    return(false);
                }
            }

            return(true);
        }
        public bool Validate(PnP.Framework.Provisioning.Model.ContentTypeCollection sourceCollection, PnP.Framework.Provisioning.Model.ContentTypeCollection targetCollection, TokenParser tokenParser)
        {
            // Convert object collections to XML
            List <SerializedContentType> sourceContentTypes = new List <SerializedContentType>();
            List <SerializedContentType> targetContentTypes = new List <SerializedContentType>();

            foreach (PnP.Framework.Provisioning.Model.ContentType ct in sourceCollection)
            {
                ProvisioningTemplate pt = new ProvisioningTemplate();
                pt.ContentTypes.Add(ct);

                sourceContentTypes.Add(new SerializedContentType()
                {
                    SchemaXml = ExtractElementXml(pt)
                });
            }

            foreach (PnP.Framework.Provisioning.Model.ContentType ct in targetCollection)
            {
                ProvisioningTemplate pt = new ProvisioningTemplate();
                pt.ContentTypes.Add(ct);

                targetContentTypes.Add(new SerializedContentType()
                {
                    SchemaXml = ExtractElementXml(pt)
                });
            }

            // Use XML validation logic to compare source and target
            Dictionary <string, string[]> parserSettings = new Dictionary <string, string[]>
            {
                { "SchemaXml", null }
            };
            bool isContentTypeMatch = ValidateObjectsXML(sourceContentTypes, targetContentTypes, "SchemaXml", new List <string> {
                "ID"
            }, tokenParser, parserSettings);

            Console.WriteLine("-- Content type validation " + isContentTypeMatch);
            return(isContentTypeMatch);
        }