예제 #1
0
        public TService?GetService <TService>() where TService : class, IDocumentService
        {
            if (typeof(TService) == typeof(ISpanMappingService))
            {
                if (_spanMappingService == null)
                {
                    lock (_lock)
                    {
                        if (_spanMappingService == null)
                        {
                            var razorMappingService = _innerDocumentServiceProvider.GetService <IRazorSpanMappingService>();
                            _spanMappingService = new RazorSpanMappingServiceWrapper(razorMappingService);
                        }
                    }
                }

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

            if (typeof(TService) == typeof(IDocumentExcerptService))
            {
                if (_excerptService == null)
                {
                    lock (_lock)
                    {
                        if (_excerptService == null)
                        {
                            var excerptService = _innerDocumentServiceProvider.GetService <IRazorDocumentExcerptService>();
                            _excerptService = new RazorDocumentExcerptServiceWrapper(excerptService);
                        }
                    }
                }

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

            return(this as TService);
        }
        public TService?GetService <TService>() where TService : class, IDocumentService
        {
            var serviceType = typeof(TService);

            if (serviceType == typeof(ISpanMappingService))
            {
                if (_spanMappingService == null)
                {
                    lock (_lock)
                    {
                        if (_spanMappingService == null)
                        {
                            var razorMappingService = _innerDocumentServiceProvider.GetService <IRazorSpanMappingService>();
                            if (razorMappingService != null)
                            {
                                _spanMappingService = new RazorSpanMappingServiceWrapper(razorMappingService);
                            }
                            else
                            {
                                return(this as TService);
                            }
                        }
                    }
                }

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

            if (serviceType == typeof(IDocumentExcerptService))
            {
                if (_excerptService == null)
                {
                    lock (_lock)
                    {
                        if (_excerptService == null)
                        {
                            var excerptService = _innerDocumentServiceProvider.GetService <IRazorDocumentExcerptService>();
                            if (excerptService != null)
                            {
                                _excerptService = new RazorDocumentExcerptServiceWrapper(excerptService);
                            }
                            else
                            {
                                return(this as TService);
                            }
                        }
                    }
                }

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

            if (serviceType == typeof(DocumentPropertiesService))
            {
                if (_documentPropertiesService == null)
                {
                    lock (_lock)
                    {
                        if (_documentPropertiesService == null)
                        {
                            var documentPropertiesService = _innerDocumentServiceProvider.GetService <IRazorDocumentPropertiesService>();

                            if (documentPropertiesService != null)
                            {
                                _documentPropertiesService = new RazorDocumentPropertiesServiceWrapper(documentPropertiesService);
                            }
                            else
                            {
                                return(this as TService);
                            }
                        }
                    }
                }

                return((TService)(object)_documentPropertiesService);
            }

            return(this as TService);
        }