Example #1
0
        /// <summary>
        /// This method returns a language-specific service.
        ///
        /// It provides a point of extensibility for a language implementation
        /// to offer more functionality than the standard engine members discussed here.
        ///
        /// Commonly available services include:
        ///     TokenCategorizer
        ///         Provides standardized tokenization of source code
        ///     ExceptionOperations
        ///         Provides formatting of exception objects.
        ///     DocumentationProvidera
        ///         Provides documentation for live object.
        /// </summary>
        public TService GetService <TService>(params object[] args) where TService : class
        {
            if (typeof(TService) == typeof(TokenCategorizer))
            {
                TokenizerService service = LanguageContext.GetService <TokenizerService>(ArrayUtils.Insert((object)LanguageContext, args));
                return((service != null) ? (TService)(object)new TokenCategorizer(service) : null);
            }

            if (typeof(TService) == typeof(ExceptionOperations))
            {
                ExceptionOperations service = LanguageContext.GetService <ExceptionOperations>();
                return((service != null) ? (TService)(object)service : (TService)(object)new ExceptionOperations(LanguageContext));
            }

            if (typeof(TService) == typeof(DocumentationOperations))
            {
                DocumentationProvider service = LanguageContext.GetService <DocumentationProvider>(args);
                return((service != null) ? (TService)(object)new DocumentationOperations(service) : null);
            }

            return(LanguageContext.GetService <TService>(args));
        }