private ProvisioningHierarchy GetHierarchy()
 {
     if (!System.IO.Path.IsPathRooted(Path))
     {
         Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path);
     }
     return(ReadProvisioningHierarchy.LoadProvisioningHierarchyFromFile(Path, TemplateProviderExtensions));
 }
Exemplo n.º 2
0
        private void ProcessFiles(string templateFileName, FileConnectorBase fileSystemConnector, FileConnectorBase connector)
        {
            var hierarchy = ReadProvisioningHierarchy.LoadProvisioningHierarchyFromFile(templateFileName, null);

            if (Hierarchy.Tenant?.AppCatalog != null)
            {
                foreach (var app in Hierarchy.Tenant.AppCatalog.Packages)
                {
                    WriteObject($"Processing {app.Src}");
                    AddFile(app.Src, hierarchy, fileSystemConnector, connector);
                }
            }
            if (Hierarchy.Tenant?.SiteScripts != null)
            {
                foreach (var siteScript in Hierarchy.Tenant.SiteScripts)
                {
                    WriteObject($"Processing {siteScript.JsonFilePath}");
                    AddFile(siteScript.JsonFilePath, hierarchy, fileSystemConnector, connector);
                }
            }
            if (Hierarchy.Localizations != null && Hierarchy.Localizations.Any())
            {
                foreach (var location in Hierarchy.Localizations)
                {
                    WriteObject($"Processing {location.ResourceFile}");
                    AddFile(location.ResourceFile, hierarchy, fileSystemConnector, connector);
                }
            }
            foreach (var template in Hierarchy.Templates)
            {
                if (template.WebSettings != null && template.WebSettings.SiteLogo != null)
                {
                    // is it a file?
                    var isFile = false;
                    using (var fileStream = fileSystemConnector.GetFileStream(template.WebSettings.SiteLogo))
                    {
                        isFile = fileStream != null;
                    }
                    if (isFile)
                    {
                        WriteObject($"Processing {template.WebSettings.SiteLogo}");
                        AddFile(template.WebSettings.SiteLogo, hierarchy, fileSystemConnector, connector);
                    }
                }
                if (template.Files.Any())
                {
                    foreach (var file in template.Files)
                    {
                        AddFile(file.Src, hierarchy, fileSystemConnector, connector);
                    }
                }
            }
        }