Пример #1
0
 public bool TryGetMountPoint(string mountPointUri, out IMountPoint mountPoint)
 {
     if (_disposed)
     {
         throw new ObjectDisposedException(nameof(SettingsLoader));
     }
     return(MountPointManager.TryDemandMountPoint(mountPointUri, out mountPoint));
 }
Пример #2
0
        public ITemplate?LoadTemplate(ITemplateInfo info, string baselineName)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(nameof(SettingsLoader));
            }

            IGenerator generator;

            if (!Components.TryGetComponent(info.GeneratorId, out generator))
            {
                return(null);
            }

            IMountPoint mountPoint;

            if (!MountPointManager.TryDemandMountPoint(info.MountPointUri, out mountPoint))
            {
                return(null);
            }
            IFileSystemInfo config = mountPoint.FileSystemInfo(info.ConfigPlace);

            IFileSystemInfo?localeConfig = null;

            if (!string.IsNullOrEmpty(info.LocaleConfigPlace) &&
                !string.IsNullOrEmpty(info.MountPointUri))
            {
                IMountPoint localeMountPoint;
                if (!MountPointManager.TryDemandMountPoint(info.MountPointUri, out localeMountPoint))
                {
                    // TODO: decide if we should proceed without loc info, instead of bailing.
                    return(null);
                }

                localeConfig = localeMountPoint.FileSystemInfo(info.LocaleConfigPlace);
            }

            IFile?hostTemplateConfigFile = FindBestHostTemplateConfigFile(config);

            ITemplate template;

            using (Timing.Over(_environmentSettings.Host, "Template from config"))
            {
                if (generator.TryGetTemplateFromConfigInfo(config, out template, localeConfig, hostTemplateConfigFile, baselineName))
                {
                    return(template);
                }
                else
                {
                    //TODO: Log the failure to read the template info
                }
            }

            return(null);
        }