Beispiel #1
0
        public IReadOnlyDictionary <string, IReadOnlyList <IFileChange2> > GetFileChanges(string targetBaseDir, IParameterSet parameters = null, IVariableCollection variables = null)
        {
            if (parameters == null)
            {
                parameters = new MockParameterSet();
            }

            if (variables == null)
            {
                variables = new VariableCollection();
            }

            IRunnableProjectConfig runnableConfig = TemplateConfigTestHelpers.ConfigFromSource(_environment, SourceMountPoint);
            IFileSystemInfo        configFileInfo = TemplateConfigTestHelpers.ConfigFileSystemInfo(SourceMountPoint, _configFile);

            runnableConfig.Evaluate(parameters, variables, configFileInfo);

            MockGlobalRunSpec runSpec   = new MockGlobalRunSpec();
            IDirectory        sourceDir = SourceMountPoint.DirectoryInfo("/");

            IOrchestrator2 basicOrchestrator         = new Core.Util.Orchestrator();
            RunnableProjectOrchestrator orchestrator = new RunnableProjectOrchestrator(basicOrchestrator);

            Dictionary <string, IReadOnlyList <IFileChange2> > changesByTarget = new Dictionary <string, IReadOnlyList <IFileChange2> >();

            foreach (FileSourceMatchInfo source in runnableConfig.Sources)
            {
                TemplateConfigTestHelpers.SetupFileSourceMatchersOnGlobalRunSpec(runSpec, source);
                string targetDirForSource            = Path.Combine(targetBaseDir, source.Target);
                IReadOnlyList <IFileChange2> changes = orchestrator.GetFileChanges(runSpec, sourceDir, targetDirForSource);
                changesByTarget[source.Target] = changes;
            }

            return(changesByTarget);
        }
Beispiel #2
0
        public void InstantiateTemplate(string targetBaseDir, IParameterSet parameters = null, IVariableCollection variables = null)
        {
            if (parameters == null)
            {
                parameters = new MockParameterSet();
            }

            if (variables == null)
            {
                variables = new VariableCollection();
            }

            IRunnableProjectConfig runnableConfig = TemplateConfigTestHelpers.ConfigFromSource(_environment, SourceMountPoint);
            IFileSystemInfo        configFileInfo = TemplateConfigTestHelpers.ConfigFileSystemInfo(SourceMountPoint, _configFile);

            runnableConfig.Evaluate(parameters, variables, configFileInfo);

            MockGlobalRunSpec runSpec = new MockGlobalRunSpec();

            runSpec.RootVariableCollection = variables;
            IDirectory sourceDir = SourceMountPoint.DirectoryInfo("/");

            IOrchestrator2 basicOrchestrator         = new Core.Util.Orchestrator();
            RunnableProjectOrchestrator orchestrator = new RunnableProjectOrchestrator(basicOrchestrator);

            foreach (FileSourceMatchInfo source in runnableConfig.Sources)
            {
                TemplateConfigTestHelpers.SetupFileSourceMatchersOnGlobalRunSpec(runSpec, source);
                string targetDirForSource = Path.Combine(targetBaseDir, source.Target);
                orchestrator.Run(runSpec, sourceDir, targetDirForSource);
            }
        }
        public TemplateEngineHost() : base(VSHost, FindTemplateHostVersion(), VSHostLocale)
        {
            MountPointFactory = new FileSystemMountPointFactory();
            Settings          = new EngineEnvironmentSettings(this, settings => new TemplateSettingsLoader(settings));
            Orchestrator      = new RunnableProjectOrchestrator(new Orchestrator());
            TemplateCreator   = new TemplateCreator(Settings);
            Generator         = new RunnableProjectGenerator();

            MountPointManager = new MountPointManager(Settings, ComponentManager);


            HostDefaults = new Dictionary <string, string>
            {
                ["HostIdentifier"] = HostIdentifier,
                ["Locale"]         = Locale,
                ["Version"]        = Version
            };

            UserTemplates = SettingsLoader.UserTemplateCache.TemplateInfo;

            MountPoints = new List <IMountPoint>();

            foreach (var mountPointInfo in SettingsLoader.MountPoints)
            {
                if (MountPointFactory.TryMount(MountPointManager, mountPointInfo, out var mountPoint))
                {
                    MountPoints.Add(mountPoint);
                }
            }
        }