Example #1
0
        public void AttachResolver(Scope root)
        {
            if (ErrorMessages.Any() || Dependencies.Any(x => x.ErrorMessages.Any()))
            {
                _resolver = new ErrorMessageResolver(this);
            }
            else
            {
                _resolver = (IResolver)root.QuickBuild(_resolverType.CompiledType);
                _resolverType.ApplySetterValues(_resolver);
            }

            _resolver.Hash = GetHashCode();
            _resolver.Name = Name;
        }
        internal ILiveAggregator <T> BuildLiveAggregator()
        {
            var aggregator = (ILiveAggregator <T>)Activator.CreateInstance(_liveType.CompiledType, this);

            _liveType.ApplySetterValues(aggregator);

            return(aggregator);
        }
Example #3
0
        internal IInlineProjection BuildInlineProjection(IMartenSession session)
        {
            var storage = session.StorageFor <T>();

            var inline = (IInlineProjection)Activator.CreateInstance(_inlineType.CompiledType, this, storage, this);

            _inlineType.ApplySetterValues(inline);

            return(inline);
        }
Example #4
0
        internal IInlineProjection BuildInlineProjection(StoreOptions options)
        {
            var storage = options.Providers.StorageFor <T>().Lightweight;
            var slicer  = buildEventSlicer();

            var inline = (IInlineProjection)Activator.CreateInstance(_inlineType.CompiledType, this, slicer, options.Tenancy, storage, this);

            _inlineType.ApplySetterValues(inline);

            return(inline);
        }
Example #5
0
        internal override IProjection Build(DocumentStore store)
        {
            if (_inlineType == null)
            {
                Compile();
            }

            var inline = (IProjection)Activator.CreateInstance(_inlineType.CompiledType, this);

            _inlineType.ApplySetterValues(inline);

            return(inline);
        }
Example #6
0
        IProjection IProjectionSource.Build(DocumentStore store)
        {
            if (_inlineType == null)
            {
                Compile();
            }

            Debug.WriteLine(_inlineType.SourceCode);

            var inline = (IProjection)Activator.CreateInstance(_inlineType.CompiledType, this);

            _inlineType.ApplySetterValues(inline);

            return(inline);
        }
Example #7
0
        IInlineProjection IProjectionSource.BuildInline(StoreOptions options)
        {
            if (_inlineType == null)
            {
                Compile(options);
            }

            Debug.WriteLine(_inlineType.SourceCode);

            var inline = (IInlineProjection)Activator.CreateInstance(_inlineType.CompiledType, this);

            _inlineType.ApplySetterValues(inline);

            return(inline);
        }
        private void buildResolver(Scope scope)
        {
            if (_resolver != null)
            {
                return;
            }

            if (ErrorMessages.Any() || Dependencies.Any(x => x.ErrorMessages.Any()))
            {
                _resolver = new ErrorMessageResolver(this);
            }
            else
            {
                if (scope.ServiceGraph.CachedResolverTypes.TryGetValue(GetResolverTypeName(), out var resolverType))
                {
                    _resolver = (IResolver)scope.Root.QuickBuild(resolverType);
                }
                else
                {
                    var assembly = scope.ServiceGraph.ToGeneratedAssembly();
                    GenerateResolver(assembly);

                    if (_resolverType == null)
                    {
                        _resolver = new ErrorMessageResolver(this);
                    }
                    else
                    {
                        assembly.CompileAll();

                        _resolver = (IResolver)scope.Root.QuickBuild(_resolverType.CompiledType);
                        _resolverType.ApplySetterValues(_resolver);
                    }
                }
            }

            _resolver.Hash = GetHashCode();
            _resolver.Name = Name;
        }
        internal IProjection BuildRuntime(DocumentStore store)
        {
            if (_liveType == null)
            {
                Compile(store.Options);
            }

            var storage = store.Options.Providers.StorageFor <T>().Lightweight;
            var slicer  = buildEventSlicer();

            var ctor = _inlineType.CompiledType.GetConstructors().Single();

            foreach (var parameter in ctor.GetParameters())
            {
                Debug.WriteLine(parameter.ParameterType.NameInCode());
            }

            var inline = (IProjection)Activator.CreateInstance(_inlineType.CompiledType, store, this, slicer, store.Options.Tenancy, storage, this);

            _inlineType.ApplySetterValues(inline);

            return(inline);
        }