示例#1
0
        public static void Dump(this IEnumerable <String> result)
        {
            QueryExecutionContext context = QueryExecutionContext.Current;
            Action <object>       onNext;
            Action <Exception>    onError;
            Action onComplete;

            context.OnDumpStart(typeof(StringWrapper), result,
                                out onNext,
                                out onComplete,
                                out onError);

            if (onNext != null)
            {
                try
                {
                    foreach (var item in result)
                    {
                        onNext(new StringWrapper {
                            Value = item
                        });
                    }
                }
                catch (Exception ex)
                {
                    onError(ex);
                }
                finally
                {
                    onComplete();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Enumerble collections should have playback run already and hence we only call onNext.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="result"></param>
        public static void Dump <T>(this IEnumerable <T> result)
        {
            QueryExecutionContext context = QueryExecutionContext.Current;
            Action <object>       onNext;
            Action <Exception>    onError;
            Action onComplete;

            context.OnDumpStart(typeof(T), result,
                                out onNext,
                                out onComplete,
                                out onError);

            try
            {
                if (onNext != null)
                {
                    foreach (var item in result)
                    {
                        onNext(item);
                    }
                }
            }
            catch (Exception ex)
            {
                onError(ex);
            }
            finally
            {
                onComplete();
            }
        }
示例#3
0
        public static void Dump(this SequenceDiagram result)
        {
            QueryExecutionContext context = QueryExecutionContext.Current;
            Action <object>       onNext;
            Action <Exception>    onError;
            Action onComplete;

            context.OnDumpStart(typeof(SequenceDiagram), result,
                                out onNext,
                                out onComplete,
                                out onError);
            try
            {
                if (onNext != null)
                {
                    onNext(result);
                }
            }
            catch (Exception ex)
            {
                onError(ex);
            }
            finally
            {
                onComplete();
            }
        }
        internal static QueryExecutionContext CreateFromFiles(IList <string> etlfiles, Action <Type> onStart, Action <object> onNext)
        {
            Playback playback = new Playback();

            foreach (var item in etlfiles)
            {
                playback.AddEtlFiles(item);
            }

            Func <Type, object, Action <object> > v = (t, o) =>
            {
                onStart(t);
                return(onNext);
            };
            QueryExecutionContext context = new QueryExecutionContext(playback, v);

            playback.KnownTypes = ManifestCompiler.GetKnowntypesforPlayback();
            return(context);
        }
示例#5
0
        public static void Dump <T>(this IObservable <IList <T> > result)
        {
            QueryExecutionContext context = QueryExecutionContext.Current;
            Action <object>       onNext;
            Action <Exception>    onError;
            Action onComplete;

            context.OnDumpStart(typeof(T), result,
                                out onNext,
                                out onComplete,
                                out onError);
            try
            {
                if (onNext != null)
                {
                    result
                    .Finally(() =>
                    {
                        onComplete();
                    })
                    .Subscribe(
                        (data) =>
                    {
                        try
                        {
                            foreach (var item in data)
                            {
                                onNext(item);
                            }
                        }
                        catch (Exception ex)
                        {
                            onError(ex);
                            throw;
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                onError(ex);
            }
        }
示例#6
0
        public static bool CompileAndRun(QueryExecutionContext context,
                                         string query,
                                         TextWriter errorLogger,
                                         TextWriter logger,
                                         Dictionary <string, object> playbackProperties = null)
        {
            try
            {
                EnsureTemporaryCache();
                Assembly assembly = null;
                Logger.Log("Compiling Query \n" + query);

                if (string.IsNullOrEmpty(query))
                {
                    errorLogger.Write("No query present to execute.");
                    return(false);
                }

                if (!AssemblyCache.TryGetValue(query, out assembly))
                {
                    string usings = GetUsings();
                    assembly = GenerateAssembly(usings, query, errorLogger, logger);
                    if (assembly != null)
                    {
                        AssemblyCache[query] = assembly;
                    }
                }

                if (assembly != null)
                {
                    object t = Activator.CreateInstance(assembly.GetType("QueryExecutionTemplate.PlaybackWrapper"), context.Playback, logger);

                    if (playbackProperties != null)
                    {
                        foreach (var extraParam in playbackProperties)
                        {
                            t.GetType().GetProperty(extraParam.Key).SetValue(t, extraParam.Value, null);
                        }
                    }
                    QueryExecutionContext.Current = context;
                    bool result = (bool)t.GetType().GetMethod("CompileQuery").Invoke(t, null);
                    if (result == false)
                    {
                        Exception ex = (Exception)t.GetType().GetProperty("Exception").GetValue(t, null);
                        context.SetException(ex);
                    }
                    else
                    {
                        context.Run();
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                context.SetException(ex);
                errorLogger.WriteLine(ex.Message);
            }

            return(false);
        }
示例#7
0
        internal static QueryExecutionContext CreateFromFiles(IList<string> etlfiles, Action<Type> onStart, Action<object> onNext)
        {
            Playback playback = new Playback();
            foreach (var item in etlfiles)
            {
                playback.AddEtlFiles(item);
            }

            Func<Type, object, Action<object>> v = (t, o) =>
                {
                    onStart(t);
                    return onNext;
                };
            QueryExecutionContext context = new QueryExecutionContext(playback, v);
            playback.KnownTypes = ManifestCompiler.GetKnowntypesforPlayback();
            return context;
        }
示例#8
0
        public static bool CompileAndRun(QueryExecutionContext context,
            string query,
            TextWriter errorLogger,
            TextWriter logger,
            Dictionary<string, object> playbackProperties = null)
        {
            try
            {
                EnsureTemporaryCache();
                Assembly assembly = null;
                Logger.Log("Compiling Query \n" + query);

                if (string.IsNullOrEmpty(query))
                {
                    errorLogger.Write("No query present to execute.");
                    return false;
                }

                if (!AssemblyCache.TryGetValue(query, out assembly))
                {
                    string usings = GetUsings();
                    assembly = GenerateAssembly(usings, query, errorLogger, logger);
                    if (assembly != null)
                    {
                        AssemblyCache[query] = assembly;
                    }
                }

                if (assembly != null)
                {
                    object t = Activator.CreateInstance(assembly.GetType("QueryExecutionTemplate.PlaybackWrapper"), context.Playback, logger);

                    if (playbackProperties != null)
                    {
                        foreach (var extraParam in playbackProperties)
                        {
                            t.GetType().GetProperty(extraParam.Key).SetValue(t, extraParam.Value, null);
                        }
                    }
                    QueryExecutionContext.Current = context;
                    bool result = (bool)t.GetType().GetMethod("CompileQuery").Invoke(t, null);
                    if (result == false)
                    {
                        Exception ex = (Exception)t.GetType().GetProperty("Exception").GetValue(t, null);
                        context.SetException(ex);
                    }
                    else
                    {
                        context.Run();
                    }
                    return result;
                }
            }
            catch (Exception ex)
            {
                context.SetException(ex);
                errorLogger.WriteLine(ex.Message);
            }

            return false;
        }