Пример #1
0
        public void RegisterStoreTests()
        {
            using (var registry = new RegisterStore())
            {
                var test11  = new Test11();
                var test112 = new Test11();
                var test12  = new Test12();
                var test21  = new Test21();
                registry.Register <ITest1>(test11);
                registry.Register <ITest1>(test12);
                registry.Register <ITest1>(test112);
                registry.Register <ITest2>(test21);

                Assert.IsTrue(registry.GetRegistered <ITest1>().SequenceEqual(new ITest1[] { test11, test12, test112 }));
                Assert.IsTrue(registry.GetRegistered <ITest2>().SequenceEqual(new ITest2[] { test21 }));
            }
        }
Пример #2
0
        public void LoadTemplates(string templateRoot)
        {
            // Registrierte (Standard-)Templates laden
            var instances = store.GetRegistered <ITemplateProxy>();

            templates = instances.Select(t => new TemplateHost(t.GetTemplateCode(), t.TemplateIdentifier, logger, true)).ToList();

            // Weitere Templates aus Dateien laden
            var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), templateRoot);
            var info = new DirectoryInfo(path);

            if (!info.Exists)
            {
                return;
            }

            var files = info.GetFiles("*.fpltmpl");

            foreach (var file in files)
            {
                var content = File.ReadAllText(file.FullName);
                templates.Add(new TemplateHost(content, file.Name, logger, enabledTemplates.Contains(file.Name)));
            }
        }
Пример #3
0
        public void LoadTemplates(string templateRoot)
        {
            // Registrierte (Standard-)Templates laden
            var instances = store.GetRegistered <ITemplateProvider>();

            templates = instances.Select(t => new TemplateHost(t.GetTemplateCode(), t.TemplateIdentifier, this.pluginInterface, true)).ToList();

            // Weitere Templates aus Dateien laden
            var path = Path.Combine(PathManager.Instance.AppDirectory, templateRoot);
            var dir  = new DirectoryInfo(path);

            if (!dir.Exists)
            {
                return;
            }

            var files = dir.GetFiles("*.fpltmpl");

            foreach (var file in files)
            {
                var content = File.ReadAllText(file.FullName);
                templates.Add(new TemplateHost(content, file.Name, this.pluginInterface, enabledTemplates.Contains(file.Name)));
            }
        }