public static void execute() { foreach (string tmpName in dicInject.Keys) { iInjector owner = dicInject[tmpName]; List <iTemplate> tmpList = dicTemplates[tmpName]; iInputValue inputVO = dicInput[tmpName]; iInitValue initVO = dicInit[tmpName]; FileSettingText setting = dicSetting[tmpName]; owner.init(initVO); owner.inject(inputVO, tmpList); foreach (iTemplate iTemp in tmpList) { string FileName = iTemp.GetType().ToString(); string writeContent = iTemp.TransformText(); string directoryPath = setting.SaveTo; string filePath = directoryPath + FileName; File.WriteAllText(filePath, writeContent); } } }
static void reflect(IEnumerable <FileSettingText> configs) { Assembly[] AssembliesLoaded = AppDomain.CurrentDomain.GetAssemblies(); foreach (FileSettingText config in configs) { foreach (InjectSettingText injSetting in config.InjectSettings) { string path = injSetting.Assembly; var assemblies = new Assembly[] { Assembly.LoadFile(path) }; iInjector injectObj = Global.getTypedObject <iInjector>(assemblies, injSetting.Injector); if (injectObj == null) { Global.LogError(""); continue; } IEnumerable <string> aaa = injSetting.Templates.Trim('[', ']').Split(',').Select(obj => obj.Trim()); List <iTemplate> templateList = new List <iTemplate>(); foreach (string templates in aaa) { iTemplate template = Global.getTypedObject <iTemplate>(assemblies, templates); if (template == null) { Global.LogError(""); continue; } templateList.Add(template); } iInitValue initValue = injectObj.getInitValue(); iInputValue inputValue = injectObj.getInputValue(); initValue.setValue(injSetting.InitValue); inputValue.setValue(injSetting.InputValue); Global.dicTemplates.Add(config.Name, templateList); Global.dicInput.Add(config.Name, inputValue); Global.dicInit.Add(config.Name, initValue); Global.dicInject.Add(config.Name, injectObj); } Global.dicSetting.Add(config.Name, config); } }