Beispiel #1
0
        /// <summary>
        /// Searches for a <see cref="IScriptingProvider"/> that can execute the script type as stated in <see cref="ScriptTypeKey"/> and invokes the script.
        /// </summary>
        /// <param name="context"></param>
        protected override void RetrieveData(IGenerationContext context)
        {
            IScriptingProvider[] matchingProviders = context.Engine.Extensions.Get <IScriptingProvider>().Where(_ => _.CanExecute(this.ScriptTypeKey)).ToArray();

            /* We need at least one matching provider. If there is more than one matching provider, take the first one and maybe omit warning.
             */
            if (matchingProviders.Length > 0)
            {
                IScriptingProvider prov = matchingProviders.First();

                ScriptExecutionOptions options = new ScriptExecutionOptions();
                options.AssociatedDataProvider = this;
                options.DesiredReturnValueType = typeof(DataSet);

                try
                {
                    object ret = prov.Execute(this.ScriptText, options);

                    DataSet ds = ret as DataSet;

                    if (ds != null)
                    {
                        this.CurrentData = ds;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Beispiel #2
0
        IScriptingProvider CreateScriptingProvider()
        {
            lock (typeof(IScriptingProvider))
            {
                if (_scriptingProvider == null) // double checked lock
                {
                    //TODO: [Import(typeof(IScriptingProvider)]
                    _scriptingProvider = new UnsupportedScriptingProvider();
                }
            }

            return(_scriptingProvider);
        }