Exemple #1
0
        private object CreateInstance(ConfigInfo config,
                                      string key)
        {
            Hashtable mapping = config.GetMappingEntries();
            Hashtable dllPath = config.GetOuterDLLPaths();
            string    impl    = (string)mapping[key];
            string    path    = (string)dllPath[key];

            if (impl == null)
            {
                if (Version.DEBUG)
                {
                    System.Console.WriteLine("the method node's field <impl> is null");
                }
                return(null);
            }
            if (path != null)
            {
                IEnv e = (IEnv)DynamicCreator.CreateInstance(impl, path);
                e.SetEnv(_env);
                return(e);
            }

            Type type = null;

            try
            {
                Assembly assembly = this.GetType().Assembly;
                type = assembly.GetType(impl);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                return(null);
            }

            IEnv env = (IEnv)DynamicCreator.CreateInstance(type);

            env.SetEnv(_env);

            return(env);
        }