public RazorDocumentExcerptService(DocumentSnapshot document, ISpanMappingService mapper)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }

            _document = document;
            _mapper   = mapper;
        }
Example #2
0
        public TService GetService <TService>() where TService : class, IDocumentService
        {
            if (_documentContainer == null)
            {
                return(this as TService);
            }

            if (typeof(TService) == typeof(ISpanMappingService))
            {
                if (_spanMappingService == null)
                {
                    lock (_lock)
                    {
                        if (_spanMappingService == null)
                        {
                            var spanMappingServiceObject = _documentContainer.GetMappingService();
                            _spanMappingService = (ISpanMappingService)spanMappingServiceObject;
                        }
                    }
                }

                return((TService)(object)_spanMappingService);
            }

            if (typeof(TService) == typeof(IDocumentExcerptService))
            {
                if (_excerptService == null)
                {
                    lock (_lock)
                    {
                        if (_excerptService == null)
                        {
                            var excerptServiceObject = _documentContainer.GetExcerptService();
                            _excerptService = (IDocumentExcerptService)excerptServiceObject;
                        }
                    }
                }

                return((TService)(object)_excerptService);
            }

            return(this as TService);
        }