public Model.File GetFile(string pageUrl, TokenParser parser, bool ignoreDefault)
        {
            Model.File file = null;
            if (pageUrl.StartsWith(Web.ServerRelativeUrl, StringComparison.OrdinalIgnoreCase))
            {
                var provider = new WebPartsModelProvider(Web);
                var webPartsModels = provider.Retrieve(pageUrl, parser);

                var needToOverride = this.NeedToOverrideFile(Web, pageUrl);

                if ( !ignoreDefault || needToOverride || (1 != webPartsModels.Count) || !WebPartsModelProvider.IsWebPartDefault(webPartsModels[0]))
                {
                    var folderPath = this.GetFolderPath(pageUrl);
                    var localFilePath = this.GetFilePath(pageUrl);
                    file = new Model.File(localFilePath, folderPath, needToOverride, webPartsModels, null);
                }
            }
            return file;
        }
        private ProvisioningTemplate GetFileContents(Web web, ProvisioningTemplate template, TokenParser parser, string welcomePageUrl, ProvisioningTemplateCreationInformation creationInfo, PnPMonitoredScope scope)
        {
            var fullUri = new Uri(UrlUtility.Combine(web.Url, web.RootFolder.WelcomePage));

            var folderPath = fullUri.Segments.Take(fullUri.Segments.Count() - 1).ToArray().Aggregate((i, x) => i + x).TrimEnd('/');
            var fileName = fullUri.Segments[fullUri.Segments.Count() - 1];

            var webParts = web.GetWebParts(welcomePageUrl);

            var file = web.GetFileByServerRelativeUrl(welcomePageUrl);

            var homeFile = new Model.File()
            {
                Folder = TokenizeUrl(folderPath, parser),
                Src = fileName,
                Overwrite = true,
            };
            // Add field values to file
            //RetrieveFieldValues(web, file, homeFile);

            WebPartsModelProvider webpartsProvider = new WebPartsModelProvider(web);
            var webparts = webpartsProvider.Retrieve(welcomePageUrl, parser);
            homeFile.WebParts.AddRange(webparts);

            template.Files.Add(homeFile);

            // Persist file using connector
            if (creationInfo.PersistBrandingFiles)
            {
                PersistFile(web, creationInfo, scope, folderPath, fileName);
            }
            return template;
        }