Esempio n. 1
0
 public RazorDocumentExcerptServiceWrapper(
     IRazorDocumentExcerptService razorDocumentExcerptService
     )
 {
     _razorDocumentExcerptService =
         razorDocumentExcerptService
         ?? throw new ArgumentNullException(nameof(razorDocumentExcerptService));
 }
        public TService GetService <TService>() where TService : class
        {
            if (_documentContainer == null)
            {
                return(this as TService);
            }

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

                return((TService)_spanMappingService);
            }

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

                return((TService)_excerptService);
            }

            if (typeof(TService) == typeof(IRazorDocumentPropertiesService))
            {
                if (_documentPropertiesService == null)
                {
                    lock (_lock)
                    {
                        if (_documentPropertiesService == null)
                        {
                            _documentPropertiesService = _documentContainer.GetDocumentPropertiesService();
                        }
                    }
                }

                return((TService)_documentPropertiesService);
            }

            return(this as TService);
        }
            public override IRazorDocumentExcerptService GetExcerptService()
            {
                if (_excerptService == null)
                {
                    var mappingService = GetMappingService();
                    _excerptService = new CSharpDocumentExcerptService(mappingService, _documentSnapshot);
                }

                return(_excerptService);
            }