示例#1
0
 private static void ExtractWrokflow(XmlNode workflowRoot, SingleWorkflowStep root)
 {
     var workflowSteps = workflowRoot.GetChildrenByTag(new List<string>(_availableStepsSpecs.Keys).ToArray());
     for (int i = 0; i < workflowSteps.Count; i++)
     {
         var workflowStep = workflowSteps[i];
         var newStep = SetupStepFactory.CreateStep(workflowStep);
         if (workflowStep.GetAttribute("include") != null)
         {
             LoadExternalWorkflowSteps(workflowStep.GetAttribute("include"), newStep, workflowStep.GetAttribute("assemblyPath"));
         }
         ExtractWrokflow(workflowStep, newStep);
         root.WorkflowSteps.Add(newStep);
     }
 }
示例#2
0
        private static void ExtractTemplates(XmlNode rootTemplates)
        {
            var templates = rootTemplates.GetChildrenByTag("template");
            for (int i = 0; i < templates.Count; i++)
            {
                var template = templates[i];

                var setupTemplate = new SetupTemplate
                {
                    Content = template.InnerText.Trim('\r', '\n', '\f') + "\n",
                    Id = template.GetAttribute("id")
                };
                _setupFile.SetupTemplates.Add(setupTemplate.Id, setupTemplate);
            }
        }
示例#3
0
        private static void ExtractDlls(XmlNode rootDlls)
        {
            _availableStepsSpecs = new Dictionary<string, SingleWorkflowStep>();
            var dlls = rootDlls.GetChildrenByTag("dll");

            for (int i = 0; i < dlls.Count; i++)
            {
                var listOfAvailablePaths = new List<string>(_templatesDirectories.ToArray());

                var dll = dlls[i];
                var location = dll.GetAttribute("location");
                var dllName = dll.GetAttribute("name");

                listOfAvailablePaths.Add(location);
                listOfAvailablePaths.Add(Environment.CurrentDirectory);
                listOfAvailablePaths.Add(Environment.SystemDirectory);
                listOfAvailablePaths.Add(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

                if (!AssembliesManager.LoadAssemblyFrom(dllName, null,
                    listOfAvailablePaths.ToArray()))
                {
                    throw new FileNotFoundException("Impossible to load assembly", dllName);
                }
            }

            var loaders = new List<Type>(AssembliesManager.LoadTypesInheritingFrom(typeof(IOnLoad))).ToArray();
            foreach (var loader in loaders)
            {
                var step = (IOnLoad)Activator.CreateInstance(loader);
                step.Initialize();
            }

            var files = new List<Type>( AssembliesManager.LoadTypesInheritingFrom(typeof (SingleWorkflowStep))).ToArray();
            foreach (var stepType in files)
            {
                var step = (SingleWorkflowStep) Activator.CreateInstance(stepType);
                if (step.GetNodeType()!=null)
                {
                    if (!_availableStepsSpecs.ContainsKey(step.GetNodeType()))
                    {
                        _availableStepsSpecs.Add(step.GetNodeType(), step);
                    }
                }
            }

            var factories = new List<Type>(AssembliesManager.LoadTypesInheritingFrom(typeof(BaseStepFactory))).ToArray();
            foreach (var factory in factories)
            {
                var stepFactory = (BaseStepFactory)Activator.CreateInstance(factory);
                SetupStepFactory.AddFactory(stepFactory);
            }
        }
示例#4
0
        private static void ExtractConfigs(XmlNode rootConfig)
        {
            var configs = rootConfig.GetChildrenByTag("config");
            for (int i = 0; i < configs.Count; i++)
            {
                var config = configs[i];
                ConfigTypes configType;
                if (!ConfigTypes.TryParse(config.GetAttribute("type"), true, out configType))
                {
                    configType = ConfigTypes.Value;
                }

                var setupConfig = new SetupConfig
                {
                    Key = config.GetAttribute("key"),
                    AllowNone = config.GetAttributeBool("allownone"),
                    ConfigType = configType,
                    Help = config.GetAttribute("help"),
                    Default = config.GetAttribute("default")
                };
                ExtractAvailableConfigs(config, setupConfig);
                _setupFile.SetupConfigs.Add(setupConfig.Key, setupConfig);
            }

            AddYesNoConfig();
        }
示例#5
0
        private static void ExtractBaseTemplates(XmlNode baseTemplates)
        {
            var templates = baseTemplates.GetChildrenByTag("baseTemplate");
            for (int i = 0; i < templates.Count; i++)
            {
                var template = templates[i];

                var templateFile = template.GetAttribute("templateFile");
                string templateFileContent = null;
                if (templateFile != null)
                {
                    if (templateFile.StartsWith("res:"))
                    {
                        templateFileContent = LoadAssemblyResource(templateFile, template.GetAttribute("assemblyPath"));
                    }
                    else
                    {
                        templateFile = Path.Combine(_templatesDirectory, templateFile);
                        if (File.Exists(templateFile))
                        {
                            templateFileContent = File.ReadAllText(templateFile);
                        }
                    }
                }
                if (templateFileContent == null)
                {
                    templateFileContent = template.InnerText;
                }
                templateFileContent = templateFileContent.Trim('\r', '\n', '\f') + "\n";
                if (templateFile != null && File.Exists(templateFile))
                {
                    templateFileContent = File.ReadAllText(templateFile).Trim('\r', '\n', '\f') + "\n";
                }
                var setupTemplate = new SetupBaseTemplate
                {
                    Content = templateFileContent,
                    Id = template.GetAttribute("id"),
                    TemplateSourceFile = template.GetAttribute("templateFile"),
                    IsXml = template.GetAttributeBool("isxml")
                };
                _setupFile.BaseTemplates.Add(setupTemplate.Id, setupTemplate);
            }
        }
示例#6
0
        private static void ExtractAvailableConfigs(XmlNode config, SetupConfig setupConfig)
        {
            var availables = config.GetChildrenByTag("available");
            for (int i = 0; i < availables.Count; i++)
            {
                var available = availables[i];

                var availableConfig = new SetupAvailable
                {
                    Value = available.GetAttribute("value"),
                    Help = available.GetAttribute("help"),
                    IsNull = false
                };

                ExtractWrokflow(available, availableConfig);
                setupConfig.SetupChoices.Add(availableConfig);
            }
            AddEmptyChoice(setupConfig);
        }