예제 #1
1
        internal static Tuple <Type, string> Generate <TPayload>(StreamEventObservable <TPayload> streamEventObservable)
        {
            string errorMessages = null;

            try
            {
                var template     = new TemporalEgressTemplate(typeof(Empty), typeof(TPayload), typeof(TPayload), string.Empty, "StreamEvent", streamEventObservable.source.Properties.IsColumnar);
                var keyType      = typeof(Empty);
                var expandedCode = template.TransformText();

                var assemblyReferences = Transformer.AssemblyReferencesNeededFor(keyType, typeof(TPayload));
                assemblyReferences.Add(typeof(IStreamable <,>).GetTypeInfo().Assembly);
                assemblyReferences.Add(Transformer.GeneratedStreamMessageAssembly <Empty, TPayload>());

                var a = Transformer.CompileSourceCode(expandedCode, assemblyReferences, out errorMessages);
                var t = a.GetType(template.className);
                return(Tuple.Create(t, errorMessages));
            }
            catch
            {
                if (Config.CodegenOptions.DontFallBackToRowBasedExecution)
                {
                    throw new InvalidOperationException("Code Generation failed when it wasn't supposed to!");
                }
                return(Tuple.Create((Type)null, errorMessages));
            }
        }
        private EgressBoundary <Empty, TPayload, StreamEvent <TPayload> > GetPipe(IObserver <StreamEvent <TPayload> > observer)
        {
            var lookupKey         = CachedPipeLookupKey();
            var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => TemporalEgressTemplate.Generate(this));

            var instance    = Activator.CreateInstance(generatedPipeType.Item1, observer, this.container);
            var returnValue = (EgressBoundary <Empty, TPayload, StreamEvent <TPayload> >)instance;

            return(returnValue);
        }
        private EgressBoundary <PartitionKey <TKey>, TPayload, TResult> GetPipe(IObserver <TResult> observer)
        {
            var lookupKey         = CachedPipeLookupKey();
            var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => TemporalEgressTemplate.Generate(this));

            var instance    = Activator.CreateInstance(generatedPipeType.Item1, observer, this.container);
            var returnValue = (EgressBoundary <PartitionKey <TKey>, TPayload, TResult>)instance;

            return(returnValue);
        }
예제 #4
0
        private EgressBoundary <PartitionKey <TKey>, TPayload, TResult> GetPipe(IObserver <TResult> observer)
        {
            var lookupKey = CacheKey.Create(this.constructor.Body.ExpressionToCSharp(), this.source.Properties.IsColumnar);

            var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => TemporalEgressTemplate.Generate(this));

            var instance    = Activator.CreateInstance(generatedPipeType.Item1, observer, this.container);
            var returnValue = (EgressBoundary <PartitionKey <TKey>, TPayload, TResult>)instance;

            return(returnValue);
        }
예제 #5
0
        private EgressBoundary <PartitionKey <TKey>, TPayload, PartitionedStreamEvent <TKey, TPayload> > GetPipe(IObserver <PartitionedStreamEvent <TKey, TPayload> > observer)
        {
            var lookupKey = CacheKey.Create(this.source.Properties.IsColumnar);

            var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => TemporalEgressTemplate.Generate(this));

            var instance    = Activator.CreateInstance(generatedPipeType.Item1, observer, this.container);
            var returnValue = (EgressBoundary <PartitionKey <TKey>, TPayload, PartitionedStreamEvent <TKey, TPayload> >)instance;

            return(returnValue);
        }
        private bool CanGenerateColumnar()
        {
            if (typeof(TPayload).IsAnonymousTypeName())
            {
                return(false);
            }
            if (!typeof(TPayload).GetTypeInfo().IsVisible)
            {
                return(false);
            }

            var lookupKey         = CachedPipeLookupKey();
            var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => TemporalEgressTemplate.Generate(this));

            this.errorMessages = generatedPipeType.Item2;
            return(generatedPipeType.Item1 != null);
        }
예제 #7
0
        private bool CanGenerateColumnar()
        {
            if (typeof(TKey).IsAnonymousTypeName() || typeof(TPayload).IsAnonymousTypeName() || typeof(TResult).IsAnonymousTypeName())
            {
                return(false);
            }
            if (!typeof(TKey).GetTypeInfo().IsVisible || !typeof(TPayload).GetTypeInfo().IsVisible || !typeof(TResult).GetTypeInfo().IsVisible)
            {
                return(false);
            }

            var lookupKey = CacheKey.Create(this.constructor.Body.ExpressionToCSharp(), this.source.Properties.IsColumnar);

            var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => TemporalEgressTemplate.Generate(this));

            this.errorMessages = generatedPipeType.Item2;
            return(generatedPipeType.Item1 != null);
        }
예제 #8
0
        internal static Tuple <Type, string> Generate <TKey, TPayload, TResult>(PartitionedIntervalObservable <TKey, TPayload, TResult> partitionedIntervalObservable)
        {
            string errorMessages = null;

            try
            {
                var template = new TemporalEgressTemplate(typeof(TKey), typeof(TPayload), typeof(TResult), "Partitioned", "Interval", partitionedIntervalObservable.source.Properties.IsColumnar);
                if (partitionedIntervalObservable.constructor != null)
                {
                    template.intervalFunction = (x, y, z) =>
                                                partitionedIntervalObservable.constructor.Body.ExpressionToCSharpStringWithParameterSubstitution(
                        new Dictionary <ParameterExpression, string>
                    {
                        { partitionedIntervalObservable.constructor.Parameters[0], "colkey[i].Key" },
                        { partitionedIntervalObservable.constructor.Parameters[0], x },
                        { partitionedIntervalObservable.constructor.Parameters[1], y },
                        { partitionedIntervalObservable.constructor.Parameters[2], z },
                    });
                }
                var keyType      = typeof(PartitionKey <>).MakeGenericType(typeof(TKey));
                var expandedCode = template.TransformText();

                var assemblyReferences = Transformer.AssemblyReferencesNeededFor(keyType, typeof(TPayload), typeof(TResult));
                assemblyReferences.Add(typeof(IStreamable <,>).GetTypeInfo().Assembly);
                assemblyReferences.Add(Transformer.GeneratedStreamMessageAssembly <PartitionKey <TKey>, TPayload>());

                var a = Transformer.CompileSourceCode(expandedCode, assemblyReferences, out errorMessages);
                var t = a.GetType(template.className);
                return(Tuple.Create(t, errorMessages));
            }
            catch
            {
                if (Config.CodegenOptions.DontFallBackToRowBasedExecution)
                {
                    throw new InvalidOperationException("Code Generation failed when it wasn't supposed to!");
                }
                return(Tuple.Create((Type)null, errorMessages));
            }
        }