Exemple #1
0
        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);
            }
        }