예제 #1
0
        protected override void OnInitialize()
        {
            Logger.Debug("OnInitialize: Enter");
            if (ProcessContext == null)
            {
                throw new AwarenessException("ProcessContext == null");
            }

            if (DatapoolManager == null)
            {
                throw new AwarenessException("DatapoolManager == null");
            }

            string scriptName = GrinderContext.GetProperty(ScriptFileKey);

            if (string.IsNullOrWhiteSpace(scriptName))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Missing property '{0}'", ScriptFileKey));
            }

            Logger.Trace(x => x("OnInitialize: scriptName = {0}", scriptName));
            ScriptWorker = CSScript.Evaluator.LoadFile(scriptName);
            if (!(ScriptWorker is IGrinderWorker))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Type '{0}', from script file '{1}', does not implement '{2}'", ScriptWorker.GetType(), scriptName, typeof(IGrinderWorker).FullName));
            }

            ProcessContext.InitializeAwareness(ScriptWorker);

            ((IGrinderWorker)ScriptWorker).Initialize();

            Logger.Debug(x => x("OnInitialize: Exit, ScriptWorker = {0}", ScriptWorker.GetType().FullName));
        }