예제 #1
0
            public bool LoadAssembly(string jobScriptAssemblyPath)
            {
                var jobScriptAssembly = AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(jobScriptAssemblyPath));

                Type handlerInitializerType = null;

                foreach (var type in jobScriptAssembly.GetTypes())
                {
                    if (typeof(IHandlerInitializer).IsAssignableFrom(type))
                    {
                        handlerInitializerType = type;
                        break;
                    }
                }

                if (handlerInitializerType == null)
                {
                    return(false);
                }

                // Initialize the handler initializer
                var jobInstance = (IHandlerInitializer)Activator.CreateInstance(handlerInitializerType);

                // Read the settings
                _handlerSettings = jobInstance.GetHandlerSettings();
                _customSettings  = jobInstance.GetCustomHandlerSettings();
                return(true);
            }
예제 #2
0
        /// <summary>
        /// Loads the assembly into the current domain and reads the handler and custom settings
        /// </summary>
        public static bool LoadAssemblyAndReadSettings(string jobAssemblyPath, out HandlerSettings handlerSettings, out IHandlerCustomSettings customSettings)
        {
            handlerSettings = null;
            customSettings  = null;
            var loader         = new JobAssemblyLoader();
            var loadingSuccess = loader.LoadAssembly(jobAssemblyPath);

            if (!loadingSuccess)
            {
                return(false);
            }
            handlerSettings = loader.GetHandlerSettings();
            customSettings  = loader.GetCustomSettings();
            return(true);
        }