예제 #1
0
        public static object CreateInstance(string assemblyName, string typeName)
        {
            if (string.IsNullOrWhiteSpace(assemblyName))
            {
                throw new ArgumentNullException("assemblyName");
            }

            if (string.IsNullOrWhiteSpace(typeName))
            {
                throw new ArgumentNullException("typeName");
            }

            var type     = AssembliesManager.LoadType(assemblyName, typeName);
            var instance = type == null ? null : Activator.CreateInstance(type);

            if (instance != null)
            {
                Console.WriteLine(@"Instance of type {0} was created.", typeName);
            }
            else
            {
                Console.Error.WriteLine(@"Instance of type {0} was not created.", typeName);
            }

            return(instance);
        }